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: <Pine.BSF.4.21.0011070304500.47384-100000@starbug.ugh.net.au>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0011070304500.47384-100000>