- Remove wantparent, it is no longer necessary. An assert in vfs_lookup.c

prevents any callers from doing a modifying op without
   LOCKPARENT or WANTPARENT.
This commit is contained in:
Jeff Roberson 2005-03-29 13:09:42 +00:00
parent fcc9c112cf
commit da1c9cb2b5
6 changed files with 12 additions and 30 deletions

View File

@ -836,7 +836,7 @@ nwfs_lookup(ap)
struct nw_entry_info fattr, *fap;
ncpfid fid;
int nameiop=cnp->cn_nameiop, islastcn;
int wantparent, error = 0, notfound;
int error = 0, notfound;
struct thread *td = cnp->cn_thread;
char _name[cnp->cn_namelen+1];
bcopy(cnp->cn_nameptr, _name, cnp->cn_namelen);
@ -857,7 +857,6 @@ nwfs_lookup(ap)
return (EROFS);
if ((error = VOP_ACCESS(dvp, VEXEC, cnp->cn_cred, td)))
return (error);
wantparent = flags & (LOCKPARENT|WANTPARENT);
nmp = VFSTONWFS(mp);
dnp = VTONW(dvp);
/*
@ -943,7 +942,7 @@ printf("dvp %d:%d:%d\n", (int)mp, (int)dvp->v_vflag & VV_ROOT, (int)flags & ISDO
return (notfound); /* hard error */
if (notfound) { /* entry not found */
/* Handle RENAME or CREATE case... */
if ((nameiop == CREATE || nameiop == RENAME) && wantparent && islastcn) {
if ((nameiop == CREATE || nameiop == RENAME) && islastcn) {
cnp->cn_flags |= SAVENAME;
return (EJUSTRETURN);
}
@ -966,7 +965,7 @@ printf("dvp %d:%d:%d\n", (int)mp, (int)dvp->v_vflag & VV_ROOT, (int)flags & ISDO
cnp->cn_flags |= SAVENAME; /* I free it later */
return (0);
}
if (nameiop == RENAME && islastcn && wantparent) {
if (nameiop == RENAME && islastcn) {
error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred, cnp->cn_thread);
if (error) return (error);
if (NWCMPF(&dnp->n_fid, &fid)) return EISDIR;

View File

@ -1076,7 +1076,7 @@ smbfs_lookup(ap)
int flags = cnp->cn_flags;
int nameiop = cnp->cn_nameiop;
int nmlen = cnp->cn_namelen;
int wantparent, error, islastcn, isdot;
int error, islastcn, isdot;
int killit;
SMBVDEBUG("\n");
@ -1103,7 +1103,6 @@ smbfs_lookup(ap)
return EROFS;
if ((error = VOP_ACCESS(dvp, VEXEC, cnp->cn_cred, td)) != 0)
return error;
wantparent = flags & (LOCKPARENT|WANTPARENT);
smp = VFSTOSMBFS(mp);
dnp = VTOSMB(dvp);
isdot = (nmlen == 1 && name[0] == '.');
@ -1183,7 +1182,7 @@ smbfs_lookup(ap)
/*
* Handle RENAME or CREATE case...
*/
if ((nameiop == CREATE || nameiop == RENAME) && wantparent && islastcn) {
if ((nameiop == CREATE || nameiop == RENAME) && islastcn) {
error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred, td);
if (error)
return error;
@ -1213,7 +1212,7 @@ smbfs_lookup(ap)
cnp->cn_flags |= SAVENAME;
return 0;
}
if (nameiop == RENAME && islastcn && wantparent) {
if (nameiop == RENAME && islastcn) {
error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred, td);
if (error)
return error;

View File

@ -312,7 +312,6 @@ ext2_lookup(ap)
struct vnode *tdp; /* returned by VFS_VGET */
doff_t enduseful; /* pointer past last used dir slot */
u_long bmask; /* block offset mask */
int wantparent; /* 1 => wantparent flag */
int namlen, error;
struct vnode **vpp = ap->a_vpp;
struct componentname *cnp = ap->a_cnp;
@ -328,8 +327,6 @@ ext2_lookup(ap)
*vpp = NULL;
vdp = ap->a_dvp;
dp = VTOI(vdp);
wantparent = flags & (LOCKPARENT|WANTPARENT);
/*
* We now have a segment name to search for, and a directory to search.
*/
@ -572,9 +569,6 @@ ext2_lookup(ap)
/*
* If deleting, and at end of pathname, return
* parameters which can be used to remove file.
* If the wantparent flag isn't set, we return only
* the directory (in ndp->ni_dvp), otherwise we go
* on and lock the inode, being careful with ".".
*/
if (nameiop == DELETE && (flags & ISLASTCN)) {
/*
@ -623,8 +617,7 @@ ext2_lookup(ap)
* Must get inode of directory entry to verify it's a
* regular file, or empty directory.
*/
if (nameiop == RENAME && wantparent &&
(flags & ISLASTCN)) {
if (nameiop == RENAME && (flags & ISLASTCN)) {
if ((error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_thread)) != 0)
return (error);
/*

View File

@ -312,7 +312,6 @@ ext2_lookup(ap)
struct vnode *tdp; /* returned by VFS_VGET */
doff_t enduseful; /* pointer past last used dir slot */
u_long bmask; /* block offset mask */
int wantparent; /* 1 => wantparent flag */
int namlen, error;
struct vnode **vpp = ap->a_vpp;
struct componentname *cnp = ap->a_cnp;
@ -328,8 +327,6 @@ ext2_lookup(ap)
*vpp = NULL;
vdp = ap->a_dvp;
dp = VTOI(vdp);
wantparent = flags & (LOCKPARENT|WANTPARENT);
/*
* We now have a segment name to search for, and a directory to search.
*/
@ -572,9 +569,6 @@ ext2_lookup(ap)
/*
* If deleting, and at end of pathname, return
* parameters which can be used to remove file.
* If the wantparent flag isn't set, we return only
* the directory (in ndp->ni_dvp), otherwise we go
* on and lock the inode, being careful with ".".
*/
if (nameiop == DELETE && (flags & ISLASTCN)) {
/*
@ -623,8 +617,7 @@ ext2_lookup(ap)
* Must get inode of directory entry to verify it's a
* regular file, or empty directory.
*/
if (nameiop == RENAME && wantparent &&
(flags & ISLASTCN)) {
if (nameiop == RENAME && (flags & ISLASTCN)) {
if ((error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_thread)) != 0)
return (error);
/*

View File

@ -937,7 +937,7 @@ nfs4_lookup(struct vop_lookup_args *ap)
long len;
nfsfh_t *fhp;
struct nfsnode *np;
int wantparent, error = 0, fhsize;
int error = 0, fhsize;
struct thread *td = cnp->cn_thread;
struct nfs4_compound cp;
struct nfs4_oparg_getattr ga, dga;
@ -950,7 +950,6 @@ nfs4_lookup(struct vop_lookup_args *ap)
return (EROFS);
if (dvp->v_type != VDIR)
return (ENOTDIR);
wantparent = flags & (LOCKPARENT|WANTPARENT);
nmp = VFSTONFS(dvp->v_mount);
np = VTONFS(dvp);
@ -1030,7 +1029,7 @@ nfs4_lookup(struct vop_lookup_args *ap)
/*
* Handle RENAME case...
*/
if (cnp->cn_nameiop == RENAME && wantparent && (flags & ISLASTCN)) {
if (cnp->cn_nameiop == RENAME && (flags & ISLASTCN)) {
if (NFS_CMPFH(np, fhp, fhsize))
return (EISDIR);

View File

@ -776,7 +776,7 @@ nfs_lookup(struct vop_lookup_args *ap)
long len;
nfsfh_t *fhp;
struct nfsnode *np;
int wantparent, error = 0, attrflag, fhsize;
int error = 0, attrflag, fhsize;
int v3 = NFS_ISV3(dvp);
struct thread *td = cnp->cn_thread;
@ -786,7 +786,6 @@ nfs_lookup(struct vop_lookup_args *ap)
return (EROFS);
if (dvp->v_type != VDIR)
return (ENOTDIR);
wantparent = flags & (LOCKPARENT|WANTPARENT);
nmp = VFSTONFS(dvp->v_mount);
np = VTONFS(dvp);
if ((error = VOP_ACCESS(dvp, VEXEC, cnp->cn_cred, td)) != 0) {
@ -836,7 +835,7 @@ nfs_lookup(struct vop_lookup_args *ap)
/*
* Handle RENAME case...
*/
if (cnp->cn_nameiop == RENAME && wantparent && (flags & ISLASTCN)) {
if (cnp->cn_nameiop == RENAME && (flags & ISLASTCN)) {
if (NFS_CMPFH(np, fhp, fhsize)) {
m_freem(mrep);
return (EISDIR);