diff options
author | eivind <eivind@FreeBSD.org> | 1999-01-08 17:31:30 +0000 |
---|---|---|
committer | eivind <eivind@FreeBSD.org> | 1999-01-08 17:31:30 +0000 |
commit | a8dc66f457be84eefbe16e70c901ceb11137ba65 (patch) | |
tree | e5747f527c552fa90334c779c047697b372582fb /sys/kern/vfs_lookup.c | |
parent | 1c69824749ed0aa6efce159d39ab3f17fc9e25f2 (diff) | |
download | FreeBSD-src-a8dc66f457be84eefbe16e70c901ceb11137ba65.zip FreeBSD-src-a8dc66f457be84eefbe16e70c901ceb11137ba65.tar.gz |
Split DIAGNOSTIC -> DIAGNOSTIC, INVARIANTS, and INVARIANT_SUPPORT as
discussed on -hackers.
Introduce 'KASSERT(assertion, ("panic message", args))' for simple
check + panic.
Reviewed by: msmith
Diffstat (limited to 'sys/kern/vfs_lookup.c')
-rw-r--r-- | sys/kern/vfs_lookup.c | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index 3a00557..e6e8a6f 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)vfs_lookup.c 8.4 (Berkeley) 2/16/94 - * $Id: vfs_lookup.c,v 1.28 1998/06/07 17:11:45 dfr Exp $ + * $Id: vfs_lookup.c,v 1.29 1999/01/05 18:49:52 eivind Exp $ */ #include "opt_ktrace.h" @@ -89,14 +89,11 @@ namei(ndp) struct proc *p = cnp->cn_proc; ndp->ni_cnd.cn_cred = ndp->ni_cnd.cn_proc->p_ucred; -#ifdef DIAGNOSTIC - if (!cnp->cn_cred || !cnp->cn_proc) - panic ("namei: bad cred/proc"); - if (cnp->cn_nameiop & (~OPMASK)) - panic ("namei: nameiop contaminated with flags"); - if (cnp->cn_flags & OPMASK) - panic ("namei: flags contaminated with nameiops"); -#endif + KASSERT(cnp->cn_cred && cnp->cn_proc, ("namei: bad cred/proc")); + KASSERT((cnp->cn_nameiop & (~OPMASK)) == 0, + ("namei: nameiop contaminated with flags")); + KASSERT((cnp->cn_flags & OPMASK) == 0, + ("namei: flags contaminated with nameiops")); fdp = cnp->cn_proc->p_fd; /* @@ -418,10 +415,7 @@ unionlookup: ndp->ni_vp = NULL; ASSERT_VOP_LOCKED(dp, "lookup"); if (error = VOP_LOOKUP(dp, &ndp->ni_vp, cnp)) { -#ifdef DIAGNOSTIC - if (ndp->ni_vp != NULL) - panic("leaf should be empty"); -#endif + KASSERT(ndp->ni_vp == NULL, ("leaf should be empty")); #ifdef NAMEI_DIAGNOSTIC printf("not found\n"); #endif @@ -649,10 +643,7 @@ relookup(dvp, vpp, cnp) * We now have a segment name to search for, and a directory to search. */ if (error = VOP_LOOKUP(dp, vpp, cnp)) { -#ifdef DIAGNOSTIC - if (*vpp != NULL) - panic("leaf should be empty"); -#endif + KASSERT(*vpp == NULL, ("leaf should be empty")); if (error != EJUSTRETURN) goto bad; /* @@ -675,13 +666,11 @@ relookup(dvp, vpp, cnp) } dp = *vpp; -#ifdef DIAGNOSTIC /* * Check for symbolic link */ - if (dp->v_type == VLNK && (cnp->cn_flags & FOLLOW)) - panic ("relookup: symlink found.\n"); -#endif + KASSERT(dp->v_type != VLNK || !(cnp->cn_flags & FOLLOW), + ("relookup: symlink found.\n")); /* * Disallow directory write attempts on read-only file systems. |