From nobody@FreeBSD.ORG Sun Aug  1 12:07:10 1999
Return-Path: <nobody@FreeBSD.ORG>
Received: by hub.freebsd.org (Postfix, from userid 32767)
	id 76D7D14BEB; Sun,  1 Aug 1999 12:07:10 -0700 (PDT)
Message-Id: <19990801190710.76D7D14BEB@hub.freebsd.org>
Date: Sun,  1 Aug 1999 12:07:10 -0700 (PDT)
From: blapp@attic.ch
Sender: nobody@FreeBSD.ORG
To: freebsd-gnats-submit@freebsd.org
Subject: NFS umounts are not properly done if just the mountpoint gets umounted
X-Send-Pr-Version: www-1.0

>Number:         12911
>Category:       bin
>Synopsis:       NFS umounts are not properly done if just the mountpoint gets umounted
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    alfred
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Aug  1 12:10:00 PDT 1999
>Closed-Date:    Sat Dec 18 15:41:02 PST 1999
>Last-Modified:  Sat Dec 18 15:41:13 PST 1999
>Originator:     Martin Blapp
>Release:        CURRENT 4.0, STABLE 3.2
>Organization:
Improware AG
>Environment:
FreeBSD fuchur.lan.attic.ch 4.0-CURRENT FreeBSD 4.0-CURRENT #0: Sun Aug  1 15:54:19 CEST 1999     root@fuchur.lan.attic.ch:/usr/src/sys/compile/FUCHUR  i386
(also verified on 3.2-STABLE/i586)

>Description:
If you umount a nfs-mountpoint, the server will not get an
authentificated umount request. If you unmount it with the full
path it works. With Linux 2.2 and Irix 6.5.2 as clients both
'umount /mountpoint' and 'umount somehost:/somedir' work.
>How-To-Repeat:
Client:

# mount somehost:/somedir /mountpoint
# umount /mountpoint

Server:

# showmount 
>Fix:
workaround (no fix !):

# umount somehost:/somedir

>Release-Note:
>Audit-Trail:

From: Martin Blapp <mblapp@solnet.ch>
To: freebsd-gnats-submit@freebsd.org, blapp@attic.ch
Cc:  
Subject: Re: kern/12911: NFS umounts are not properly done if just the mountpoint 
 gets umounted
Date: Sun, 01 Aug 1999 21:31:17 +0000

 Sorry - should be changed to bin/12911
 
 Martin
 
Responsible-Changed-From-To: freebsd-bugs->billf 
Responsible-Changed-By: billf 
Responsible-Changed-When: Sun Aug 8 17:17:21 PDT 1999 
Responsible-Changed-Why:  
The submitter sent me a patch, I am testing it. 

From: Martin Blapp <mblapp@solnet.ch>
To: freebsd-gnats-submit@freebsd.org, blapp@attic.ch
Cc: billf@freebsd.org
Subject: Re: bin/12911: NFS umounts are not properly done if just the mountpoint 
 gets umounted
Date: Mon, 09 Aug 1999 00:22:57 +0000

 This should fix the problem with /usr/src/sbin/umount/umount.c :
 
 --- umount.c    Mon Aug  3 08:44:46 1998
 +++ umount.c    Mon Aug  9 02:00:10 1999
 @@ -209,6 +209,8 @@
         struct sockaddr_in saddr;
         struct stat sb;
         struct timeval pertry, try;
 +       char *mntfromname;
 +
         CLIENT *clp;
         int so;
         char *type, *delimp, *hostp, *mntpt, *origname,
 rname[MAXPATHLEN];
 @@ -259,6 +261,16 @@
                         hp = gethostbyname(hostp);
                         name = delimp + 1;
                         *delimp = ':';
 +               } else {
 +                       mntfromname = (getmntname(rname, MNTFROM,
 &type));
 +                       name = mntfromname;
 +                       if ((delimp = strchr(name, ':')) != NULL) {
 +                               *delimp = '\0';
 +                               hostp = name;
 +                               hp = gethostbyname(hostp);
 +                               name = delimp + 1;
 +                               *delimp = ':';
 +                       }
                 }
         }
 

From: Martin Blapp <mblapp@solnet.ch>
To: freebsd-gnats-submit@freebsd.org, blapp@attic.ch
Cc: billf@freebsd.org
Subject: Re: bin/12911: NFS umounts are not properly done if just the mountpoint 
 gets umounted
Date: Mon, 09 Aug 1999 20:35:41 +0000

 I reviewed my patch and recognized that nfs-unmounts within '@' were
 still not fixed by my patch. I found and fixed other problems in
 umount.c :
 
 - getmntname() was not the right way recursive, so always the first
   mount on the same mountpoint was umounted. (fixed)
 - umount -v had also problems with this, because it depends from
   getmntname(). (fixed)
 - umount -v had problems with order of mount_union. (fixed)
 - umount -v had problems with order of mount_nfs. (fixed)
 - nfs-unmounts from mounts with an '@' still had problems if
   only the mntpnt got umounted. (fixed)
 
 tnx for testing billf ;-)
 
 -------------------------------------------------------------------
 
 --- umount.c.orig       Mon Aug  9 17:20:13 1999
 +++ umount.c    Mon Aug  9 21:32:45 1999
 @@ -211,29 +211,31 @@
         struct timeval pertry, try;
         CLIENT *clp;
         int so;
 -       char *type, *delimp, *hostp, *mntpt, *origname,
 rname[MAXPATHLEN];
 +       char *type, *delimp, *hostp, *mntpt, *mnton, *mntfrom,
 rname[MAXPATHLEN];
 
         if (realpath(name, rname) == NULL) {
                 /* Continue and let the system call check it... */
                 strcpy(rname, name);
         }
 
 -       origname = name;
 +       mntfrom = getmntname(rname, MNTFROM, &type);
 +       mnton = getmntname(name, MNTON, &type);
 +
         if (stat(name, &sb) < 0) {
                 mntpt = rname;
 -               if ((getmntname(rname, MNTFROM, &type) == NULL) &&
 -                   ((mntpt = getmntname(name, MNTON, &type)) == NULL))
 {
 +               if ((mntfrom == NULL) &&
 +                   ((mntpt = mnton) == NULL)) {
                         warnx("%s: not currently mounted", name);
                         return (1);
                 }
         } else if (S_ISBLK(sb.st_mode)) {
 -               if ((mntpt = getmntname(name, MNTON, &type)) == NULL) {
 +               if ((mntpt = mnton) == NULL) {
                         warnx("%s: not currently mounted", name);
                         return (1); 
                 }
         } else if (S_ISDIR(sb.st_mode)) {
                 mntpt = rname;
 -               if (getmntname(mntpt, MNTFROM, &type) == NULL) {
 +               if (mntfrom == NULL) {
                         warnx("%s: not currently mounted", name);
                         return (1);
                 }
 @@ -248,6 +250,12 @@
 
         hp = NULL;
         if (!strcmp(type, "nfs")) {
 +
 +               /* We need this if we get nothing but mntpt as argument
 */
 +               if ((delimp = strpbrk(mntfrom, "@:")) != NULL) {
 +                       name = mntfrom;
 +               }
 +
                 if ((delimp = strchr(name, '@')) != NULL) {
                         hostp = delimp + 1;
                         *delimp = '\0';
 @@ -262,11 +270,18 @@
                 }
         }
 
 +
 +       /* make umount -v happy */
 +       if (mntfrom == NULL) {
 +               mntfrom = name;
 +       }
 +
         if (!namematch(hp))
                 return (1);
 
 -       if (vflag)
 -               (void)printf("%s: unmount from %s\n", origname, mntpt);
 +       if (vflag)
 +               (void)printf("%s: unmount from %s\n", mntfrom, mntpt);
 +
         if (fake)
                 return (0);
 
 @@ -320,7 +335,7 @@
                 warn("getmntinfo");
                 return (NULL);
         }
 -       for (i = 0; i < mntsize; i++) {
 +       for (i = mntsize; i > 0; i--) {
                 if ((what == MNTON) && !strcmp(mntbuf[i].f_mntfromname,
 name)) {
                         if (type)
                                 *type = mntbuf[i].f_fstypename;
 

From: Doug <Doug@gorean.org>
To: blapp@attic.ch
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: kern/12911: NFS umounts are not properly done if just the mountpoint 
 gets umounted
Date: Sat, 21 Aug 1999 18:19:04 -0700

 blapp@attic.ch wrote:
 
 > >Description:
 > If you umount a nfs-mountpoint, the server will not get an
 > authentificated umount request. If you unmount it with the full
 > path it works. With Linux 2.2 and Irix 6.5.2 as clients both
 > 'umount /mountpoint' and 'umount somehost:/somedir' work.
 > >How-To-Repeat:
 > Client:
 > 
 > # mount somehost:/somedir /mountpoint
 > # umount /mountpoint
 
 	I want to add a "me too" on this point in hopes that it another data point
 helps. 
 
 Doug
 
Responsible-Changed-From-To: billf->alfred 
Responsible-Changed-By: billf 
Responsible-Changed-When: Sat Sep 4 16:54:18 PDT 1999 
Responsible-Changed-Why:  
Alfred has been working with Martin. 
State-Changed-From-To: open->closed 
State-Changed-By: green 
State-Changed-When: Sat Dec 18 15:41:02 PST 1999 
State-Changed-Why:  
This has been fixed in -CURRENT and 3.3/3.4. 

>Unformatted:
