diff options
author | Jari Vetoniemi <mailroxas@gmail.com> | 2018-10-19 14:35:16 +0300 |
---|---|---|
committer | Jari Vetoniemi <mailroxas@gmail.com> | 2018-10-19 15:13:07 +0300 |
commit | 743fb001f3d381b14d48f3fdfc9ee648a7c0644c (patch) | |
tree | e46f65bfac59427b1389a4fb5d8c13ca34ed1c69 /src/io/io.h | |
parent | 6cb8c44fef192f3f8e7164d9c3baccacc9db620c (diff) |
Refactor project, offer uio variant of region-rw
Diffstat (limited to 'src/io/io.h')
-rw-r--r-- | src/io/io.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/io/io.h b/src/io/io.h new file mode 100644 index 0000000..8a0639b --- /dev/null +++ b/src/io/io.h @@ -0,0 +1,27 @@ +#pragma once + +#include <stddef.h> +#include <stdbool.h> +#include <sys/types.h> // pid_t + +struct io { + void *backing; + size_t (*read)(const struct io *io, void *ptr, const size_t offset, const size_t size); + size_t (*write)(const struct io *io, const void *ptr, const size_t offset, const size_t size); + void (*cleanup)(struct io *io); + pid_t pid; +}; + +static inline void +io_release(struct io *io) +{ + if (io->cleanup) + io->cleanup(io); + *io = (struct io){0}; +} + +bool +io_uio_init(struct io *io, const pid_t pid); + +bool +io_ptrace_init(struct io *io, const pid_t pid); |