diff options
author | Amar Tumballi <amarts@redhat.com> | 2017-07-19 23:08:05 +0530 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2017-08-04 05:26:42 +0000 |
commit | 590ae48c65a60c93c2e5407e3f663cef3daacc55 (patch) | |
tree | 82e948d6e48900878a9977aceef3535506d05207 /libglusterfs/src/options.c | |
parent | f68887999e89d894c3125e3b26517221ad1543fc (diff) |
glusterfsd: allow subdir mount
Changes:
1. Take subdir mount option in client (mount.gluster / glusterfsd)
2. Pass the subdir mount to server-handshake (from client-handshake)
3. Handle subdir-mount dir's lookup in server-first-lookup and handle
all fops resolution accordingly with proper gfid of subdir
4. Change the auth/addr module to handle the multiple subdir entries
in option, and valid parsing.
How to use the feature:
`# mount -t glusterfs $hostname:/$volname/$subdir /$mount_point`
Or
`# mount -t glusterfs $hostname:/$volname -osubdir_mount=$subdir /$mount_point`
Option can be set like:
`# gluster volume set <volname> auth.allow "/subdir1(192.168.1.*),/(192.168.10.*),/subdir2(192.168.8.*)"`
Updates #175
Change-Id: I7ea57f76ddbe6c3862cfe02e13f89e8a39719e11
Signed-off-by: Amar Tumballi <amarts@redhat.com>
Reviewed-on: https://review.gluster.org/17141
Smoke: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Diffstat (limited to 'libglusterfs/src/options.c')
-rw-r--r-- | libglusterfs/src/options.c | 62 |
1 files changed, 56 insertions, 6 deletions
diff --git a/libglusterfs/src/options.c b/libglusterfs/src/options.c index 3b1e21b5d0f..f0292eab5d4 100644 --- a/libglusterfs/src/options.c +++ b/libglusterfs/src/options.c @@ -599,21 +599,70 @@ xlator_option_validate_addr_list (xlator_t *xl, const char *key, char *dup_val = NULL; char *addr_tok = NULL; char *save_ptr = NULL; + char *entry = NULL; + char *entry_ptr = NULL; + char *dir_and_addr = NULL; + char *addr_ptr = NULL; + char *addr_list = NULL; + char *addr = NULL; + char *dir = NULL; char errstr[4096] = {0,}; dup_val = gf_strdup (value); if (!dup_val) goto out; - addr_tok = strtok_r (dup_val, ",", &save_ptr); - if (addr_tok == NULL) + if (dup_val[0] != '/' && !strchr (dup_val, '(')) { + /* Possible old format, handle it for back-ward compatibility */ + addr_tok = strtok_r (dup_val, ",", &save_ptr); + while (addr_tok) { + if (!valid_internet_address (addr_tok, _gf_true)) + goto out; + + addr_tok = strtok_r (NULL, ",", &save_ptr); + } + ret = 0; goto out; - while (addr_tok) { - if (!valid_internet_address (addr_tok, _gf_true)) + } + + /* Lets handle the value with new format */ + entry = strtok_r (dup_val, ",", &entry_ptr); + while (entry) { + dir_and_addr = gf_strdup (entry); + if (!dir_and_addr) goto out; - addr_tok = strtok_r (NULL, ",", &save_ptr); + dir = strtok_r (dir_and_addr, "(", &addr_ptr); + if (dir[0] != '/') { + /* Valid format should be starting from '/' */ + goto out; + } + /* dir = strtok_r (NULL, " =", &addr_tmp); */ + addr = strtok_r (NULL, ")", &addr_ptr); + if (!addr) + goto out; + + addr_list = gf_strdup (addr); + if (!addr_list) + goto out; + + /* This format be separated by '|' */ + addr_tok = strtok_r (addr_list, "|", &save_ptr); + if (addr_tok == NULL) + goto out; + while (addr_tok) { + if (!valid_internet_address (addr_tok, _gf_true)) + goto out; + + addr_tok = strtok_r (NULL, "|", &save_ptr); + } + entry = strtok_r (NULL, ",", &entry_ptr); + GF_FREE (dir_and_addr); + GF_FREE (addr_list); + addr_list = NULL; + dir_and_addr = NULL; } + ret = 0; out: @@ -626,7 +675,8 @@ out: *op_errstr = gf_strdup (errstr); } GF_FREE (dup_val); - + GF_FREE (dir_and_addr); + GF_FREE (addr_list); return ret; } |