Skip to contentSkip to conversation

hw/9pfs: Add new security model mapped-file.

PATCH New Aneesh Kumar K.V 1 participant 1 message Jan 12, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/9pfs: Add new security model mapped-file.

From: "Aneesh Kumar K.V" <[email protected]>

This enable us to do passthrough equivalent security model on NFS directory. NFS server mostly do root squashing and don't support xattr. Hence we cannot use 'passthrough' or 'mapped' security model

Also added "mapped-xattr" security to indicate earlier "mapped" security model Older name is still supported.

POSIX rules regarding ctime update on chmod are not followed by this security model.

---
 fsdev/file-op-9p.h         |   12 +-
 hw/9pfs/cofile.c           |   14 ++
 hw/9pfs/virtio-9p-device.c |    9 --
 hw/9pfs/virtio-9p-local.c  |  341 +++++++++++++++++++++++++++++++++++++++++++-
 4 files changed, 359 insertions(+), 17 deletions(-)
fsdev/file-op-9p.h +8 -4
index 1e96c8b..956fda0 100644
@@ -56,11 +56,15 @@ typedef struct extended_ops {
  * On failure ignore the error.
  */
 #define V9FS_SM_NONE                0x00000010
-#define V9FS_RDONLY                 0x00000020
-#define V9FS_PROXY_SOCK_FD          0x00000040
-#define V9FS_PROXY_SOCK_NAME        0x00000080
+/*
+ * uid/gid part of .virtfs_meatadata namespace
+ */
+#define V9FS_SM_MAPPED_FILE         0x00000020
+#define V9FS_RDONLY                 0x00000040
+#define V9FS_PROXY_SOCK_FD          0x00000080
+#define V9FS_PROXY_SOCK_NAME        0x00000100
 
-#define V9FS_SEC_MASK               0x0000001C
+#define V9FS_SEC_MASK               0x0000003C
 
 
 typedef struct FileOperations FileOperations;
hw/9pfs/cofile.c +14 -0
index b15838c..9345aae 100644
@@ -76,6 +76,20 @@ int v9fs_co_fstat(V9fsPDU *pdu, V9fsFidState *fidp, struct stat *stbuf)
                 err = -errno;
             }
         });
+    /*
+     * Some FS driver (local:mapped-file) can't support fetching attributes
+     * using file descriptor. Use Path name in that case.
+     */
+    if (err == -EOPNOTSUPP) {
+        err = v9fs_co_lstat(pdu, &fidp->path, stbuf);
+        if (err == -ENOENT) {
+            /*
+             * fstat on an unlinked file. Work with partial results
+             * returned from s->ops->fstat
+             */
+            err = 0;
+        }
+    }
     return err;
 }
 
hw/9pfs/virtio-9p-device.c +0 -9
index 642d5e2..41a1a82 100644
@@ -91,15 +91,6 @@ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf)
         s->ctx.fs_root = NULL;
     }
     s->ctx.exops.get_st_gen = NULL;
-
-    if (fse->export_flags & V9FS_SM_PASSTHROUGH) {
-        s->ctx.xops = passthrough_xattr_ops;
-    } else if (fse->export_flags & V9FS_SM_MAPPED) {
-        s->ctx.xops = mapped_xattr_ops;
-    } else if (fse->export_flags & V9FS_SM_NONE) {
-        s->ctx.xops = none_xattr_ops;
-    }
-
     len = strlen(conf->tag);
     if (len > MAX_TAG_LEN - 1) {
         fprintf(stderr, "mount tag '%s' (%d bytes) is longer than "
hw/9pfs/virtio-9p-local.c +337 -4

468 lines not on this page · raw message

Signature · 1 line
1.7.8.1.362.g5d6df