Skip to content

Commit

Permalink
hw/9pfs: Add new security model mapped-file.
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Aneesh Kumar K.V <[email protected]>
  • Loading branch information
kvaneesh committed Jan 19, 2012
1 parent 8c4ec5c commit 2c30dd7
Show file tree
Hide file tree
Showing 5 changed files with 378 additions and 25 deletions.
12 changes: 8 additions & 4 deletions fsdev/file-op-9p.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 14 additions & 0 deletions hw/9pfs/cofile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
9 changes: 0 additions & 9 deletions hw/9pfs/virtio-9p-device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down
Loading

0 comments on commit 2c30dd7

Please sign in to comment.