Fix for bug #4781: allow cleaning of /etc/mtab by canonicalizing mountpoint.
authorMichael Adam <obnox@samba.org>
Fri, 16 Nov 2007 21:26:26 +0000 (22:26 +0100)
committerMichael Adam <obnox@samba.org>
Fri, 16 Nov 2007 21:30:50 +0000 (22:30 +0100)
Canonicalize mountpoint by trimming trailing slashes before unmounting.
This allows for correct cleanup of /etc/mtab after unmounting.

Thanks to Steve Langasek <vorlon@debian.org>.

Michael

source/client/umount.cifs.c

index 3869e3439fce544ac8dc7177881e9fd3880b3de8..47ddd1e92eef8b80688c5975abcd8009fa32690a 100644 (file)
@@ -342,6 +342,13 @@ int main(int argc, char ** argv)
 
        /* fixup path if needed */
 
+       /* Trim any trailing slashes */
+       while ((strlen(mountpoint) > 1) &&
+               (mountpoint[strlen(mountpoint)-1] == '/'))
+       {
+               mountpoint[strlen(mountpoint)-1] = '\0';
+       }
+
        /* make sure that this is a cifs filesystem */
        rc = statfs(mountpoint, &statbuf);