static ssize_t evfd_read(const struct uk_file *f,
- const struct iovec *iov, int iovcnt,
+ const struct iovec *iov, size_t iovcnt,
size_t off, long flags __unused)
{
int semaphore;
static ssize_t evfd_write(const struct uk_file *f,
- const struct iovec *iov, int iovcnt,
+ const struct iovec *iov, size_t iovcnt,
size_t off, long flags __unused)
{
uint64_t add;
for (;;) {
if (iolock)
uk_file_rlock(f);
- r = uk_file_read(f, iov, iovcnt, offset, flags);
+ r = uk_file_read(f, iov, (size_t)iovcnt, offset, flags);
if (iolock)
uk_file_runlock(f);
if (!_SHOULD_BLOCK(r, mode))
if (iolock)
uk_file_rlock(f);
- r = uk_file_read(f, iov, iovcnt, off, flags);
+ r = uk_file_read(f, iov, (size_t)iovcnt, off, flags);
if (iolock)
uk_file_runlock(f);
if (!_SHOULD_BLOCK(r, mode))
if (iolock)
uk_file_rlock(f);
- r = uk_file_read(f, iov, iovcnt, off, xflags);
+ r = uk_file_read(f, iov, (size_t)iovcnt, off, xflags);
if (iolock)
uk_file_runlock(f);
if (!_SHOULD_BLOCK(r, mode))
for (;;) {
if (iolock)
uk_file_wlock(f);
- r = uk_file_write(f, iov, iovcnt, offset, flags);
+ r = uk_file_write(f, iov, (size_t)iovcnt, offset, flags);
if (iolock)
uk_file_wunlock(f);
if (!_SHOULD_BLOCK(r, mode))
}
if (likely(off >= 0))
- r = uk_file_write(f, iov, iovcnt, off, flags);
+ r = uk_file_write(f, iov, (size_t)iovcnt, off, flags);
else
r = off;
}
if (likely(off >= 0))
- r = uk_file_write(f, iov, iovcnt, off, xflags);
+ r = uk_file_write(f, iov, (size_t)iovcnt, off, xflags);
else
r = off;
_pipebuf_write(buf, head, (const char *)iov[i].iov_base, n);
}
-static ssize_t _iovsz(const struct iovec *iov, int iovcnt)
+static ssize_t _iovsz(const struct iovec *iov, size_t iovcnt)
{
size_t ret = 0;
- for (int i = 0; i < iovcnt; i++)
+ for (size_t i = 0; i < iovcnt; i++)
if (iov[i].iov_len) {
if (likely(iov[i].iov_base))
ret += iov[i].iov_len;
}
static ssize_t pipe_read(const struct uk_file *f,
- const struct iovec *iov, int iovcnt,
+ const struct iovec *iov, size_t iovcnt,
size_t off, long flags __unused)
{
ssize_t toread;
}
static ssize_t pipe_write(const struct uk_file *f,
- const struct iovec *iov, int iovcnt,
+ const struct iovec *iov, size_t iovcnt,
size_t off, long flags)
{
struct pipe_node *d;
* @return The number of bytes written on success, -errno otherwise
*/
typedef ssize_t (*posix_socket_write_func_t)(posix_sock *sock,
- const struct iovec *iov, int iovcnt);
+ const struct iovec *iov, size_t iovcnt);
/**
* Read from a socket file descriptor.
* @return The number of bytes read on success, -errno otherwise
*/
typedef ssize_t (*posix_socket_read_func_t)(posix_sock *sock,
- const struct iovec *iov, int iovcnt);
+ const struct iovec *iov, size_t iovcnt);
/**
* Close the socket.
static inline ssize_t
posix_socket_write(posix_sock *sock, const struct iovec *iov,
- int iovcnt)
+ size_t iovcnt)
{
struct posix_socket_driver *d = posix_sock_get_driver(sock);
static inline ssize_t
posix_socket_read(posix_sock *sock, const struct iovec *iov,
- int iovcnt)
+ size_t iovcnt)
{
struct posix_socket_driver *d = posix_sock_get_driver(sock);
static ssize_t
socket_read(const struct uk_file *sock,
- const struct iovec *iov, int iovcnt,
+ const struct iovec *iov, size_t iovcnt,
size_t off, long flags __unused)
{
ssize_t ret;
static ssize_t
socket_write(const struct uk_file *sock,
- const struct iovec *iov, int iovcnt,
+ const struct iovec *iov, size_t iovcnt,
size_t off, long flags __unused)
{
ssize_t ret;
/* Ops */
static ssize_t timerfd_read(const struct uk_file *f,
- const struct iovec *iov, int iovcnt,
+ const struct iovec *iov, size_t iovcnt,
size_t off, long flags __unused)
{
struct timerfd_node *d;
static const char ZERO_VOLID[] = "zero_vol";
static ssize_t null_read(const struct uk_file *f __maybe_unused,
- const struct iovec *iov __unused, int iovcnt __unused,
+ const struct iovec *iov __unused,
+ size_t iovcnt __unused,
size_t off __unused, long flags __unused)
{
UK_ASSERT(f->vol == NULL_VOLID);
}
static ssize_t void_read(const struct uk_file *f __maybe_unused,
- const struct iovec *iov __unused, int iovcnt __unused,
+ const struct iovec *iov __unused,
+ size_t iovcnt __unused,
size_t off __unused, long flags __unused)
{
UK_ASSERT(f->vol == VOID_VOLID);
}
static ssize_t zero_read(const struct uk_file *f __maybe_unused,
- const struct iovec *iov, int iovcnt,
+ const struct iovec *iov, size_t iovcnt,
size_t off __unused, long flags __unused)
{
ssize_t total = 0;
UK_ASSERT(f->vol == ZERO_VOLID);
- for (int i = 0; i < iovcnt; i++) {
+ for (size_t i = 0; i < iovcnt; i++) {
if (unlikely(!iov[i].iov_base && iov[i].iov_len))
return -EFAULT;
memset(iov[i].iov_base, 0, iov[i].iov_len);
}
static ssize_t null_write(const struct uk_file *f __maybe_unused,
- const struct iovec *iov, int iovcnt,
+ const struct iovec *iov, size_t iovcnt,
size_t off __unused, long flags __unused)
{
ssize_t total = 0;
UK_ASSERT(f->vol == NULL_VOLID || f->vol == ZERO_VOLID ||
f->vol == VOID_VOLID);
- for (int i = 0; i < iovcnt; i++)
+ for (size_t i = 0; i < iovcnt; i++)
total += iov[i].iov_len;
return total;
}
}
static ssize_t serial_read(const struct uk_file *f,
- const struct iovec *iov, int iovcnt,
+ const struct iovec *iov, size_t iovcnt,
size_t off, long flags __unused)
{
ssize_t total = 0;
if (!uk_file_poll_immediate(f, UKFD_POLLIN))
return 0;
- for (int i = 0; i < iovcnt; i++) {
+ for (size_t i = 0; i < iovcnt; i++) {
char *buf = iov[i].iov_base;
size_t len = iov[i].iov_len;
char *last;
}
static ssize_t serial_write(const struct uk_file *f __maybe_unused,
- const struct iovec *iov, int iovcnt,
+ const struct iovec *iov, size_t iovcnt,
size_t off, long flags __unused)
{
ssize_t total = 0;
if (unlikely(off))
return -ESPIPE;
- for (int i = 0; i < iovcnt; i++) {
+ for (size_t i = 0; i < iovcnt; i++) {
char *buf = iov[i].iov_base;
size_t len = iov[i].iov_len;
int bytes_written;
static
ssize_t unix_socket_read(posix_sock *file,
- const struct iovec *iov, int iovcnt)
+ const struct iovec *iov, size_t iovcnt)
{
struct msghdr msg = {
.msg_name = NULL,
static
ssize_t unix_socket_write(posix_sock *file,
- const struct iovec *iov, int iovcnt)
+ const struct iovec *iov, size_t iovcnt)
{
struct msghdr msg = {
.msg_name = NULL,
ssize_t uk_file_nop_read(const struct uk_file *f __unused,
- const struct iovec *iov __unused, int iovcnt __unused,
+ const struct iovec *iov __unused,
+ size_t iovcnt __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,
+ const struct iovec *iov __unused,
+ size_t iovcnt __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,
+ const struct iovec *iov, size_t iovcnt,
size_t off, long flags);
/* Info (stat-like & chXXX-like) */
/* Operations inlines */
static inline
ssize_t uk_file_read(const struct uk_file *f,
- const struct iovec *iov, int iovcnt,
+ const struct iovec *iov, size_t iovcnt,
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,
+ const struct iovec *iov, size_t iovcnt,
size_t off, long flags)
{
return f->ops->write(f, iov, iovcnt, off, flags);
* @return Number of bytes zeroed
*/
static inline
-size_t uk_iov_zero(const struct iovec *iov, int iovcnt, size_t len,
- int *iovip, size_t *curp)
+size_t uk_iov_zero(const struct iovec *iov, size_t iovcnt, size_t len,
+ size_t *iovip, size_t *curp)
{
size_t ret = 0;
- int i = *iovip;
+ size_t i = *iovip;
size_t cur = *curp;
UK_ASSERT(i < iovcnt);
* @return Number of bytes copied
*/
static inline
-size_t uk_iov_scatter(const struct iovec *iov, int iovcnt, const char *buf,
- size_t len, int *iovip, size_t *curp)
+size_t uk_iov_scatter(const struct iovec *iov, size_t iovcnt, const char *buf,
+ size_t len, size_t *iovip, size_t *curp)
{
size_t ret = 0;
- int i = *iovip;
+ size_t i = *iovip;
size_t cur = *curp;
UK_ASSERT(i < iovcnt);
* @return Number of bytes copied
*/
static inline
-size_t uk_iov_gather(char *buf, const struct iovec *iov, int iovcnt,
- size_t len, int *iovip, size_t *curp)
+size_t uk_iov_gather(char *buf, const struct iovec *iov, size_t iovcnt,
+ size_t len, size_t *iovip, size_t *curp)
{
size_t ret = 0;
- int i = *iovip;
+ size_t i = *iovip;
size_t cur = *curp;
UK_ASSERT(i < iovcnt);
extern const struct uk_file_ops uk_file_nops;
ssize_t uk_file_nop_read(const struct uk_file *f,
- const struct iovec *iov, int iovcnt,
+ const struct iovec *iov, size_t iovcnt,
size_t off, long flags);
ssize_t uk_file_nop_write(const struct uk_file *f,
- const struct iovec *iov, int iovcnt,
+ const struct iovec *iov, size_t iovcnt,
size_t off, long flags);
int uk_file_nop_getstat(const struct uk_file *f,