41#pragma clang diagnostic ignored "-Wc++98-compat"
56#if defined(OS_TRACE_POSIX_IO_BLOCK_DEVICE)
57 trace::printf (
"block_device::%s(\"%s\")=@%p\n", __func__, name_,
this);
65#if defined(OS_TRACE_POSIX_IO_BLOCK_DEVICE)
66 trace::printf (
"block_device::%s() @%p %s\n", __func__,
this, name_);
75#if defined(OS_TRACE_POSIX_IO_BLOCK_DEVICE)
76 trace::printf (
"block_device::%s(%p, %u, %u) @%p\n", __func__, buf,
77 blknum, nblocks,
this);
80 if (blknum + nblocks >
impl ().num_blocks_)
86 if (!
impl ().do_is_opened ())
99#if defined(OS_TRACE_POSIX_IO_BLOCK_DEVICE)
100 trace::printf (
"block_device::%s(%p, %u, %u) @%p\n", __func__, buf,
101 blknum, nblocks,
this);
104 if (blknum + nblocks >
impl ().num_blocks_)
110 if (!
impl ().do_is_opened ())
122#if defined(OS_TRACE_POSIX_IO_BLOCK_DEVICE)
123 trace::printf (
"block_device::%s(%d) @%p\n", __func__, request,
this);
126 if (!
impl ().do_is_opened ())
134 switch (
static_cast<unsigned int> (request))
139 std::size_t* sz = va_arg(args, std::size_t*);
140 if (sz ==
nullptr ||
impl ().block_logical_size_bytes_ != 0)
146 *sz =
impl ().block_logical_size_bytes_;
153 std::size_t* sz = va_arg(args, std::size_t*);
154 if (sz ==
nullptr ||
impl ().block_physical_size_bytes_ != 0)
160 *sz =
impl ().block_physical_size_bytes_;
167 uint64_t* sz = va_arg(args, uint64_t*);
168 if (sz ==
nullptr ||
impl ().num_blocks_ != 0)
174 *sz = (
static_cast<uint64_t
> (
impl ().num_blocks_
175 *
impl ().block_logical_size_bytes_));
190#if defined(OS_TRACE_POSIX_IO_BLOCK_DEVICE)
191 trace::printf (
"block_device_impl::%s()=@%p\n", __func__,
this);
197#if defined(OS_TRACE_POSIX_IO_BLOCK_DEVICE)
198 trace::printf (
"block_device_impl::%s() @%p\n", __func__,
this);
201 block_logical_size_bytes_ = 0;
210#if defined(OS_TRACE_POSIX_IO_BLOCK_DEVICE)
247#if defined(OS_TRACE_POSIX_IO_BLOCK_DEVICE)
248 trace::printf (
"block_device_impl::%s(%p, %u) @%p\n", __func__, buf,
252 if ((block_logical_size_bytes_ == 0)
253 || ((nbyte % block_logical_size_bytes_) != 0)
254 || ((
static_cast<std::size_t
> (offset_) % block_logical_size_bytes_)
261 std::size_t nblocks = nbyte / block_logical_size_bytes_;
262 blknum_t blknum =
static_cast<std::size_t
> (offset_)
263 / block_logical_size_bytes_;
265 if (blknum + nblocks > num_blocks_)
274 ret *= block_logical_size_bytes_;
282#if defined(OS_TRACE_POSIX_IO_BLOCK_DEVICE)
283 trace::printf (
"block_device_impl::%s(%p, %u) @%p\n", __func__, buf,
287 if ((block_logical_size_bytes_ == 0)
288 || ((nbyte % block_logical_size_bytes_) != 0)
289 || ((
static_cast<std::size_t
> (offset_) % block_logical_size_bytes_)
296 std::size_t nblocks = nbyte / block_logical_size_bytes_;
297 blknum_t blknum =
static_cast<std::size_t
> (offset_)
298 / block_logical_size_bytes_;
300 if (blknum + nblocks > num_blocks_)
309 ret *= block_logical_size_bytes_;
virtual ssize_t do_read(void *buf, std::size_t nbyte) override
virtual off_t do_lseek(off_t offset, int whence) override
virtual ssize_t do_read_block(void *buf, blknum_t blknum, std::size_t nblocks)=0
virtual ~block_device_impl() override
virtual ssize_t do_write(const void *buf, std::size_t nbyte) override
virtual ssize_t do_write_block(const void *buf, blknum_t blknum, std::size_t nblocks)=0
block_device::blknum_t blknum_t
virtual ~block_device() override
block_device_impl & impl(void) const
virtual int vioctl(int request, std::va_list args) override
virtual ssize_t read_block(void *buf, blknum_t blknum, std::size_t nblocks=1)
virtual ssize_t write_block(const void *buf, blknum_t blknum, std::size_t nblocks=1)
virtual int do_vioctl(int request, std::va_list args)=0
static void link(value_type *device)
const char * name(void) const
int printf(const char *format,...)
Write a formatted string to the trace device.