提交 d068535c 编写于 作者: L Liu Bo 提交者: Caspar Zhang

alinux: virtiofs: simplify mount options

task #28910367
Rather than explicitly specifying "-o
default_permissions,allow_other", virtiofs can set some default values
for them.

With this, we can simply do
"mount -t virtio_fs atest /mnt/test/ -otag=myfs-1,dax".
Signed-off-by: NLiu Bo <bo.liu@linux.alibaba.com>
Reviewed-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
上级 e6067150
...@@ -1002,7 +1002,7 @@ void fuse_dev_free(struct fuse_dev *fud); ...@@ -1002,7 +1002,7 @@ void fuse_dev_free(struct fuse_dev *fud);
* Parse a mount options string * Parse a mount options string
*/ */
int parse_fuse_opt(char *opt, struct fuse_mount_data *d, int is_bdev, int parse_fuse_opt(char *opt, struct fuse_mount_data *d, int is_bdev,
struct user_namespace *user_ns); struct user_namespace *user_ns, int is_virtiofs);
/** /**
* Fill in superblock and initialize fuse connection * Fill in superblock and initialize fuse connection
......
...@@ -468,13 +468,19 @@ static int fuse_match_uint(substring_t *s, unsigned int *res) ...@@ -468,13 +468,19 @@ static int fuse_match_uint(substring_t *s, unsigned int *res)
} }
int parse_fuse_opt(char *opt, struct fuse_mount_data *d, int is_bdev, int parse_fuse_opt(char *opt, struct fuse_mount_data *d, int is_bdev,
struct user_namespace *user_ns) struct user_namespace *user_ns, int is_virtiofs)
{ {
char *p; char *p;
memset(d, 0, sizeof(struct fuse_mount_data)); memset(d, 0, sizeof(struct fuse_mount_data));
d->max_read = ~0; d->max_read = ~0;
d->blksize = FUSE_DEFAULT_BLKSIZE; d->blksize = FUSE_DEFAULT_BLKSIZE;
if (is_virtiofs) {
d->rootmode = S_IFDIR;
d->default_permissions = 1;
d->allow_other = 1;
}
while ((p = strsep(&opt, ",")) != NULL) { while ((p = strsep(&opt, ",")) != NULL) {
int token; int token;
int value; int value;
...@@ -549,6 +555,10 @@ int parse_fuse_opt(char *opt, struct fuse_mount_data *d, int is_bdev, ...@@ -549,6 +555,10 @@ int parse_fuse_opt(char *opt, struct fuse_mount_data *d, int is_bdev,
} }
} }
/* no need to check rootmode/user_id/group_id for virtiofs */
if (is_virtiofs)
return 1;
if (!d->rootmode_present || !d->user_id_present || if (!d->rootmode_present || !d->user_id_present ||
!d->group_id_present) !d->group_id_present)
return 0; return 0;
...@@ -1201,7 +1211,7 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent) ...@@ -1201,7 +1211,7 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
struct fuse_req *init_req; struct fuse_req *init_req;
err = -EINVAL; err = -EINVAL;
if (!parse_fuse_opt(data, &d, is_bdev, sb->s_user_ns)) if (!parse_fuse_opt(data, &d, is_bdev, sb->s_user_ns, false))
goto err; goto err;
if (!d.fd_present) if (!d.fd_present)
goto err; goto err;
......
...@@ -1035,7 +1035,7 @@ static int virtio_fs_fill_super(struct super_block *sb, void *data, ...@@ -1035,7 +1035,7 @@ static int virtio_fs_fill_super(struct super_block *sb, void *data,
mutex_lock(&virtio_fs_mutex); mutex_lock(&virtio_fs_mutex);
err = -EINVAL; err = -EINVAL;
if (!parse_fuse_opt(data, &d, is_bdev, sb->s_user_ns)) if (!parse_fuse_opt(data, &d, is_bdev, sb->s_user_ns, true))
goto err; goto err;
if (d.fd_present) { if (d.fd_present) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册