Date: Sun, 28 Jul 1996 08:07:11 +0200 (MET DST) From: "Martin v.Loewis" <loewis@cs.tu-berlin.de> To: freebsd-fs@freebsd.org Subject: umount question Message-ID: <199607280607.IAA17525@cent.cs.tu-berlin.de>
next in thread | raw e-mail | index | archive | help
I have a question on umount(8). Why does it sometimes pass the mounted-from device to unmount(2)? For your reference, I have some code from /usr/src/sbin/umount/umount.c of FreeBSD 2.1.0. In umountfs, the umount parameter is checked: if (stat(name, &sb) < 0) { if (((mntpt = getmntname(name, MNTFROM, &type)) == NULL) && ((mntpt = getmntname(name, MNTON, &type)) == NULL)) { warnx("%s: not currently mounted", name); getmntname in turn checks on name and returns the other: if ((what == MNTON) && !strcmp(mntbuf[i].f_mntfromname, name)) { if (type) *type = mntbuf[i].f_type; return (mntbuf[i].f_mntonname); } if ((what == MNTFROM) && !strcmp(mntbuf[i].f_mntonname, name)) { if (type) *type = mntbuf[i].f_type; return (mntbuf[i].f_mntfromname); } In my case, /dev/wd0s2 was mounted on /mnt, and I invoked 'umount /mnt'. The root vnode of the file system did not support stat(2), so umount ran through the mntlist and found it to a mntonname. As a result, it later invoked unmount(2) with "/dev/wd0s2". unmount now verified whether this is a VROOT vnode, and failed. In the NFS case, I can see why it is important make mntonnames out of mntfromnames, in case somebody invokes "umount remote:/path" (stat will fail here as well). However, I can see no reason to ever pass the mntfromname to unmount. Any comments? Thanks, Martin P.S. I know that the solution is to support stat and lstat in the root vnode. I'm writing this because I actually had to debug umount to see why it fails.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199607280607.IAA17525>