diff options
author | Amar Tumballi <amar@kadalu.io> | 2021-02-22 23:36:53 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-22 23:36:53 +0530 |
commit | 14c578e9f3be7afbb5d088f0fe4921b67a969ea7 (patch) | |
tree | bc5d33866dfbd07f6f9bf23de1b63a3aba0d8325 /xlators | |
parent | 839e4796d2ea92a97001d1af34837467da4a05cd (diff) | |
download | glusterfs-14c578e9f3be7afbb5d088f0fe4921b67a969ea7.tar.gz glusterfs-14c578e9f3be7afbb5d088f0fe4921b67a969ea7.tar.xz glusterfs-14c578e9f3be7afbb5d088f0fe4921b67a969ea7.zip |
fuse: add an option to specify the mount display name (#1989)
* fuse: add an option to specify the mount display name
There are two things this PR is fixing.
1. When a mount is specified with volfile (-f) option, today, you can't make it out its from glusterfs as only volfile is added as 'fsname', so we add it as 'glusterfs:/<volname>'.
2. Provide an options for admins who wants to show the source of mount other than default (useful when one is not providing 'mount.glusterfs', but using their own scripts.
Updates: #1000
Change-Id: I19e78f309a33807dc5f1d1608a300d93c9996a2f
Signed-off-by: Amar Tumballi <amar@kadalu.io>
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/mount/fuse/src/fuse-bridge.c | 45 |
1 files changed, 16 insertions, 29 deletions
diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index 8e20712d2a..1a8befb8e4 100644 --- a/xlators/mount/fuse/src/fuse-bridge.c +++ b/xlators/mount/fuse/src/fuse-bridge.c @@ -6658,14 +6658,13 @@ init(xlator_t *this_xl) dict_t *options = NULL; char *value_string = NULL; cmd_args_t *cmd_args = NULL; - char *fsname = NULL; + char fsname[PATH_MAX] = ""; fuse_private_t *priv = NULL; struct stat stbuf = { 0, }; int i = 0; int xl_name_allocated = 0; - int fsname_allocated = 0; glusterfs_ctx_t *ctx = NULL; gf_boolean_t sync_to_mount = _gf_false; gf_boolean_t fopen_keep_cache = _gf_false; @@ -6908,31 +6907,23 @@ init(xlator_t *this_xl) priv->congestion_threshold = priv->background_qlen; } + /* What you need to find with we do 'df -h' */ cmd_args = &this_xl->ctx->cmd_args; - fsname = cmd_args->volfile; - if (!fsname && cmd_args->volfile_server) { - if (cmd_args->volfile_id) { - int dir_len = 0; - if (cmd_args->subdir_mount) - dir_len = strlen(cmd_args->subdir_mount) + 1; - fsname = GF_MALLOC(strlen(cmd_args->volfile_server) + 1 + - strlen(cmd_args->volfile_id) + 1 + dir_len, - gf_fuse_mt_fuse_private_t); - if (!fsname) { - gf_log("glusterfs-fuse", GF_LOG_ERROR, "Out of memory"); - goto cleanup_exit; - } - fsname_allocated = 1; - strcpy(fsname, cmd_args->volfile_server); - strcat(fsname, ":"); - strcat(fsname, cmd_args->volfile_id); - if (dir_len) - strcat(fsname, cmd_args->subdir_mount); - } else - fsname = cmd_args->volfile_server; + char *subdir = cmd_args->subdir_mount ? cmd_args->subdir_mount : ""; + if (cmd_args->fs_display_name) { + snprintf(fsname, PATH_MAX, "%s%s", cmd_args->fs_display_name, subdir); + } else { + if (cmd_args->volfile_server) { + snprintf(fsname, PATH_MAX, "%s:%s%s", cmd_args->volfile_server, + cmd_args->volfile_id, subdir); + } else { + /* Do we need file path ? */ + /* volfile-id is mandatory anyways, else we can also write file path + */ + snprintf(fsname, PATH_MAX, "glusterfs:%s%s", cmd_args->volfile_id, + subdir); + } } - if (!fsname) - fsname = "glusterfs"; priv->fdtable = gf_fd_fdtable_alloc(); if (priv->fdtable == NULL) { @@ -7014,16 +7005,12 @@ init(xlator_t *this_xl) priv->fuse_ops = fuse_dump_ops; } - if (fsname_allocated) - GF_FREE(fsname); GF_FREE(mnt_args); return 0; cleanup_exit: if (xl_name_allocated) GF_FREE(this_xl->name); - if (fsname_allocated) - GF_FREE(fsname); if (priv) { GF_FREE(priv->mount_point); if (priv->fd != -1) |