[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCH v3 4/5] lib/vfscore: do not advance position for stdio
With the proper handling of uio for stdio files, vfs also advances the position in the struct file. Which does not make any sense for console (and some other classes of devices). This patch adds another flags variable inside struct vfscore_file. Using f_flags would add more mess in the code, because most of the flags are defined in fcntl.h, which is external from vfscore header. Signed-off-by: Yuri Volchkov <yuri.volchkov@xxxxxxxxx> Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxxxxxxxxxxx> --- lib/vfscore/fops.c | 6 ++++-- lib/vfscore/include/vfscore/file.h | 6 ++++++ lib/vfscore/stdio.c | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/vfscore/fops.c b/lib/vfscore/fops.c index 79114e21..8f5c2e1b 100644 --- a/lib/vfscore/fops.c +++ b/lib/vfscore/fops.c @@ -75,7 +75,8 @@ int vfs_read(struct vfscore_file *fp, struct uio *uio, int flags) error = VOP_READ(vp, fp, uio, 0); if (!error) { count = bytes - uio->uio_resid; - if ((flags & FOF_OFFSET) == 0) + if (((flags & FOF_OFFSET) == 0) && + !(fp->f_vfs_flags & UK_VFSCORE_NOPOS)) fp->f_offset += count; } vn_unlock(vp); @@ -107,7 +108,8 @@ int vfs_write(struct vfscore_file *fp, struct uio *uio, int flags) error = VOP_WRITE(vp, uio, ioflags); if (!error) { count = bytes - uio->uio_resid; - if ((flags & FOF_OFFSET) == 0) + if (!(flags & FOF_OFFSET) && + !(fp->f_vfs_flags & UK_VFSCORE_NOPOS)) fp->f_offset += count; } diff --git a/lib/vfscore/include/vfscore/file.h b/lib/vfscore/include/vfscore/file.h index 2c0252e2..e602d32d 100644 --- a/lib/vfscore/include/vfscore/file.h +++ b/lib/vfscore/include/vfscore/file.h @@ -46,12 +46,18 @@ extern "C" { struct vfscore_file; +/* Set this flag if vfs should NOt hande POSition for this file. The + * file is not seek-able, updating f_offset does not make sense for + * it */ +#define UK_VFSCORE_NOPOS ((int) (1 << 0)) + struct vfscore_file { int fd; int f_flags; /* open flags */ int f_count; /* reference count */ off_t f_offset; /* current position in file */ void *f_data; /* file descriptor specific data */ + int f_vfs_flags; /* internal implementation flags */ struct dentry *f_dentry; }; diff --git a/lib/vfscore/stdio.c b/lib/vfscore/stdio.c index 56c11a92..bd814fa0 100644 --- a/lib/vfscore/stdio.c +++ b/lib/vfscore/stdio.c @@ -149,6 +149,7 @@ static struct vfscore_file stdio_file = { .fd = 1, .f_flags = UK_FWRITE | UK_FREAD, .f_dentry = &stdio_dentry, + .f_vfs_flags = UK_VFSCORE_NOPOS, /* reference count is 2 because close(0) is a valid * operation. However it is not properly handled in the * current implementation. */ -- 2.19.2 _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |