Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Housecleaning time:
details: https://anonhg.NetBSD.org/src/rev/3e086a8dcfc0
branches: trunk
changeset: 474378:3e086a8dcfc0
user: sommerfeld <sommerfeld%NetBSD.org@localhost>
date: Sun Jul 04 20:16:57 1999 +0000
description:
Housecleaning time:
Fix and document naming convention for vnode variables (always use
lvp/lvpp and uvp/uvpp instead of a hash of cvp, vpp, dvpp, pvp, pvpp).
Delete old stale #if 0'ed code at the end.
Change error path code in getcwd_getcache() slightly (merge common
cleanup code; shouldn't affect behavior any).
diffstat:
sys/kern/vfs_getcwd.c | 371 +++++++++++++++++--------------------------------
1 files changed, 130 insertions(+), 241 deletions(-)
diffs (truncated from 602 to 300 lines):
diff -r 3a091bd4e930 -r 3e086a8dcfc0 sys/kern/vfs_getcwd.c
--- a/sys/kern/vfs_getcwd.c Sun Jul 04 20:07:51 1999 +0000
+++ b/sys/kern/vfs_getcwd.c Sun Jul 04 20:16:57 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_getcwd.c,v 1.8 1999/06/21 05:11:09 sommerfeld Exp $ */
+/* $NetBSD: vfs_getcwd.c,v 1.9 1999/07/04 20:16:57 sommerfeld Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -68,25 +68,44 @@
#define DIRENT_MINSIZE (sizeof(struct dirent) - (MAXNAMLEN+1) + 4)
/*
+ * Vnode variable naming conventions in this file:
+ *
+ * rvp: the current root we're aiming towards.
+ * lvp, *lvpp: the "lower" vnode
+ * uvp, *uvpp: the "upper" vnode.
+ *
+ * Since all the vnodes we're dealing with are directories, and the
+ * lookups are going *up* in the filesystem rather than *down*, the
+ * usual "pvp" (parent) or "dvp" (directory) naming conventions are
+ * too confusing.
+ */
+
+/*
* XXX Will infinite loop in certain cases if a directory read reliably
* returns EINVAL on last block.
* XXX is EINVAL the right thing to return if a directory is malformed?
*/
/*
- * Find parent vnode of cvp, return in *pvpp
- * Scan it looking for name of directory entry pointing at cvp.
+ * XXX Untested vs. mount -o union; probably does the wrong thing.
+ */
+
+/*
+ * Find parent vnode of *lvpp, return in *uvpp
+ *
+ * If we care about the name, scan it looking for name of directory
+ * entry pointing at lvp.
*
* Place the name in the buffer which starts at bufp, immediately
* before *bpp, and move bpp backwards to point at the start of it.
*
- * On entry, *cvpp is a locked vnode reference; on exit, it is vput and NULL'ed
- * On exit, *pvpp is either NULL or is a locked vnode reference.
+ * On entry, *lvpp is a locked vnode reference; on exit, it is vput and NULL'ed
+ * On exit, *uvpp is either NULL or is a locked vnode reference.
*/
static int
-getcwd_scandir(cvpp, pvpp, bpp, bufp, p)
- struct vnode **cvpp;
- struct vnode **pvpp;
+getcwd_scandir(lvpp, uvpp, bpp, bufp, p)
+ struct vnode **lvpp;
+ struct vnode **uvpp;
char **bpp;
char *bufp;
struct proc *p;
@@ -101,8 +120,8 @@
int dirbuflen;
ino_t fileno;
struct vattr va;
- struct vnode *pvp = NULL;
- struct vnode *cvp = *cvpp;
+ struct vnode *uvp = NULL;
+ struct vnode *lvp = *lvpp;
struct componentname cn;
int len, reclen;
tries = 0;
@@ -112,11 +131,11 @@
* current directory is still locked.
*/
if (bufp != NULL) {
- error = VOP_GETATTR(cvp, &va, p->p_ucred, p);
+ error = VOP_GETATTR(lvp, &va, p->p_ucred, p);
if (error) {
- vput(cvp);
- *cvpp = NULL;
- *pvpp = NULL;
+ vput(lvp);
+ *lvpp = NULL;
+ *uvpp = NULL;
return error;
}
}
@@ -136,22 +155,22 @@
cn.cn_consume = 0;
/*
- * At this point, cvp is locked and will be unlocked by the lookup.
- * On successful return, *pvpp will be locked
+ * At this point, lvp is locked and will be unlocked by the lookup.
+ * On successful return, *uvpp will be locked
*/
- error = VOP_LOOKUP(cvp, pvpp, &cn);
+ error = VOP_LOOKUP(lvp, uvpp, &cn);
if (error) {
- vput(cvp);
- *cvpp = NULL;
- *pvpp = NULL;
+ vput(lvp);
+ *lvpp = NULL;
+ *uvpp = NULL;
return error;
}
- pvp = *pvpp;
+ uvp = *uvpp;
/* If we don't care about the pathname, we're done */
if (bufp == NULL) {
- vrele(cvp);
- *cvpp = NULL;
+ vrele(lvp);
+ *lvpp = NULL;
return 0;
}
@@ -181,7 +200,7 @@
eofflag = 0;
- error = VOP_READDIR(pvp, &uio, p->p_ucred, &eofflag, 0, 0);
+ error = VOP_READDIR(uvp, &uio, p->p_ucred, &eofflag, 0, 0);
off = uio.uio_offset;
@@ -243,17 +262,17 @@
* Deal with mount -o union, which unions only the
* root directory of the mount.
*/
- if ((pvp->v_flag & VROOT) &&
- (pvp->v_mount->mnt_flag & MNT_UNION)) {
- struct vnode *tvp = pvp;
- pvp = pvp->v_mount->mnt_vnodecovered;
+ if ((uvp->v_flag & VROOT) &&
+ (uvp->v_mount->mnt_flag & MNT_UNION)) {
+ struct vnode *tvp = uvp;
+ uvp = uvp->v_mount->mnt_vnodecovered;
vput(tvp);
- VREF(pvp);
- *pvpp = pvp;
- error = vn_lock(pvp, LK_EXCLUSIVE | LK_RETRY);
+ VREF(uvp);
+ *uvpp = uvp;
+ error = vn_lock(uvp, LK_EXCLUSIVE | LK_RETRY);
if (error != 0) {
- vrele(pvp);
- *pvpp = pvp = NULL;
+ vrele(uvp);
+ *uvpp = uvp = NULL;
goto out;
}
goto unionread;
@@ -262,8 +281,8 @@
error = ENOENT;
out:
- vrele(cvp);
- *cvpp = NULL;
+ vrele(lvp);
+ *lvpp = NULL;
free(dirbuf, M_TEMP);
return error;
}
@@ -274,69 +293,75 @@
*
* XXX vget failure path is untested.
*
- * On entry, *vpp is a locked vnode reference.
+ * On entry, *lvpp is a locked vnode reference.
* On exit, one of the following is the case:
- * 0) Both *vpp and *vpp are NULL and failure is returned.
- * 1) *dvpp is NULL, *vpp remains locked and -1 is returned (cache miss)
- * 2) *dvpp is a locked vnode reference, *vpp is vput and NULL'ed
+ * 0) Both *lvpp and *uvpp are NULL and failure is returned.
+ * 1) *uvpp is NULL, *lvpp remains locked and -1 is returned (cache miss)
+ * 2) *uvpp is a locked vnode reference, *lvpp is vput and NULL'ed
* and 0 is returned (cache hit)
*/
static int
-getcwd_getcache(vpp, dvpp, bpp, bufp)
- struct vnode **vpp, **dvpp;
+getcwd_getcache(lvpp, uvpp, bpp, bufp)
+ struct vnode **lvpp, **uvpp;
char **bpp;
char *bufp;
{
- struct vnode *cvp, *pvp = NULL;
+ struct vnode *lvp, *uvp = NULL;
int error;
int vpid;
- cvp = *vpp;
+ lvp = *lvpp;
/*
* This returns 0 on a cache hit, -1 on a clean cache miss,
* or an errno on other failure.
*/
- error = cache_revlookup(cvp, dvpp, bpp, bufp);
+ error = cache_revlookup(lvp, uvpp, bpp, bufp);
if (error) {
if (error != -1) {
- vput(cvp);
- *vpp = NULL;
- *dvpp = NULL;
+ vput(lvp);
+ *lvpp = NULL;
+ *uvpp = NULL;
}
return error;
}
- pvp = *dvpp;
- vpid = pvp->v_id;
+ uvp = *uvpp;
+ vpid = uvp->v_id;
/*
* Since we're going up, we have to release the current lock
* before we take the parent lock.
*/
- VOP_UNLOCK(cvp, 0);
+ VOP_UNLOCK(lvp, 0);
- error = vget(pvp, LK_EXCLUSIVE | LK_RETRY);
+ error = vget(uvp, LK_EXCLUSIVE | LK_RETRY);
if (error != 0)
- *dvpp = NULL;
+ *uvpp = NULL;
/*
- * Check that vnode capability didn't change while we were waiting
- * for the lock.
+ * Verify that vget succeeded, and check that vnode capability
+ * didn't change while we were waiting for the lock.
*/
- if (error || (vpid != pvp->v_id)) {
+ if (error || (vpid != uvp->v_id)) {
/*
- * oops, it did. do this the hard way.
+ * Oops, we missed. If the vget failed, or the
+ * capability changed, try to get our lock back; if
+ * that works, tell caller to try things the hard way,
+ * otherwise give up.
*/
- if (!error) vput(pvp);
- error = vn_lock(cvp, LK_EXCLUSIVE | LK_RETRY);
- *dvpp = NULL;
- return -1;
+ if (!error) vput(uvp);
+ *uvpp = NULL;
+
+ error = vn_lock(lvp, LK_EXCLUSIVE | LK_RETRY);
+
+ if (!error)
+ return -1;
}
- vrele(cvp);
- *vpp = NULL;
+ vrele(lvp);
+ *lvpp = NULL;
- return 0;
+ return error;
}
/*
@@ -345,8 +370,8 @@
#define GETCWD_CHECK_ACCESS 0x0001
-static int getcwd_common (dvp, rvp, bpp, bufp, limit, flags, p)
- struct vnode *dvp;
+static int getcwd_common (lvp, rvp, bpp, bufp, limit, flags, p)
+ struct vnode *lvp;
struct vnode *rvp;
char **bpp;
char *bufp;
@@ -355,7 +380,7 @@
struct proc *p;
{
struct cwdinfo *cwdi = p->p_cwdi;
- struct vnode *pvp = NULL;
+ struct vnode *uvp = NULL;
char *bp = NULL;
int error;
@@ -366,19 +391,19 @@
}
VREF(rvp);
- VREF(dvp);
+ VREF(lvp);
/*
* Error handling invariant:
Home |
Main Index |
Thread Index |
Old Index