[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Minios-devel] [UNIKRAFT PATCH v2 4/5] lib/vfscore: do not advance position for stdio
Hi Yuri, On 6/3/19 11:04 AM, Yuri Volchkov wrote: 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> --- lib/vfscore/fops.c | 3 ++- lib/vfscore/include/vfscore/file.h | 3 +++ lib/vfscore/stdio.c | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/vfscore/fops.c b/lib/vfscore/fops.c index 79114e21..ad78d3b1 100644 --- a/lib/vfscore/fops.c +++ b/lib/vfscore/fops.c @@ -107,7 +107,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.hindex 2c0252e2..be1c7772 100644 --- a/lib/vfscore/include/vfscore/file.h +++ b/lib/vfscore/include/vfscore/file.h @@ -46,12 +46,15 @@ extern "C" {struct vfscore_file; +#define UK_VFSCORE_NOPOS ((int) (1 << 0))+ I was scratching my head here wondering what a NOP-OS is, until I realized (and it took me way longer that it should have!) that it's about NO-POS(isition information). Maybe explain that really quickly in the code for other people who are as slow as me. ;-) As a side note: the lwip<->vfscore then should probably also set this on lwip sockets? Since they are also not seekable and don't have a "file position"? 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.cindex 8e3ccbdb..40288bb3 100644 --- a/lib/vfscore/stdio.c +++ b/lib/vfscore/stdio.c @@ -144,6 +144,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. */ -- Dr. Florian Schmidt フローリアン・シュミット Research Scientist, Systems and Machine Learning Group NEC Laboratories Europe Kurfürsten-Anlage 36, D-69115 Heidelberg Tel. +49 (0)6221 4342-265 Fax: +49 (0)6221 4342-155 e-mail: florian.schmidt@xxxxxxxxx ============================================================ Registered at Amtsgericht Mannheim, Germany, HRB728558 _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |