Subject: bin/3615: umount change to allow relative path unmounting
To: None <gnats-bugs@gnats.netbsd.org>
From: None <nimenees@par0163.urh.uiuc.edu>
List: netbsd-bugs
Date: 05/13/1997 17:32:39
>Number:         3615
>Category:       bin
>Synopsis:       umount can't unmount mount points that are not absolute pathnames
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue May 13 15:35:01 1997
>Last-Modified:
>Originator:     Eric Haszlakiewicz
>Organization:
>Release:        1.2E
>Environment:
	Pentium, NetBSD-current (5/12/97)
System: NetBSD par0163.urh.uiuc.edu 1.2E NetBSD 1.2E (REALMS) #59: Thu May 8 13:39:27 CDT 1997 root@par0163.urh.uiuc.edu:/usr/src/sys/arch/i386/compile/REALMS i386


>Description:
	umount currently always takes the path you give it and converts it
to an absolute path w/realpath.  This causes the unmount to fail  if someone
happened to mount something using a relative path.
>How-To-Repeat:
	As in PR 3612:  mount_<fs> <dev> <relative path>
			umount <relative path>
			umount: <absolute path>: not currently mounted
>Fix:
	This fix makes umount not use the resolved path unless the relative
path doesn't work.  Relative path works only if you're in the same directory
you mounted from.

*** umount.c.old        Mon May 12 20:44:45 1997
--- umount.c    Tue May 13 17:09:38 1997
*************** umountfs(name)
*** 183,189 ****
                return (1);
        }
  
!       mntpt = name = rname;
  
        if (stat(name, &sb) < 0) {
                if ((name = getmntname(mntpt, MNTFROM, type)) == NULL) {
--- 183,189 ----
                return (1);
        }
  
!       mntpt = name;
  
        if (stat(name, &sb) < 0) {
                if ((name = getmntname(mntpt, MNTFROM, type)) == NULL) {
*************** umountfs(name)
*** 195,212 ****
--- 195,219 ----
                }
        } else if (S_ISBLK(sb.st_mode)) {
                if ((mntpt = getmntname(name, MNTON, type)) == NULL) {
+                   name = rname;       /* Try the resolved name */
+                   if ((mntpt = getmntname(name, MNTON, type)) == NULL) {
                        warnx("%s: not currently mounted", name);
                        return (1);
+                   }
                }
        } else if (S_ISDIR(sb.st_mode)) {
                if ((name = getmntname(mntpt, MNTFROM, type)) == NULL) {
+                   mntpt = rname;      /* Try the resolved name */
+                   if ((name = getmntname(mntpt, MNTFROM, type)) == NULL) {
                        warnx("%s: not currently mounted", mntpt);
                        return (1);
+                   }
                }
        } else {
                warnx("%s: not a directory or special device", name);
                return (1);
        }
+ 
  
        if (!selected(type))
                return (1);

>Audit-Trail:
>Unformatted: