From owner-freebsd-doc Mon Nov 6 9:18:29 2000 Delivered-To: freebsd-doc@freebsd.org Received: from starbug.ugh.net.au (starbug.ugh.net.au [203.31.238.37]) by hub.freebsd.org (Postfix) with ESMTP id 38A4A37B4CF for ; Mon, 6 Nov 2000 09:18:23 -0800 (PST) Received: by starbug.ugh.net.au (Postfix, from userid 1000) id CC5FEA82B; Tue, 7 Nov 2000 04:18:18 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by starbug.ugh.net.au (Postfix) with ESMTP id C9FC65464 for ; Tue, 7 Nov 2000 03:18:18 +1000 (EST) Date: Tue, 7 Nov 2000 03:16:34 +1000 (EST) From: andrew@ugh.net.au To: docs@freebsd.org Subject: Man page for vcount Message-ID: X-WonK: *wibble* MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-doc@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org Hi, I have written a man page for vcount. I don't want to send-pr it until someone has checked it for technical accuracy as I'm not exactly an expert in this area. OTH vcount appears to be simple and is at least short. It is available at http://www.ugh.net.au/~andrew/misc/vcount.9 I have already asked on -hackers but didn't get any response. While I was trying to understand a few functions in the kernel I made a few comments in the source code. I have attached a diff below. Is this useful? The comments are all pretty obvious but it may reduce the barrier to entry for new programmers (I'd comment harder functions but I don't understand them yet ;) ). I will do more functions as I come across them if ppl feel this is a good idea and not just a distraction to the code. Thanks, Andrew --snip-- Patch for /usr/src/sys/kern/vfs_syscalls.c: --- vfs_syscalls.c.orig Sat Nov 4 23:31:21 2000 +++ vfs_syscalls.c Tue Nov 7 03:14:09 2000 @@ -3046,23 +3046,29 @@ int error; struct nameidata nd; + /* get the vnode for the given filename (and ++usecount) */ NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); if ((error = namei(&nd)) != 0) return (error); vp = nd.ni_vp; NDFREE(&nd, NDF_ONLY_PNBUF); + /* make sure the vnode is of a type you can revoke */ if (vp->v_type != VCHR && vp->v_type != VBLK) { error = EINVAL; goto out; } + /* get the attributes of this file */ if ((error = VOP_GETATTR(vp, &vattr, p->p_ucred, p)) != 0) goto out; + /* make sure euid == owner of file or we are invoked by the superuser */ if (p->p_ucred->cr_uid != vattr.va_uid && (error = suser_xxx(0, p, PRISON_ROOT))) goto out; + /* if someone other than us is using the device then do the revoke */ if (vcount(vp) > 1) VOP_REVOKE(vp, REVOKEALL); out: + /* --usecount to say we are finished with this vnode */ vrele(vp); return (error); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-doc" in the body of the message