[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT PATCH 4/6] 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>
---
 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.h
index 80845b79..7f323417 100644
--- a/lib/vfscore/include/vfscore/file.h
+++ b/lib/vfscore/include/vfscore/file.h
@@ -52,12 +52,15 @@ struct vfscore_fops {
        ssize_t (*read)(struct vfscore_file *, void *, size_t);
 };
 
+#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 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. */
-- 
2.19.2


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.