diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 1999-02-17 18:03:48 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 1999-02-17 18:03:48 +0000 |
commit | 659730a173a6780111b95325c95a113297ad8dcc (patch) | |
tree | 2cf10f4f24648e447e880cb6a0aea08593c64a3d /sbin | |
parent | 3db44f2b81f64fb042024e8eaa04a8e5efba9589 (diff) |
try harder to match the mntonname with the name we are trying to unmount
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/umount/umount.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/sbin/umount/umount.c b/sbin/umount/umount.c index f3cfeb569ab..4852944efb8 100644 --- a/sbin/umount/umount.c +++ b/sbin/umount/umount.c @@ -1,4 +1,4 @@ -/* $OpenBSD: umount.c,v 1.5 1997/01/15 23:41:45 millert Exp $ */ +/* $OpenBSD: umount.c,v 1.6 1999/02/17 18:03:47 art Exp $ */ /* $NetBSD: umount.c,v 1.16 1996/05/11 14:13:55 mycroft Exp $ */ /*- @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)umount.c 8.3 (Berkeley) 2/20/94"; #else -static char rcsid[] = "$OpenBSD: umount.c,v 1.5 1997/01/15 23:41:45 millert Exp $"; +static char rcsid[] = "$OpenBSD: umount.c,v 1.6 1999/02/17 18:03:47 art Exp $"; #endif #endif /* not lint */ @@ -276,19 +276,30 @@ getmntname(name, what, type) { struct statfs *mntbuf; int i, mntsize; + char realonname[MAXPATHLEN], realfromname[MAXPATHLEN]; if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0) { warn("getmntinfo"); return (NULL); } for (i = 0; i < mntsize; i++) { - if ((what == MNTON) && !strcmp(mntbuf[i].f_mntfromname, name)) { + /* + * Translate the name in case the mount call wasn't done + * with a translated name. + * (but return the name as it is in the struct) + */ + if (realpath(mntbuf[i].f_mntfromname, realfromname) == NULL) + continue; + if (realpath(mntbuf[i].f_mntonname, realonname) == NULL) + continue; + + if ((what == MNTON) && !strcmp(realfromname, name)) { if (type) memcpy(type, mntbuf[i].f_fstypename, sizeof(mntbuf[i].f_fstypename)); return (mntbuf[i].f_mntonname); } - if ((what == MNTFROM) && !strcmp(mntbuf[i].f_mntonname, name)) { + if ((what == MNTFROM) && !strcmp(realonname, name)) { if (type) memcpy(type, mntbuf[i].f_fstypename, sizeof(mntbuf[i].f_fstypename)); |