From logix@foobar.franken.de Fri Sep 10 20:28:43 1999
Return-Path: <logix@foobar.franken.de>
Received: from foobar.franken.de (foobar.franken.de [194.94.249.81])
	by hub.freebsd.org (Postfix) with ESMTP id 96B33152F7
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 10 Sep 1999 20:28:37 -0700 (PDT)
	(envelope-from logix@foobar.franken.de)
Received: (from logix@localhost)
	by foobar.franken.de (8.8.8/8.8.5) id FAA04567;
	Sat, 11 Sep 1999 05:25:56 +0200 (CEST)
Message-Id: <199909110325.FAA04567@foobar.franken.de>
Date: Sat, 11 Sep 1999 05:25:56 +0200 (CEST)
From: Harold Gutch <logix@foobar.franken.de>
Reply-To: logix@foobar.franken.de
To: FreeBSD-gnats-submit@freebsd.org
Subject: umount(8) does not unmount filesystems with a trailing slash
X-Send-Pr-Version: 3.2

>Number:         13692
>Category:       bin
>Synopsis:       umount(8) does not unmount filesystems with a trailing slash
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Sep 10 20:30:01 PDT 1999
>Closed-Date:    Sat Dec 18 15:36:20 PST 1999
>Last-Modified:  Sat Dec 18 15:36:49 PST 1999
>Originator:     Harold Gutch
>Release:        FreeBSD 2.2.8-STABLE i386
>Organization:
>Environment:

	FreeBSD 2.2.8, the bug persists in 3.x as well

>Description:

	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

>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.

>Fix:
	
	Apply this patch:

--- 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, "/");

 	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.

>Release-Note:
>Audit-Trail:

From: Martin Blapp <mblapp@solnet.ch>
To: freebsd-gnats-submit@freebsd.org, logix@foobar.franken.de
Cc:  
Subject: Re: bin/13692: umount(8) does not unmount filesystems with a trailing 
 slash
Date: Sat, 11 Sep 1999 23:55:44 +0000

 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
 
State-Changed-From-To: open->closed 
State-Changed-By: green 
State-Changed-When: Sat Dec 18 15:36:20 PST 1999 
State-Changed-Why:  
This has been fixed in -CURRENT and 3.3/3.4. 

>Unformatted:
