Bug 13692 - umount(8) does not unmount filesystems with a trailing slash
Summary: umount(8) does not unmount filesystems with a trailing slash
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 2.2.8-STABLE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 1999-09-11 04:30 UTC by Harold Gutch
Modified: 1999-12-18 23:36 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Harold Gutch 1999-09-11 04:30:01 UTC
	umount(8) will not unmount a filesystem if
	a) you supply the directory-name instead of the devicenode (or
	    host:directory-combination when using NFS) as an argument
	and b) the directory on which the filesystem is mounted (member
	    f_mntonname of the struct statfs) has a trailing slash

Fix: Apply this patch:



if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0) {
 		warn("getmntinfo");
+		free(longname);
 		return (NULL);
 	}
 	for (i = 0; i < mntsize; i++) {
 		if ((what == MNTON) && !strcmp(mntbuf[i].f_mntfromname, name)) {
 			if (type)
 				*type = mntbuf[i].f_type;
+			free(longname);
 			return (mntbuf[i].f_mntonname);
 		}
-		if ((what == MNTFROM) && !strcmp(mntbuf[i].f_mntonname, name)) {
+		if (((what == MNTFROM) && (!strcmp(mntbuf[i].f_mntonname, name))
+		    || (!strcmp(mntbuf[i].f_mntonname, longname)))) {
 			if (type)
 				*type = mntbuf[i].f_type;
+			free(longname);
 			return (mntbuf[i].f_mntfromname);
 		}
 	}
+	free(longname);
 	return (NULL);
 }


Alternatively mount_msdos, mount_cd9660 etc. need to be fixed to remove
trailing slashes.--7XjIAXa8be2EFYonGxMxJiZ1tPXUSy5gpsxcRYIRl3AQfgk3
Content-Type: text/plain; name="file.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="file.diff"

--- umount.c.sav	Thu Dec  4 08:36:22 1997
+++ umount.c	Sat Sep 11 05:29:27 1999
@@ -282,23 +282,34 @@
 {
 	struct statfs *mntbuf;
 	int i, mntsize;
+	char *longname;
+
+	if (NULL == (longname = malloc(strlen(name) + 2)))
+		err(1, NULL);
+	strcpy(longname, name);
+	strcat(longname, "/");
How-To-Repeat: 
	# mount_nfs remotehost:/remote/dir /local/dir/
	# mount -t nfs
	remotehost:/remote/dir on /local/dir/
	# umount /local/dir/
	umount: /local/dir: not currently mounted
	# umount /local/dir
	umount: /local/dir: not currently mounted
	# umount remotehost:/remote/dir
	# mount -t nfs
	#

	Note: You will need to call mount_nfs, mount_cd9660, mount_msdos etc.
	directly, as mount(8) catches this and removes the trailing slash.
Comment 1 mblapp 1999-09-12 00:55:44 UTC
Hi Logix,

Try this patch. Most of it will be commited to FreeBSD-
Current soon. All your problems should be solved then:

http://www.freebsd.org/~alfred/mount.diff

Cheers, Martin
Comment 2 Brian Feldman freebsd_committer freebsd_triage 1999-12-18 23:36:20 UTC
State Changed
From-To: open->closed

This has been fixed in -CURRENT and 3.3/3.4.