diff options
-rw-r--r-- | glusterfsd/src/glusterfsd.c | 9 | ||||
-rw-r--r-- | libglusterfs/src/graph.c | 25 | ||||
-rw-r--r-- | xlators/mount/fuse/src/fuse-bridge.c | 31 | ||||
-rw-r--r-- | xlators/mount/fuse/src/fuse-bridge.h | 1 |
4 files changed, 29 insertions, 37 deletions
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c index d02c4b7a9..244307d08 100644 --- a/glusterfsd/src/glusterfsd.c +++ b/glusterfsd/src/glusterfsd.c @@ -322,6 +322,15 @@ create_fuse_mount (glusterfs_ctx_t *ctx) } } + if (cmd_args->read_only) { + ret = dict_set_static_ptr (master->options, "read-only", "on"); + if (ret < 0) { + gf_log ("glusterfsd", GF_LOG_ERROR, + "failed to set dict value for key read-only"); + goto err; + } + } + switch (cmd_args->fuse_direct_io_mode) { case GF_OPTION_DISABLE: /* disable */ ret = dict_set_static_ptr (master->options, ZR_DIRECT_IO_OPT, diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c index 7844a5475..830c88363 100644 --- a/libglusterfs/src/graph.c +++ b/libglusterfs/src/graph.c @@ -175,24 +175,6 @@ err: return -1; } - -int -glusterfs_graph_readonly (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx) -{ - int ret = 0; - cmd_args_t *cmd_args = NULL; - - cmd_args = &ctx->cmd_args; - - if (!cmd_args->read_only) - return 0; - - ret = glusterfs_graph_insert (graph, ctx, "features/read-only", - "readonly-autoload"); - return ret; -} - - int glusterfs_graph_acl (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx) { @@ -453,13 +435,6 @@ glusterfs_graph_prepare (glusterfs_graph_t *graph, glusterfs_ctx_t *ctx) return -1; } - /* XXX: RO VOLUME */ - ret = glusterfs_graph_readonly (graph, ctx); - if (ret) { - gf_log ("graph", GF_LOG_ERROR, "glusterfs graph readonly failed"); - return -1; - } - /* XXX: WORM VOLUME */ ret = glusterfs_graph_worm (graph, ctx); if (ret) { diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index 62726b38f..3e271ff69 100644 --- a/xlators/mount/fuse/src/fuse-bridge.c +++ b/xlators/mount/fuse/src/fuse-bridge.c @@ -3560,6 +3560,7 @@ init (xlator_t *this_xl) int fsname_allocated = 0; glusterfs_ctx_t *ctx = NULL; gf_boolean_t sync_mtab = _gf_false; + char *mnt_args = NULL; if (this_xl == NULL) return -1; @@ -3680,6 +3681,12 @@ init (xlator_t *this_xl) if (priv->uid_map_root) priv->acl = 1; + priv->read_only = 0; + ret = dict_get_str (options, "read-only", &value_string); + if (ret == 0) { + ret = gf_string2boolean (value_string, &priv->read_only); + GF_ASSERT (ret == 0); + } priv->fuse_dump_fd = -1; ret = dict_get_str (options, "dump-fuse", &value_string); @@ -3729,19 +3736,14 @@ init (xlator_t *this_xl) if (!fsname) fsname = "glusterfs"; + gf_asprintf (&mnt_args, "%s%sallow_other,max_read=131072", + priv->read_only ? "ro," : "", + priv->acl ? "" : "default_permissions,"); + if (!mnt_args) + goto cleanup_exit; - if (priv->acl) { - priv->fd = gf_fuse_mount (priv->mount_point, fsname, - "allow_other," - "max_read=131072", - sync_mtab ? &ctx->mtab_pid : NULL); - } else { - priv->fd = gf_fuse_mount (priv->mount_point, fsname, - "allow_other,default_permissions," - "max_read=131072", - sync_mtab ? &ctx->mtab_pid : NULL); - } - + priv->fd = gf_fuse_mount (priv->mount_point, fsname, mnt_args, + sync_mtab ? &ctx->mtab_pid : NULL); if (priv->fd == -1) goto cleanup_exit; @@ -3775,6 +3777,8 @@ cleanup_exit: close (priv->fuse_dump_fd); GF_FREE (priv); } + if (mnt_args) + GF_FREE (mnt_args); return -1; } @@ -3844,5 +3848,8 @@ struct volume_options options[] = { { .key = {"sync-mtab"}, .type = GF_OPTION_TYPE_BOOL }, + { .key = {"read-only"}, + .type = GF_OPTION_TYPE_BOOL + }, { .key = {NULL} }, }; diff --git a/xlators/mount/fuse/src/fuse-bridge.h b/xlators/mount/fuse/src/fuse-bridge.h index 2215ad22f..2b8323a8c 100644 --- a/xlators/mount/fuse/src/fuse-bridge.h +++ b/xlators/mount/fuse/src/fuse-bridge.h @@ -108,6 +108,7 @@ struct fuse_private { gf_boolean_t client_pid_set; unsigned uid_map_root; gf_boolean_t acl; + gf_boolean_t read_only; }; typedef struct fuse_private fuse_private_t; |