Philip Guenther:

> > "umount -tnfs -a" does not unmount all NFS filesystems.
> ....
> At that point, I think ktrace would be your friend.

That doesn't provide any clue either.

I've figured it out, though.  The problem appears when you have a
local filesystem, e.g., /usr/ports, and then mount an NFS filesystem
on top.  Both are included in the list returned by getfsstat(2),
and while umount runs through the filesystems last to first, the
getmntname function it uses to normalize the filesystems traverses
the list the other way around.  As a result, /usr/ports nfs is
"normalized" to sd0i ffs.

Switching the processing order in getmntname() fixes the behavior.
Can anybody think of something that would be broken by this?

OK?

Index: umount.c
===================================================================
RCS file: /cvs/src/sbin/umount/umount.c,v
retrieving revision 1.23
diff -u -p -r1.23 umount.c
--- umount.c    21 Apr 2013 11:56:09 -0000      1.23
+++ umount.c    19 Jul 2013 17:02:55 -0000
@@ -259,7 +259,7 @@ getmntname(char *name, mntwhat what, cha
                warn("getmntinfo");
                return (NULL);
        }
-       for (i = 0; i < mntsize; i++) {
+       for (i = mntsize - 1; i >= 0; i--) {
                if ((what == MNTON) &&
                    (strncmp(mntbuf[i].f_mntfromname, name, MNAMELEN) == 0 ||
                     strncmp(mntbuf[i].f_mntfromspec, name, MNAMELEN) == 0)) {
-- 
Christian "naddy" Weisgerber                          na...@mips.inka.de

Reply via email to