46 pr_dinfo2(io,
"io_init(%p, %d, %d, %p)", (
void *) io, type, flags, (
void *) ops);
56 mos_warn(
"ops->read is NULL for readable io");
60 mos_warn(
"ops->write is NULL for writable io");
64 mos_warn(
"io->ops->seek is NULL for seekable io");
84 mos_warn(
"%p is already closed", (
void *) io);
94 pr_dinfo2(io,
"io_unref(%p)", (
void *) io);
97 mos_warn(
"%p is already closed", (
void *) io);
103 mos_warn(
"%p has refcount 0", (
void *) io);
113 pr_dinfo2(io,
"closing %p", (
void *) io);
119 pr_dinfo2(io,
"%p is not closeable", (
void *) io);
134 pr_dinfo2(io,
"io_read(%p, %p, %zu)", (
void *) io, buf, count);
138 mos_warn(
"%p is already closed", (
void *) io);
144 pr_info2(
"%p is not readable\n", (
void *) io);
148 return io->
ops->
read(io, buf, count);
153 pr_dinfo2(io,
"io_pread(%p, %p, %zu, %lu)", (
void *) io, buf, count, offset);
157 mos_warn(
"%p is already closed", (
void *) io);
163 pr_info2(
"%p is not readable\n", (
void *) io);
169 pr_info2(
"%p is not seekable\n", (
void *) io);
175 const size_t ret =
io_read(io, buf, count);
182 pr_dinfo2(io,
"io_write(%p, %p, %zu)", (
void *) io, buf, count);
186 mos_warn(
"%p is already closed", (
void *) io);
192 pr_info2(
"%p is not writable", (
void *) io);
196 return io->
ops->
write(io, buf, count);
201 pr_dinfo2(io,
"io_seek(%p, %lu, %d)", (
void *) io, offset, whence);
205 mos_warn(
"%p is already closed", (
void *) io);
211 pr_info2(
"%p is not seekable", (
void *) io);
215 return io->
ops->
seek(io, offset, whence);
220 pr_dinfo2(io,
"io_tell(%p)", (
void *) io);
228 mos_warn(
"%p is already closed", (
void *) io);
234 pr_info2(
"%p is not mmapable", (
void *) io);
244 if (!may_mmap_writeable)
256 pr_dinfo2(io,
"io_mmap(%p, %p, %lu)", (
void *) io, (
void *) vmap, offset);
263 if (!io->
ops->
mmap(io, vmap, offset))
267 mos_panic(
"vmap->on_fault is NULL, possibly buggy io->ops->mmap() implementation");
275 pr_dinfo2(io,
"io_unmap(%p, %p, %p)", (
void *) io, (
void *) vmap, (
void *) unmapped);
278 mos_warn(
"%p is already closed", (
void *) io);
298 mos_warn(
"vmap->io->ops->unmap() failed");
#define mos_warn(fmt,...)
MOSAPI void(1, 2) fatal_abort(const char *fmt
bool io_mmap_perm_check(io_t *io, vm_flags flags, bool is_private)
size_t io_pread(io_t *io, void *buf, size_t count, off_t offset)
bool io_munmap(io_t *io, vmap_t *vmap, bool *unmapped)
static size_t _null_read(io_t *io, void *buffer, size_t size)
void io_init(io_t *io, io_type_t type, io_flags_t flags, const io_op_t *ops)
bool io_mmap(io_t *io, vmap_t *vmap, off_t offset)
off_t io_seek(io_t *io, off_t offset, io_seek_whence_t whence)
io_t * io_unref(io_t *io)
size_t io_write(io_t *io, const void *buf, size_t count)
bool io_valid(const io_t *io)
size_t io_read(io_t *io, void *buf, size_t count)
static size_t _null_write(io_t *io, const void *buffer, size_t size)
void io_get_name(const io_t *io, char *buf, size_t size)
int snprintf(char *__restrict str, size_t size, const char *__restrict format,...)
#define mos_panic(fmt,...)
#define pr_info2(fmt,...)
#define pr_dinfo2(feat, fmt,...)
size_t(* read)(io_t *io, void *buf, size_t count)
off_t(* seek)(io_t *io, off_t offset, io_seek_whence_t whence)
bool(* mmap)(io_t *io, vmap_t *vmap, off_t offset)
bool(* munmap)(io_t *io, vmap_t *vmap, bool *unmapped)
void(* get_name)(const io_t *io, char *buf, size_t size)
size_t(* write)(io_t *io, const void *buf, size_t count)
vmfault_handler_t on_fault