From owner-freebsd-fs Sat Jul 27 23:07:48 1996 Return-Path: owner-fs Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id XAA00992 for fs-outgoing; Sat, 27 Jul 1996 23:07:48 -0700 (PDT) Received: from mail.cs.tu-berlin.de (mail.cs.tu-berlin.de [130.149.17.13]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id XAA00987 for ; Sat, 27 Jul 1996 23:07:46 -0700 (PDT) Received: from cent.cs.tu-berlin.de (loewis@cent.cs.tu-berlin.de [130.149.22.20]) by mail.cs.tu-berlin.de (8.6.12/8.6.12) with ESMTP id IAA01903 for ; Sun, 28 Jul 1996 08:07:13 +0200 From: "Martin v.Loewis" Received: (loewis@localhost) by cent.cs.tu-berlin.de (8.6.12/8.6.6) id IAA17525 for freebsd-fs@freebsd.org; Sun, 28 Jul 1996 08:07:12 +0200 Message-Id: <199607280607.IAA17525@cent.cs.tu-berlin.de> Subject: umount question To: freebsd-fs@freebsd.org Date: Sun, 28 Jul 1996 08:07:11 +0200 (MET DST) X-Mailer: ELM [version 2.4 PL25] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Sender: owner-fs@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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.