Subject: bin/441: mount can mount something umount can't unmount
To: None <gnats-admin>
From: der Mouse <mouse@Collatz.McRCIM.McGill.EDU>
List: netbsd-bugs
Date: 08/29/1994 08:20:14
>Number:         441
>Category:       bin
>Synopsis:       mount can mount something umount can't unmount
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    gnats-admin (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Aug 29 08:20:09 1994
>Originator:     der Mouse
>Organization:
	Organization?  Me??  Surely you jest.
>Release:        NetBSD/sparc 1.0-beta
>Environment:
	SPARC IPC, not that it matters
>Description:
	/sbin/mount is willing to mount anything on top of a directory
	(or rather, mount_null and probably others are), but
	/sbin/umount refuses to attempt an unmount unless a directory
	(or a block special device) is given.  If the thing mounted
	doesn't stat() as a directory, it's impossible to unmount it.
>How-To-Repeat:
	echo foo > /tmp/foo  # create a plain file
	mkdir /tmp/bar       # create a place to mount it
	mount -t null -o ro /tmp/foo /tmp/bar  # NULLFS needed in your kernel
	ls -l /tmp/bar       # looks like a plain file, as it should
	umount /tmp/bar      # notice umount gets upset
>Fix:
	Uncertain.  The following patch makes umount willing to unmount
	such things, but I assume the check was put in there for a
	reason, so I'm hesitant to recommend this without knowing what
	that reason is.  Notice that even with this patch, it's still
	possible to get into a bind if the thing mounted stat()s as a
	block special device, because then mount will try to find where
	it's mounted, not what's mounted on it.  Perhaps an option
	should be added to make umount pass the given string directly
	to the unmount syscall, without attempting any sort of smarts,
	to make it possible to deal with this and other potentially
	difficult cases (like mount points containing : or @)?

	*** /sources/supped/netbsd/src/sbin/umount/umount.c	Wed Aug 24 17:31:27 1994
	--- umount.c	Mon Aug 29 10:57:19 1994
	***************
	*** 202,208 ****
	  			warnx("%s: not currently mounted", name);
	  			return (1);
	  		}
	! 	} else if (S_ISDIR(sb.st_mode)) {
	  		mntpt = name;
	  		if ((name = getmntname(mntpt, MNTFROM, type)) == NULL) {
	  			warnx("%s: not currently mounted", mntpt);
	--- 202,208 ----	
	  			warnx("%s: not currently mounted", name);
	  			return (1);
	  		}
	! 	} else if (/*S_ISDIR(sb.st_mode)*/1) {
	  		mntpt = name;
	  		if ((name = getmntname(mntpt, MNTFROM, type)) == NULL) {
	  			warnx("%s: not currently mounted", mntpt);

					der Mouse

			    mouse@collatz.mcrcim.mcgill.edu
>Audit-Trail:
>Unformatted:


------------------------------------------------------------------------------