When we write a mount entry on Linux when mounting /afs, trim trailing
slashes on the mount path. Otherwise, the umount utility can get
slightly confused, and leave the /afs mount entry in /etc/mtab after
it's been unmounted.
For full correctness we should probably completely canonicalize the
path like the mount utility does, but it's unlikely that anyone will
provide significantly weird paths for cacheMountDir, so don't bother.
Reviewed-on: http://gerrit.openafs.org/4442
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
(cherry picked from commit
325443e6178f9dcdba7326bdb675447ac72bd540)
Change-Id: I9832fad8a43278c5eb618e4148c71f8a9ef81e87
Reviewed-on: http://gerrit.openafs.org/6283
Tested-by: Derrick Brashear <shadow@dementix.org>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
#else
#if defined(AFS_SGI_ENV) || defined(AFS_LINUX20_ENV)
struct mntent tmntent;
+ char *dir = strdup(cacheMountDir);
+ int i;
+
+ /* trim trailing slashes; don't look at dir[0] in case we are somehow
+ * just "/" */
+ for (i = strlen(dir)-1; i > 0; i--) {
+ if (dir[i] == '/') {
+ dir[i] = '\0';
+ } else {
+ break;
+ }
+ }
tfilep = setmntent("/etc/mtab", "a+");
tmntent.mnt_fsname = "AFS";
- tmntent.mnt_dir = cacheMountDir;
+ tmntent.mnt_dir = dir;
tmntent.mnt_type = "afs";
tmntent.mnt_opts = "rw";
tmntent.mnt_freq = 1;
tmntent.mnt_passno = 3;
addmntent(tfilep, &tmntent);
endmntent(tfilep);
+
+ free(dir);
+ dir = NULL;
#else
struct mntent tmntent;