diff options
-rw-r--r-- | tests/bugs/nfs/subdir-trailing-slash.t | 31 | ||||
-rw-r--r-- | xlators/nfs/server/src/mount3.c | 5 |
2 files changed, 36 insertions, 0 deletions
diff --git a/tests/bugs/nfs/subdir-trailing-slash.t b/tests/bugs/nfs/subdir-trailing-slash.t new file mode 100644 index 00000000000..a00959443d0 --- /dev/null +++ b/tests/bugs/nfs/subdir-trailing-slash.t @@ -0,0 +1,31 @@ +#!/bin/bash +# +# Verify that mounting a subdir over NFS works, even with a trailing / +# +# For example: +# mount -t nfs server.example.com:/volume/subdir/ +# + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc +. $(dirname $0)/../../nfs.rc + + +cleanup; +TEST glusterd +TEST pidof glusterd + +TEST $CLI volume create $V0 $H0:$B0/$V0 +TEST $CLI volume set $V0 nfs.disable false + +TEST $CLI volume start $V0 +EXPECT_WITHIN $NFS_EXPORT_TIMEOUT "1" is_nfs_export_available + +TEST mount_nfs $H0:/$V0 $N0 nolock +TEST mkdir -p $N0/subdir +EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $N0 + +TEST mount_nfs $H0:/$V0/subdir/ $N0 nolock +EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $N0 + +cleanup diff --git a/xlators/nfs/server/src/mount3.c b/xlators/nfs/server/src/mount3.c index 7b49d097d96..cb8b9a1af2f 100644 --- a/xlators/nfs/server/src/mount3.c +++ b/xlators/nfs/server/src/mount3.c @@ -1524,6 +1524,7 @@ mnt3_resolve_subdir (rpcsvc_request_t *req, struct mount3_state *ms, int ret = -EFAULT; struct nfs3_fh pfh = GF_NFS3FH_STATIC_INITIALIZER; struct sockaddr_in *sin = NULL; + int len = -1; if ((!req) || (!ms) || (!exp) || (!subdir)) return ret; @@ -1551,7 +1552,10 @@ mnt3_resolve_subdir (rpcsvc_request_t *req, struct mount3_state *ms, mres->exp = exp; mres->mstate = ms; mres->req = req; + strncpy (mres->remainingdir, subdir, MNTPATHLEN); + gf_path_strip_trailing_slashes (mres->remainingdir); + if (gf_nfs_dvm_off (nfs_state (ms->nfsx))) pfh = nfs3_fh_build_indexed_root_fh ( mres->mstate->nfsx->children, @@ -2493,6 +2497,7 @@ mnt3svc_umnt (rpcsvc_request_t *req) if (colon) { *colon= '\0'; } + gf_path_strip_trailing_slashes (dirpath); gf_msg_debug (GF_MNT, 0, "dirpath: %s, hostname: %s", dirpath, hostname); ret = mnt3svc_umount (ms, dirpath, hostname); |