diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/fs/initramfs.c | 7 | ||||
-rw-r--r-- | sys/include/sys/vfs.h | 3 | ||||
-rw-r--r-- | sys/include/sys/vnode.h | 5 | ||||
-rw-r--r-- | sys/kern/kern_filedesc.c | 14 | ||||
-rw-r--r-- | sys/kern/vfs_subr.c | 4 |
5 files changed, 22 insertions, 11 deletions
diff --git a/sys/fs/initramfs.c b/sys/fs/initramfs.c index 5b31bf9..897a3d4 100644 --- a/sys/fs/initramfs.c +++ b/sys/fs/initramfs.c @@ -121,11 +121,12 @@ vop_vget(struct vnode *parent, const char *name, struct vnode **vp) } static int -vop_read(struct vnode *vp, char *buf, size_t count) +vop_read(struct vnode *vp, struct sio_txn *sio) { struct tar_hdr *hdr; size_t size; char *contents; + char *buf = sio->buf; if (vp->data == NULL) { return -EIO; @@ -135,14 +136,14 @@ vop_read(struct vnode *vp, char *buf, size_t count) size = getsize(hdr->size); contents = hdr_to_contents(hdr); - for (size_t i = 0; i < count; ++i) { + for (size_t i = sio->offset; i < sio->len; ++i) { if (i >= size) { return i + 1; } buf[i] = contents[i]; } - return count; + return sio->len; } static char * diff --git a/sys/include/sys/vfs.h b/sys/include/sys/vfs.h index e219cf7..b454d39 100644 --- a/sys/include/sys/vfs.h +++ b/sys/include/sys/vfs.h @@ -33,6 +33,7 @@ #include <sys/mount.h> #include <sys/vnode.h> #include <sys/types.h> +#include <sys/sio.h> /* Max path length */ #define PATH_MAX 1024 @@ -50,7 +51,7 @@ char *vfs_get_fname_at(const char *path, size_t idx); int vfs_rootname(const char *path, char **new_path); bool vfs_is_valid_path(const char *path); ssize_t vfs_hash_path(const char *path); -ssize_t vfs_read(struct vnode *vp, char *buf, size_t count); +ssize_t vfs_read(struct vnode *vp, struct sio_txn *sio); #endif /* defined(_KERNEL) */ diff --git a/sys/include/sys/vnode.h b/sys/include/sys/vnode.h index 11bbf99..0352312 100644 --- a/sys/include/sys/vnode.h +++ b/sys/include/sys/vnode.h @@ -33,13 +33,14 @@ #include <sys/types.h> #include <sys/queue.h> #include <sys/mount.h> +#include <sys/sio.h> struct vnode; struct vops { int(*vget)(struct vnode *parent, const char *name, struct vnode **vp); - int(*read)(struct vnode *vp, char *buf, size_t count); - int(*write)(struct vnode *vp, const char *buf, size_t count); + int(*read)(struct vnode *vp, struct sio_txn *sio); + int(*write)(struct vnode *vp, struct sio_txn *sio); }; struct vnode { diff --git a/sys/kern/kern_filedesc.c b/sys/kern/kern_filedesc.c index 80ab094..63ffa98 100644 --- a/sys/kern/kern_filedesc.c +++ b/sys/kern/kern_filedesc.c @@ -29,6 +29,7 @@ #include <sys/filedesc.h> #include <sys/proc.h> +#include <sys/sio.h> #include <sys/sched.h> #include <sys/errno.h> #include <sys/system.h> @@ -90,8 +91,9 @@ make_write_buf(struct proc *td, const void *data, char **buf_out, size_t count) * Helper function for write() */ static ssize_t -do_write(struct vnode *vp, const char *buf, size_t count) +do_write(struct vnode *vp, char *buf, size_t count) { + struct sio_txn sio = { .buf = buf, .len = count }; struct vops *vops = vp->vops; int status; @@ -103,7 +105,7 @@ do_write(struct vnode *vp, const char *buf, size_t count) } /* Attempt a write */ - if ((status = vops->write(vp, buf, count)) < 0) { + if ((status = vops->write(vp, &sio)) < 0) { return status; } @@ -313,8 +315,14 @@ read(int fd, void *buf, size_t count) ssize_t bytes_read; struct vnode *vnode; struct filedesc *fd_desc; + struct sio_txn sio = { + .buf = buf, + .len = count, + .type = SIO_NONE + }; fd_desc = fd_from_fdnum(this_td(), fd); + sio.offset = fd_desc->offset; if (fd_desc == NULL) { return -EBADF; @@ -326,7 +334,7 @@ read(int fd, void *buf, size_t count) return -EINVAL; } - bytes_read = vfs_read(vnode, buf, count); + bytes_read = vfs_read(vnode, &sio); return bytes_read; } diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 5155c9a..bbaec12 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -225,7 +225,7 @@ vfs_vget(struct vnode *parent, const char *name, struct vnode **vp) } ssize_t -vfs_read(struct vnode *vp, char *buf, size_t count) +vfs_read(struct vnode *vp, struct sio_txn *sio) { - return vp->vops->read(vp, buf, count); + return vp->vops->read(vp, sio); } |