提交 e103f9e7 编写于 作者: G Greg Kurz 提交者: Michael Roth

9pfs: remove side-effects in local_init()

If this function fails, it should not modify *ctx.
Signed-off-by: NGreg Kurz <groug@kaod.org>
Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
(cherry picked from commit 00c90bd1)
Signed-off-by: NGreg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
上级 2c4f0f6c
...@@ -1169,9 +1169,25 @@ static int local_ioc_getversion(FsContext *ctx, V9fsPath *path, ...@@ -1169,9 +1169,25 @@ static int local_ioc_getversion(FsContext *ctx, V9fsPath *path,
static int local_init(FsContext *ctx) static int local_init(FsContext *ctx)
{ {
int err = 0;
struct statfs stbuf; struct statfs stbuf;
#ifdef FS_IOC_GETVERSION
/*
* use ioc_getversion only if the ioctl is definied
*/
if (statfs(ctx->fs_root, &stbuf) < 0) {
return -1;
}
switch (stbuf.f_type) {
case EXT2_SUPER_MAGIC:
case BTRFS_SUPER_MAGIC:
case REISERFS_SUPER_MAGIC:
case XFS_SUPER_MAGIC:
ctx->exops.get_st_gen = local_ioc_getversion;
break;
}
#endif
if (ctx->export_flags & V9FS_SM_PASSTHROUGH) { if (ctx->export_flags & V9FS_SM_PASSTHROUGH) {
ctx->xops = passthrough_xattr_ops; ctx->xops = passthrough_xattr_ops;
} else if (ctx->export_flags & V9FS_SM_MAPPED) { } else if (ctx->export_flags & V9FS_SM_MAPPED) {
...@@ -1186,23 +1202,8 @@ static int local_init(FsContext *ctx) ...@@ -1186,23 +1202,8 @@ static int local_init(FsContext *ctx)
ctx->xops = passthrough_xattr_ops; ctx->xops = passthrough_xattr_ops;
} }
ctx->export_flags |= V9FS_PATHNAME_FSCONTEXT; ctx->export_flags |= V9FS_PATHNAME_FSCONTEXT;
#ifdef FS_IOC_GETVERSION
/* return 0;
* use ioc_getversion only if the iocl is definied
*/
err = statfs(ctx->fs_root, &stbuf);
if (!err) {
switch (stbuf.f_type) {
case EXT2_SUPER_MAGIC:
case BTRFS_SUPER_MAGIC:
case REISERFS_SUPER_MAGIC:
case XFS_SUPER_MAGIC:
ctx->exops.get_st_gen = local_ioc_getversion;
break;
}
}
#endif
return err;
} }
static int local_parse_opts(QemuOpts *opts, struct FsDriverEntry *fse) static int local_parse_opts(QemuOpts *opts, struct FsDriverEntry *fse)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册