static ssize_t evfd_read(const struct uk_file *f,
const struct iovec *iov, int iovcnt,
- off_t off, long flags __unused)
+ size_t off, long flags __unused)
{
int semaphore;
evfd_node n;
static ssize_t evfd_write(const struct uk_file *f,
const struct iovec *iov, int iovcnt,
- off_t off, long flags __unused)
+ size_t off, long flags __unused)
{
uint64_t add;
evfd_node n;
const struct uk_file *file;
unsigned int mode;
__atomic refcnt;
- off_t pos; /* Current file read/write offset position */
+ size_t pos; /* Current file read/write offset position */
struct uk_mutex lock; /* Lock for modifying open file state */
};
{
ssize_t r;
long flags;
- off_t off;
+ size_t off;
const struct uk_file *f;
int seekable;
int iolock;
off_t offset, int flags)
{
ssize_t r;
- off_t off;
+ size_t off;
long xflags;
const struct uk_file *f;
unsigned int mode;
}
if (use_pos) {
- if (r >= 0)
+ if (r >= 0) {
+ UK_ASSERT(off >= 0);
of->pos = off + r;
+ }
_of_unlock(of);
}
static ssize_t pipe_read(const struct uk_file *f,
const struct iovec *iov, int iovcnt,
- off_t off, long flags __unused)
+ size_t off, long flags __unused)
{
ssize_t toread;
struct pipe_node *d;
static ssize_t pipe_write(const struct uk_file *f,
const struct iovec *iov, int iovcnt,
- off_t off, long flags)
+ size_t off, long flags)
{
struct pipe_node *d;
struct pipe_msg *tail;
static ssize_t
socket_read(const struct uk_file *sock,
const struct iovec *iov, int iovcnt,
- off_t off, long flags __unused)
+ size_t off, long flags __unused)
{
ssize_t ret;
struct posix_socket_driver *d;
static ssize_t
socket_write(const struct uk_file *sock,
const struct iovec *iov, int iovcnt,
- off_t off, long flags __unused)
+ size_t off, long flags __unused)
{
ssize_t ret;
struct posix_socket_driver *d;
static ssize_t timerfd_read(const struct uk_file *f,
const struct iovec *iov, int iovcnt,
- off_t off, long flags __unused)
+ size_t off, long flags __unused)
{
struct timerfd_node *d;
__u64 v;
if (unlikely(f->vol != TIMERFD_VOLID))
return -EINVAL;
- if (unlikely(off != 0))
+ if (unlikely(off))
return -EINVAL;
if (unlikely(!iovcnt || iov[0].iov_len < sizeof(__u64)))
return -EINVAL;
static ssize_t null_read(const struct uk_file *f __maybe_unused,
const struct iovec *iov __unused, int iovcnt __unused,
- off_t off __unused, long flags __unused)
+ size_t off __unused, long flags __unused)
{
UK_ASSERT(f->vol == NULL_VOLID);
return 0;
static ssize_t void_read(const struct uk_file *f __maybe_unused,
const struct iovec *iov __unused, int iovcnt __unused,
- off_t off __unused, long flags __unused)
+ size_t off __unused, long flags __unused)
{
UK_ASSERT(f->vol == VOID_VOLID);
return -EAGAIN;
static ssize_t zero_read(const struct uk_file *f __maybe_unused,
const struct iovec *iov, int iovcnt,
- off_t off __unused, long flags __unused)
+ size_t off __unused, long flags __unused)
{
ssize_t total = 0;
static ssize_t null_write(const struct uk_file *f __maybe_unused,
const struct iovec *iov, int iovcnt,
- off_t off __unused, long flags __unused)
+ size_t off __unused, long flags __unused)
{
ssize_t total = 0;
static ssize_t serial_read(const struct uk_file *f,
const struct iovec *iov, int iovcnt,
- off_t off, long flags __unused)
+ size_t off, long flags __unused)
{
ssize_t total = 0;
UK_ASSERT(f->vol == SERIAL_VOLID);
- if (unlikely(off != 0))
- return -EINVAL;
+ if (unlikely(off))
+ return -ESPIPE;
if (!uk_file_poll_immediate(f, UKFD_POLLIN))
return 0;
static ssize_t serial_write(const struct uk_file *f __maybe_unused,
const struct iovec *iov, int iovcnt,
- off_t off, long flags __unused)
+ size_t off, long flags __unused)
{
ssize_t total = 0;
UK_ASSERT(f->vol == SERIAL_VOLID);
- if (unlikely(off != 0))
- return -EINVAL;
+ if (unlikely(off))
+ return -ESPIPE;
for (int i = 0; i < iovcnt; i++) {
char *buf = iov[i].iov_base;
ssize_t uk_file_nop_read(const struct uk_file *f __unused,
const struct iovec *iov __unused, int iovcnt __unused,
- off_t off __unused, long flags __unused)
+ size_t off __unused, long flags __unused)
{
return -ENOSYS;
}
ssize_t uk_file_nop_write(const struct uk_file *f __unused,
const struct iovec *iov __unused, int iovcnt __unused,
- off_t off __unused, long flags __unused)
+ size_t off __unused, long flags __unused)
{
return -ENOSYS;
}
/* I/O */
typedef ssize_t (*uk_file_io_func)(const struct uk_file *f,
const struct iovec *iov, int iovcnt,
- off_t off, long flags);
+ size_t off, long flags);
/* Info (stat-like & chXXX-like) */
typedef int (*uk_file_getstat_func)(const struct uk_file *f,
static inline
ssize_t uk_file_read(const struct uk_file *f,
const struct iovec *iov, int iovcnt,
- off_t off, long flags)
+ size_t off, long flags)
{
return f->ops->read(f, iov, iovcnt, off, flags);
}
static inline
ssize_t uk_file_write(const struct uk_file *f,
const struct iovec *iov, int iovcnt,
- off_t off, long flags)
+ size_t off, long flags)
{
return f->ops->write(f, iov, iovcnt, off, flags);
}
ssize_t uk_file_nop_read(const struct uk_file *f,
const struct iovec *iov, int iovcnt,
- off_t off, long flags);
+ size_t off, long flags);
ssize_t uk_file_nop_write(const struct uk_file *f,
const struct iovec *iov, int iovcnt,
- off_t off, long flags);
+ size_t off, long flags);
int uk_file_nop_getstat(const struct uk_file *f,
unsigned int mask, struct uk_statx *arg);