45#pragma clang diagnostic ignored "-Wc++98-compat"
61 open (
const char* path,
int oflag, ...)
65 va_start(args, oflag);
66 io*
const ret =
vopen (path, oflag, args);
78 vopen (
const char* path,
int oflag, std::va_list args)
80#if defined(OS_TRACE_POSIX_IO_IO)
81 trace::printf (
"io::%s(\"%s\")\n", __func__, path ? path :
"");
106 int oret =
static_cast<device*
> (
io)->
vopen (path, oflag, args);
118 auto adjusted_path = path;
132 io = fs->vopen (adjusted_path, oflag, args);
144#if defined(OS_TRACE_POSIX_IO_IO)
157#if defined(OS_TRACE_POSIX_IO_IO)
166#if defined(OS_TRACE_POSIX_IO_IO)
178#if defined(OS_TRACE_POSIX_IO_IO)
182 if (!
impl ().do_is_opened ())
203#if defined(OS_TRACE_POSIX_IO_IO)
216#if defined(OS_TRACE_POSIX_IO_IO)
231#if defined(OS_TRACE_POSIX_IO_IO)
232 trace::printf (
"io::%s(0x0%X, %u) @%p\n", __func__, buf, nbyte,
this);
241 if (!
impl ().do_is_opened ())
247 if (!
impl ().do_is_connected ())
269 impl ().offset_ += ret;
272#if defined(OS_TRACE_POSIX_IO_IO)
273 trace::printf (
"io::%s(0x0%X, %u) @%p n=%d\n", __func__, buf, nbyte,
this,
282#if defined(OS_TRACE_POSIX_IO_IO)
283 trace::printf (
"io::%s(0x0%X, %u) @%p\n", __func__, buf, nbyte,
this);
292 if (!
impl ().do_is_opened ())
298 if (!
impl ().do_is_connected ())
322 impl ().offset_ += ret;
325#if defined(OS_TRACE_POSIX_IO_IO)
326 trace::printf (
"io::%s(0x0%X, %u) @%p n=%d\n", __func__, buf, nbyte,
this,
335#if defined(OS_TRACE_POSIX_IO_IO)
336 trace::printf (
"io::%s(0x0%X, %d) @%p\n", __func__, iov, iovcnt,
this);
351 if (!
impl ().do_is_opened ())
357 if (!
impl ().do_is_connected ())
369 impl ().offset_ += ret;
380 int ret =
vfcntl (cmd, args);
389#if defined(OS_TRACE_POSIX_IO_IO)
393 if (!
impl ().do_is_opened ())
399 if (!
impl ().do_is_connected ())
424#if defined(OS_TRACE_POSIX_IO_IO)
434 if (!
impl ().do_is_opened ())
440 if (!
impl ().do_is_connected ())
455#if defined(OS_TRACE_POSIX_IO_IO)
456 trace::printf (
"io::%s(%d, %d) @%p\n", __func__, offset, whence,
this);
459 if (!
impl ().do_is_opened ())
475#if defined(OS_TRACE_POSIX_IO_IO)
482#if defined(OS_TRACE_POSIX_IO_IO)
504 const struct iovec* p = iov;
505 for (
int i = 0; i < iovcnt; ++i, ++p)
517#pragma GCC diagnostic push
518#pragma GCC diagnostic ignored "-Wunused-parameter"
541#pragma GCC diagnostic pop
static value_type * identify_device(const char *path)
static int deallocate(file_descriptor_t fildes)
static int allocate(class io *io)
static file_system * identify_mounted(const char **path1, const char **path2=nullptr)
virtual bool do_is_connected(void)
virtual ssize_t do_writev(const struct iovec *iov, int iovcnt)
virtual int do_close(void)=0
virtual int do_vfcntl(int cmd, std::va_list args)
virtual int do_isatty(void)
virtual ssize_t do_write(const void *buf, std::size_t nbyte)=0
virtual void do_deallocate(void)
virtual ssize_t do_read(void *buf, std::size_t nbyte)=0
virtual int do_fstat(struct stat *buf)
virtual off_t do_lseek(off_t offset, int whence)=0
file_descriptor_t file_descriptor(void) const
io(io_impl &impl, type t)
virtual off_t lseek(off_t offset, int whence)
io * alloc_file_descriptor(void)
io_impl & impl(void) const
virtual int fstat(struct stat *buf)
virtual ssize_t write(const void *buf, std::size_t nbyte)
void clear_file_descriptor(void)
virtual ssize_t read(void *buf, std::size_t nbyte)
virtual ssize_t writev(const struct iovec *iov, int iovcnt)
virtual int vfcntl(int cmd, std::va_list args)
int printf(const char *format,...)
Write a formatted string to the trace device.
io * open(const char *path, int oflag,...)
io * vopen(const char *path, int oflag, std::va_list args)
int stat(const char *path, struct stat *buf)
constexpr file_descriptor_t no_file_descriptor