Abolish struct componentname's cn_pnbuf. Use the path buffer in the

pathbuf object passed to namei as work space instead. (For now a pnbuf
pointer appears in struct nameidata, to support certain unclean things
that haven't been fixed yet, but it will be going away in the future.)

This removes the need for the SAVENAME and HASBUF namei flags.
This commit is contained in:
dholland 2010-11-30 10:29:57 +00:00
parent e1de74391b
commit d4eb05390d
25 changed files with 329 additions and 321 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: coda_vnops.c,v 1.76 2010/07/20 17:26:03 christos Exp $ */
/* $NetBSD: coda_vnops.c,v 1.77 2010/11/30 10:29:57 dholland Exp $ */
/*
*
@ -46,7 +46,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: coda_vnops.c,v 1.76 2010/07/20 17:26:03 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: coda_vnops.c,v 1.77 2010/11/30 10:29:57 dholland Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -703,11 +703,11 @@ coda_abortop(void *v)
struct vnode *a_dvp;
struct componentname *a_cnp;
} */ *ap = v;
(void)ap;
/* upcall decl */
/* locals */
if ((ap->a_cnp->cn_flags & (HASBUF | SAVESTART)) == HASBUF)
PNBUF_PUT(ap->a_cnp->cn_pnbuf);
return (0);
}
@ -1137,10 +1137,6 @@ coda_create(void *v)
}
}
/* Per vnodeops(9), free name except on success and SAVESTART. */
if (error || (cnp->cn_flags & SAVESTART) == 0) {
PNBUF_PUT(cnp->cn_pnbuf);
}
return(error);
}
@ -1461,10 +1457,6 @@ coda_mkdir(void *v)
}
}
/* Per vnodeops(9), free name except on success and SAVESTART. */
if (error || (cnp->cn_flags & SAVESTART) == 0) {
PNBUF_PUT(cnp->cn_pnbuf);
}
return(error);
}
@ -1614,11 +1606,6 @@ coda_symlink(void *v)
/* unlock and deference parent */
vput(dvp);
/* Per vnodeops(9), free name except on success and SAVESTART. */
if (error || (cnp->cn_flags & SAVESTART) == 0) {
PNBUF_PUT(cnp->cn_pnbuf);
}
CODADEBUG(CODA_SYMLINK, myprintf(("in symlink result %d\n",error)); )
return(error);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: svr4_misc.c,v 1.152 2010/11/19 06:44:38 dholland Exp $ */
/* $NetBSD: svr4_misc.c,v 1.153 2010/11/30 10:29:58 dholland Exp $ */
/*-
* Copyright (c) 1994, 2008 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: svr4_misc.c,v 1.152 2010/11/19 06:44:38 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: svr4_misc.c,v 1.153 2010/11/30 10:29:58 dholland Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -1334,14 +1334,13 @@ svr4_sys_resolvepath(struct lwp *l, const struct svr4_sys_resolvepath_args *uap,
return error;
}
if ((error = copyoutstr(nd.ni_cnd.cn_pnbuf, SCARG(uap, buf),
if ((error = copyoutstr(nd.ni_pnbuf, SCARG(uap, buf),
SCARG(uap, bufsiz), &len)) != 0)
goto bad;
*retval = len;
bad:
vrele(nd.ni_vp);
PNBUF_PUT(nd.ni_cnd.cn_pnbuf);
pathbuf_destroy(pb);
return error;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: svr4_32_misc.c,v 1.71 2010/11/19 06:44:38 dholland Exp $ */
/* $NetBSD: svr4_32_misc.c,v 1.72 2010/11/30 10:29:58 dholland Exp $ */
/*-
* Copyright (c) 1994, 2008 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: svr4_32_misc.c,v 1.71 2010/11/19 06:44:38 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: svr4_32_misc.c,v 1.72 2010/11/30 10:29:58 dholland Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -1339,7 +1339,7 @@ svr4_32_sys_resolvepath(struct lwp *l, const struct svr4_32_sys_resolvepath_args
return error;
}
if ((error = copyoutstr(nd.ni_cnd.cn_pnbuf,
if ((error = copyoutstr(nd.ni_pnbuf,
SCARG_P32(uap, buf),
SCARG(uap, bufsiz), &len)) != 0)
goto bad;
@ -1347,7 +1347,6 @@ svr4_32_sys_resolvepath(struct lwp *l, const struct svr4_32_sys_resolvepath_args
*retval = len;
bad:
vrele(nd.ni_vp);
PNBUF_PUT(nd.ni_cnd.cn_pnbuf);
pathbuf_destroy(pb);
return error;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: msdosfs_vnops.c,v 1.68 2010/07/22 18:08:11 njoly Exp $ */
/* $NetBSD: msdosfs_vnops.c,v 1.69 2010/11/30 10:29:59 dholland Exp $ */
/*-
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.68 2010/07/22 18:08:11 njoly Exp $");
__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.69 2010/11/30 10:29:59 dholland Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -99,9 +99,7 @@ __KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.68 2010/07/22 18:08:11 njoly Exp
/*
* Create a regular file. On entry the directory to contain the file being
* created is locked. We must release before we return. We must also free
* the pathname buffer pointed at by cnp->cn_pnbuf, always on error, or
* only if the SAVESTART bit in cn_flags is clear on success.
* created is locked. We must release before we return.
*/
int
msdosfs_create(void *v)
@ -159,8 +157,6 @@ msdosfs_create(void *v)
DETIMES(&ndirent, NULL, NULL, NULL, pdep->de_pmp->pm_gmtoff);
if ((error = createde(&ndirent, pdep, &dep, cnp)) != 0)
goto bad;
if ((cnp->cn_flags & SAVESTART) == 0)
PNBUF_PUT(cnp->cn_pnbuf);
fstrans_done(ap->a_dvp->v_mount);
VN_KNOTE(ap->a_dvp, NOTE_WRITE);
vput(ap->a_dvp);
@ -169,7 +165,6 @@ msdosfs_create(void *v)
bad:
fstrans_done(ap->a_dvp->v_mount);
PNBUF_PUT(cnp->cn_pnbuf);
vput(ap->a_dvp);
return (error);
}
@ -1292,8 +1287,6 @@ msdosfs_mkdir(void *v)
ndirent.de_devvp = pdep->de_devvp;
if ((error = createde(&ndirent, pdep, &dep, cnp)) != 0)
goto bad;
if ((cnp->cn_flags & SAVESTART) == 0)
PNBUF_PUT(cnp->cn_pnbuf);
VN_KNOTE(ap->a_dvp, NOTE_WRITE | NOTE_LINK);
vput(ap->a_dvp);
*ap->a_vpp = DETOV(dep);
@ -1303,7 +1296,6 @@ msdosfs_mkdir(void *v)
bad:
clusterfree(pmp, newcluster, NULL);
bad2:
PNBUF_PUT(cnp->cn_pnbuf);
vput(ap->a_dvp);
fstrans_done(ap->a_dvp->v_mount);
return (error);

View File

@ -1,4 +1,4 @@
/* $NetBSD: nilfs_vnops.c,v 1.7 2010/06/24 13:03:10 hannken Exp $ */
/* $NetBSD: nilfs_vnops.c,v 1.8 2010/11/30 10:29:59 dholland Exp $ */
/*
* Copyright (c) 2008, 2009 Reinoud Zandijk
@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
__KERNEL_RCSID(0, "$NetBSD: nilfs_vnops.c,v 1.7 2010/06/24 13:03:10 hannken Exp $");
__KERNEL_RCSID(0, "$NetBSD: nilfs_vnops.c,v 1.8 2010/11/30 10:29:59 dholland Exp $");
#endif /* not lint */
@ -1099,8 +1099,6 @@ nilfs_create(void *v)
DPRINTF(VFSCALL, ("nilfs_create called\n"));
error = nilfs_create_node(dvp, vpp, vap, cnp);
if (error || !(cnp->cn_flags & SAVESTART))
PNBUF_PUT(cnp->cn_pnbuf);
vput(dvp);
return error;
}
@ -1125,8 +1123,6 @@ nilfs_mknod(void *v)
DPRINTF(VFSCALL, ("nilfs_mknod called\n"));
error = nilfs_create_node(dvp, vpp, vap, cnp);
if (error || !(cnp->cn_flags & SAVESTART))
PNBUF_PUT(cnp->cn_pnbuf);
vput(dvp);
return error;
}
@ -1151,8 +1147,6 @@ nilfs_mkdir(void *v)
DPRINTF(VFSCALL, ("nilfs_mkdir called\n"));
error = nilfs_create_node(dvp, vpp, vap, cnp);
if (error || !(cnp->cn_flags & SAVESTART))
PNBUF_PUT(cnp->cn_pnbuf);
vput(dvp);
return error;
}
@ -1271,8 +1265,6 @@ nilfs_symlink(void *v)
nilfs_dir_detach(nilfs_node->ump, dir_node, nilfs_node, cnp);
}
}
if (error || !(cnp->cn_flags & SAVESTART))
PNBUF_PUT(cnp->cn_pnbuf);
vput(dvp);
return error;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: puffs_vnops.c,v 1.147 2010/07/14 14:07:37 pooka Exp $ */
/* $NetBSD: puffs_vnops.c,v 1.148 2010/11/30 10:29:59 dholland Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.147 2010/07/14 14:07:37 pooka Exp $");
__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.148 2010/11/30 10:29:59 dholland Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@ -673,8 +673,6 @@ puffs_vnop_create(void *v)
out:
vput(dvp);
if (error || (cnp->cn_flags & SAVESTART) == 0)
PNBUF_PUT(cnp->cn_pnbuf);
DPRINTF(("puffs_create: return %d\n", error));
PUFFS_MSG_RELEASE(create);
@ -722,8 +720,6 @@ puffs_vnop_mknod(void *v)
out:
vput(dvp);
PUFFS_MSG_RELEASE(mknod);
if (error || (cnp->cn_flags & SAVESTART) == 0)
PNBUF_PUT(cnp->cn_pnbuf);
return error;
}
@ -1484,8 +1480,6 @@ puffs_vnop_remove(void *v)
RELEPN_AND_VP(vp, pn);
error = checkerr(pmp, error, __func__);
if (error || (cnp->cn_flags & SAVESTART) == 0)
PNBUF_PUT(cnp->cn_pnbuf);
return error;
}
@ -1529,8 +1523,6 @@ puffs_vnop_mkdir(void *v)
out:
vput(dvp);
PUFFS_MSG_RELEASE(mkdir);
if (error || (cnp->cn_flags & SAVESTART) == 0)
PNBUF_PUT(cnp->cn_pnbuf);
return error;
}
@ -1589,9 +1581,6 @@ puffs_vnop_rmdir(void *v)
RELEPN_AND_VP(dvp, dpn);
RELEPN_AND_VP(vp, pn);
if (error || (cnp->cn_flags & SAVESTART) == 0)
PNBUF_PUT(cnp->cn_pnbuf);
return error;
}
@ -1636,7 +1625,6 @@ puffs_vnop_link(void *v)
if (error == 0)
puffs_updatenode(pn, PUFFS_UPDATECTIME, 0);
PNBUF_PUT(cnp->cn_pnbuf);
RELEPN_AND_VP(dvp, dpn);
puffs_releasenode(pn);
@ -1688,8 +1676,6 @@ puffs_vnop_symlink(void *v)
out:
vput(dvp);
PUFFS_MSG_RELEASE(symlink);
if (error || (cnp->cn_flags & SAVESTART) == 0)
PNBUF_PUT(cnp->cn_pnbuf);
return error;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: smbfs_vnops.c,v 1.75 2010/06/24 13:03:10 hannken Exp $ */
/* $NetBSD: smbfs_vnops.c,v 1.76 2010/11/30 10:30:00 dholland Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@ -64,7 +64,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: smbfs_vnops.c,v 1.75 2010/06/24 13:03:10 hannken Exp $");
__KERNEL_RCSID(0, "$NetBSD: smbfs_vnops.c,v 1.76 2010/11/30 10:30:00 dholland Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -554,9 +554,7 @@ smbfs_write(void *v)
/*
* smbfs_create call
* Create a regular file. On entry the directory to contain the file being
* created is locked. We must release before we return. We must also free
* the pathname buffer pointed at by cnp->cn_pnbuf, always on error, or
* only if the SAVESTART bit in cn_flags is clear on success.
* created is locked. We must release before we return.
*/
int
smbfs_create(void *v)
@ -598,8 +596,6 @@ smbfs_create(void *v)
cache_enter(dvp, *ap->a_vpp, cnp);
out:
if (error || ((cnp->cn_flags & SAVESTART) == 0))
PNBUF_PUT(cnp->cn_pnbuf);
VN_KNOTE(dvp, NOTE_WRITE);
vput(dvp);
return (error);
@ -799,8 +795,6 @@ smbfs_mkdir(void *v)
*ap->a_vpp = vp;
out:
if (error || ((cnp->cn_flags & SAVESTART) == 0))
PNBUF_PUT(cnp->cn_pnbuf);
VN_KNOTE(dvp, NOTE_WRITE | NOTE_LINK);
vput(dvp);

View File

@ -1,4 +1,4 @@
/* $NetBSD: sysvbfs_vnops.c,v 1.33 2010/07/17 00:13:42 njoly Exp $ */
/* $NetBSD: sysvbfs_vnops.c,v 1.34 2010/11/30 10:30:00 dholland Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sysvbfs_vnops.c,v 1.33 2010/07/17 00:13:42 njoly Exp $");
__KERNEL_RCSID(0, "$NetBSD: sysvbfs_vnops.c,v 1.34 2010/11/30 10:30:00 dholland Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@ -168,9 +168,6 @@ sysvbfs_create(void *arg)
/* unlock parent directory */
vput(a->a_dvp); /* locked at sysvbfs_lookup(); */
if (err || (a->a_cnp->cn_flags & SAVESTART) == 0)
PNBUF_PUT(a->a_cnp->cn_pnbuf);
return err;
}
@ -485,9 +482,6 @@ sysvbfs_remove(void *arg)
bnode->removed = 1;
}
if (err || (ap->a_cnp->cn_flags & SAVESTART) == 0)
PNBUF_PUT(ap->a_cnp->cn_pnbuf);
return err;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: tmpfs_subr.c,v 1.59 2010/07/21 17:52:11 hannken Exp $ */
/* $NetBSD: tmpfs_subr.c,v 1.60 2010/11/30 10:30:00 dholland Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.59 2010/07/21 17:52:11 hannken Exp $");
__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.60 2010/11/30 10:30:00 dholland Exp $");
#include <sys/param.h>
#include <sys/dirent.h>
@ -512,8 +512,6 @@ tmpfs_alloc_file(struct vnode *dvp, struct vnode **vpp, struct vattr *vap,
}
out:
if (error != 0 || !(cnp->cn_flags & SAVESTART))
PNBUF_PUT(cnp->cn_pnbuf);
vput(dvp);
KASSERT(IFF(error == 0, *vpp != NULL));

View File

@ -1,4 +1,4 @@
/* $NetBSD: tmpfs_vnops.c,v 1.73 2010/07/14 16:03:49 pooka Exp $ */
/* $NetBSD: tmpfs_vnops.c,v 1.74 2010/11/30 10:30:00 dholland Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.73 2010/07/14 16:03:49 pooka Exp $");
__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.74 2010/11/30 10:30:00 dholland Exp $");
#include <sys/param.h>
#include <sys/dirent.h>
@ -728,10 +728,6 @@ out:
vrele(dvp);
else
vput(dvp);
if (cnp->cn_flags & HASBUF) {
PNBUF_PUT(cnp->cn_pnbuf);
cnp->cn_flags &= ~HASBUF;
}
return error;
}
@ -806,7 +802,6 @@ tmpfs_link(void *v)
out:
VOP_UNLOCK(vp);
PNBUF_PUT(cnp->cn_pnbuf);
vput(dvp);
return error;
@ -1121,7 +1116,6 @@ tmpfs_rmdir(void *v)
/* Release the nodes. */
vput(dvp);
vput(vp);
PNBUF_PUT(cnp->cn_pnbuf);
return error;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: udf_vnops.c,v 1.59 2010/06/24 13:03:11 hannken Exp $ */
/* $NetBSD: udf_vnops.c,v 1.60 2010/11/30 10:30:01 dholland Exp $ */
/*
* Copyright (c) 2006, 2008 Reinoud Zandijk
@ -32,7 +32,7 @@
#include <sys/cdefs.h>
#ifndef lint
__KERNEL_RCSID(0, "$NetBSD: udf_vnops.c,v 1.59 2010/06/24 13:03:11 hannken Exp $");
__KERNEL_RCSID(0, "$NetBSD: udf_vnops.c,v 1.60 2010/11/30 10:30:01 dholland Exp $");
#endif /* not lint */
@ -1421,8 +1421,6 @@ udf_create(void *v)
DPRINTF(CALL, ("udf_create called\n"));
error = udf_create_node(dvp, vpp, vap, cnp);
if (error || !(cnp->cn_flags & SAVESTART))
PNBUF_PUT(cnp->cn_pnbuf);
vput(dvp);
return error;
}
@ -1447,8 +1445,6 @@ udf_mknod(void *v)
DPRINTF(CALL, ("udf_mknod called\n"));
error = udf_create_node(dvp, vpp, vap, cnp);
if (error || !(cnp->cn_flags & SAVESTART))
PNBUF_PUT(cnp->cn_pnbuf);
vput(dvp);
return error;
}
@ -1473,8 +1469,6 @@ udf_mkdir(void *v)
DPRINTF(CALL, ("udf_mkdir called\n"));
error = udf_create_node(dvp, vpp, vap, cnp);
if (error || !(cnp->cn_flags & SAVESTART))
PNBUF_PUT(cnp->cn_pnbuf);
vput(dvp);
return error;
}
@ -1699,8 +1693,6 @@ udf_symlink(void *v)
udf_dir_detach(udf_node->ump, dir_node, udf_node, cnp);
}
}
if (error || !(cnp->cn_flags & SAVESTART))
PNBUF_PUT(cnp->cn_pnbuf);
vput(dvp);
return error;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: union_subr.c,v 1.39 2010/07/21 17:52:11 hannken Exp $ */
/* $NetBSD: union_subr.c,v 1.40 2010/11/30 10:30:01 dholland Exp $ */
/*
* Copyright (c) 1994
@ -72,7 +72,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: union_subr.c,v 1.39 2010/07/21 17:52:11 hannken Exp $");
__KERNEL_RCSID(0, "$NetBSD: union_subr.c,v 1.40 2010/11/30 10:30:01 dholland Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -108,7 +108,8 @@ static void union_list_unlock(int);
void union_updatevp(struct union_node *, struct vnode *, struct vnode *);
static int union_relookup(struct union_mount *, struct vnode *,
struct vnode **, struct componentname *,
struct componentname *, const char *, int);
struct componentname *, char **,
const char *, int);
int union_vn_close(struct vnode *, int, kauth_cred_t, struct lwp *);
static void union_dircache_r(struct vnode *, struct vnode ***, int *);
struct vnode *union_dircache(struct vnode *, struct lwp *);
@ -780,10 +781,12 @@ union_relookup(
struct vnode **vpp,
struct componentname *cnp,
struct componentname *cn,
char **pnbuf_ret,
const char *path,
int pathlen)
{
int error;
char *pnbuf;
/*
* A new componentname structure must be faked up because
@ -793,15 +796,14 @@ union_relookup(
* by namei, some of the work done by lookup and some of
* the work done by VOP_LOOKUP when given a CREATE flag.
* Conclusion: Horrible.
*
* The pathname buffer will be PNBUF_PUT'd by VOP_MKDIR.
*/
cn->cn_namelen = pathlen;
if ((cn->cn_namelen + 1) > MAXPATHLEN)
return (ENAMETOOLONG);
cn->cn_pnbuf = PNBUF_GET();
memcpy(cn->cn_pnbuf, path, cn->cn_namelen);
cn->cn_pnbuf[cn->cn_namelen] = '\0';
pnbuf = PNBUF_GET();
memcpy(pnbuf, path, cn->cn_namelen);
pnbuf[cn->cn_namelen] = '\0';
*pnbuf_ret = pnbuf;
cn->cn_nameiop = CREATE;
cn->cn_flags = (LOCKPARENT|HASBUF|SAVENAME|ISLASTCN);
@ -809,14 +811,14 @@ union_relookup(
cn->cn_cred = cnp->cn_cred;
else
cn->cn_cred = um->um_cred;
cn->cn_nameptr = cn->cn_pnbuf;
cn->cn_nameptr = pnbuf;
cn->cn_hash = cnp->cn_hash;
cn->cn_consume = cnp->cn_consume;
error = relookup(dvp, vpp, cn);
if (error) {
PNBUF_PUT(cn->cn_pnbuf);
cn->cn_pnbuf = 0;
PNBUF_PUT(pnbuf);
*pnbuf_ret = NULL;
}
return (error);
@ -844,9 +846,10 @@ union_mkshadow(struct union_mount *um, struct vnode *dvp,
int error;
struct vattr va;
struct componentname cn;
char *pnbuf;
vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY);
error = union_relookup(um, dvp, vpp, cnp, &cn,
error = union_relookup(um, dvp, vpp, cnp, &cn, &pnbuf,
cnp->cn_nameptr, cnp->cn_namelen);
if (error) {
VOP_UNLOCK(dvp);
@ -855,6 +858,7 @@ union_mkshadow(struct union_mount *um, struct vnode *dvp,
if (*vpp) {
VOP_ABORTOP(dvp, &cn);
PNBUF_PUT(pnbuf);
if (dvp != *vpp)
VOP_UNLOCK(dvp);
vput(*vpp);
@ -876,6 +880,7 @@ union_mkshadow(struct union_mount *um, struct vnode *dvp,
vref(dvp);
error = VOP_MKDIR(dvp, vpp, &cn, &va);
PNBUF_PUT(pnbuf);
return (error);
}
@ -895,15 +900,18 @@ union_mkwhiteout(struct union_mount *um, struct vnode *dvp,
int error;
struct vnode *wvp;
struct componentname cn;
char *pnbuf;
VOP_UNLOCK(dvp);
vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY);
error = union_relookup(um, dvp, &wvp, cnp, &cn, path, strlen(path));
error = union_relookup(um, dvp, &wvp, cnp, &cn, &pnbuf,
path, strlen(path));
if (error)
return (error);
if (wvp) {
VOP_ABORTOP(dvp, &cn);
PNBUF_PUT(pnbuf);
if (dvp != wvp)
VOP_UNLOCK(dvp);
vput(wvp);
@ -911,9 +919,11 @@ union_mkwhiteout(struct union_mount *um, struct vnode *dvp,
}
error = VOP_WHITEOUT(dvp, &cn, CREATE);
if (error)
if (error) {
VOP_ABORTOP(dvp, &cn);
}
PNBUF_PUT(pnbuf);
return (error);
}
@ -936,6 +946,7 @@ union_vn_create(struct vnode **vpp, struct union_node *un, struct lwp *l)
int error;
int cmode = UN_FILEMODE & ~l->l_proc->p_cwdi->cwdi_cmask;
struct componentname cn;
char *pnbuf;
*vpp = NULLVP;
@ -951,24 +962,26 @@ union_vn_create(struct vnode **vpp, struct union_node *un, struct lwp *l)
cn.cn_namelen = strlen(un->un_path);
if ((cn.cn_namelen + 1) > MAXPATHLEN)
return (ENAMETOOLONG);
cn.cn_pnbuf = PNBUF_GET();
memcpy(cn.cn_pnbuf, un->un_path, cn.cn_namelen+1);
pnbuf = PNBUF_GET();
memcpy(pnbuf, un->un_path, cn.cn_namelen+1);
cn.cn_nameiop = CREATE;
cn.cn_flags = (LOCKPARENT|HASBUF|SAVENAME|ISLASTCN);
cn.cn_cred = l->l_cred;
cn.cn_nameptr = cn.cn_pnbuf;
cn.cn_nameptr = pnbuf;
cn.cn_hash = un->un_hash;
cn.cn_consume = 0;
vn_lock(un->un_dirvp, LK_EXCLUSIVE | LK_RETRY);
error = relookup(un->un_dirvp, &vp, &cn);
if (error) {
PNBUF_PUT(pnbuf);
VOP_UNLOCK(un->un_dirvp);
return (error);
}
if (vp) {
VOP_ABORTOP(un->un_dirvp, &cn);
PNBUF_PUT(pnbuf);
if (un->un_dirvp != vp)
VOP_UNLOCK(un->un_dirvp);
vput(vp);
@ -989,16 +1002,20 @@ union_vn_create(struct vnode **vpp, struct union_node *un, struct lwp *l)
vap->va_type = VREG;
vap->va_mode = cmode;
vref(un->un_dirvp);
if ((error = VOP_CREATE(un->un_dirvp, &vp, &cn, vap)) != 0)
if ((error = VOP_CREATE(un->un_dirvp, &vp, &cn, vap)) != 0) {
PNBUF_PUT(pnbuf);
return (error);
}
if ((error = VOP_OPEN(vp, fmode, cred)) != 0) {
vput(vp);
PNBUF_PUT(pnbuf);
return (error);
}
vp->v_writecount++;
*vpp = vp;
PNBUF_PUT(pnbuf);
return (0);
}

View File

@ -298,20 +298,22 @@ unionfs_create_uppervattr(struct unionfs_mount *ump,
static int
unionfs_relookup(struct vnode *dvp, struct vnode **vpp,
struct componentname *cnp, struct componentname *cn,
char **pnbuf_ret,
const char *path, int pathlen, u_long nameiop)
{
int error;
char *pnbuf;
cn->cn_namelen = pathlen;
cn->cn_pnbuf = PNBUF_GET();
memcpy(cn->cn_pnbuf, path, pathlen);
cn->cn_pnbuf[pathlen] = '\0';
pnbuf = PNBUF_GET();
memcpy(pnbuf, path, pathlen);
pnbuf[pathlen] = '\0';
cn->cn_nameiop = nameiop;
cn->cn_flags = (LOCKPARENT | LOCKLEAF | HASBUF | SAVENAME | ISLASTCN);
cn->cn_cred = cnp->cn_cred;
cn->cn_nameptr = cn->cn_pnbuf;
cn->cn_nameptr = pnbuf;
cn->cn_consume = cnp->cn_consume;
if (nameiop == DELETE)
@ -323,11 +325,14 @@ unionfs_relookup(struct vnode *dvp, struct vnode **vpp,
VOP_UNLOCK(dvp);
if ((error = relookup(dvp, vpp, cn))) {
PNBUF_PUT(cn->cn_pnbuf);
PNBUF_PUT(pnbuf);
*pnbuf_ret = NULL;
cn->cn_flags &= ~HASBUF;
vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY);
} else
} else {
*pnbuf_ret = pnbuf;
vrele(dvp);
}
return (error);
}
@ -348,11 +353,13 @@ unionfs_relookup_for_create(struct vnode *dvp, struct componentname *cnp)
struct vnode *udvp;
struct vnode *vp;
struct componentname cn;
char *pnbuf;
udvp = UNIONFSVPTOUPPERVP(dvp);
vp = NULLVP;
error = unionfs_relookup(udvp, &vp, cnp, &cn, cnp->cn_nameptr,
error = unionfs_relookup(udvp, &vp, cnp, &cn, &pnbuf,
cnp->cn_nameptr,
strlen(cnp->cn_nameptr), CREATE);
if (error)
return (error);
@ -366,13 +373,9 @@ unionfs_relookup_for_create(struct vnode *dvp, struct componentname *cnp)
error = EEXIST;
}
if (cn.cn_flags & HASBUF) {
PNBUF_PUT(cn.cn_pnbuf);
cn.cn_flags &= ~HASBUF;
}
PNBUF_PUT(pnbuf);
if (!error) {
cn.cn_flags |= (cnp->cn_flags & HASBUF);
cnp->cn_flags = cn.cn_flags;
}
@ -391,11 +394,12 @@ unionfs_relookup_for_delete(struct vnode *dvp, struct componentname *cnp)
struct vnode *udvp;
struct vnode *vp;
struct componentname cn;
char *pnbuf;
udvp = UNIONFSVPTOUPPERVP(dvp);
vp = NULLVP;
error = unionfs_relookup(udvp, &vp, cnp, &cn, cnp->cn_nameptr,
error = unionfs_relookup(udvp, &vp, cnp, &cn, &pnbuf, cnp->cn_nameptr,
strlen(cnp->cn_nameptr), DELETE);
if (error)
return (error);
@ -409,13 +413,9 @@ unionfs_relookup_for_delete(struct vnode *dvp, struct componentname *cnp)
vput(vp);
}
if (cn.cn_flags & HASBUF) {
PNBUF_PUT(cn.cn_pnbuf);
cn.cn_flags &= ~HASBUF;
}
PNBUF_PUT(pnbuf);
if (!error) {
cn.cn_flags |= (cnp->cn_flags & HASBUF);
cnp->cn_flags = cn.cn_flags;
}
@ -434,11 +434,12 @@ unionfs_relookup_for_rename(struct vnode *dvp, struct componentname *cnp)
struct vnode *udvp;
struct vnode *vp;
struct componentname cn;
char *pnbuf;
udvp = UNIONFSVPTOUPPERVP(dvp);
vp = NULLVP;
error = unionfs_relookup(udvp, &vp, cnp, &cn, cnp->cn_nameptr,
error = unionfs_relookup(udvp, &vp, cnp, &cn, &pnbuf, cnp->cn_nameptr,
strlen(cnp->cn_nameptr), RENAME);
if (error)
return (error);
@ -450,13 +451,9 @@ unionfs_relookup_for_rename(struct vnode *dvp, struct componentname *cnp)
vput(vp);
}
if (cn.cn_flags & HASBUF) {
PNBUF_PUT(cn.cn_pnbuf);
cn.cn_flags &= ~HASBUF;
}
PNBUF_PUT(pnbuf);
if (!error) {
cn.cn_flags |= (cnp->cn_flags & HASBUF);
cnp->cn_flags = cn.cn_flags;
}
@ -505,6 +502,7 @@ unionfs_mkshadowdir(struct unionfs_mount *ump, struct vnode *udvp,
struct vattr va;
struct vattr lva;
struct componentname cn;
char *pnbuf;
if (unp->un_uppervp != NULLVP)
return (EEXIST);
@ -517,7 +515,8 @@ unionfs_mkshadowdir(struct unionfs_mount *ump, struct vnode *udvp,
if ((error = VOP_GETATTR(lvp, &lva, cnp->cn_cred)))
goto unionfs_mkshadowdir_abort;
if ((error = unionfs_relookup(udvp, &uvp, cnp, &cn, cnp->cn_nameptr, cnp->cn_namelen, CREATE)))
if ((error = unionfs_relookup(udvp, &uvp, cnp, &cn, &pnbuf,
cnp->cn_nameptr, cnp->cn_namelen, CREATE)))
goto unionfs_mkshadowdir_abort;
if (uvp != NULLVP) {
if (udvp == uvp)
@ -545,10 +544,7 @@ unionfs_mkshadowdir(struct unionfs_mount *ump, struct vnode *udvp,
}
unionfs_mkshadowdir_free_out:
if (cn.cn_flags & HASBUF) {
PNBUF_PUT(cn.cn_pnbuf);
cn.cn_flags &= ~HASBUF;
}
PNBUF_PUT(pnbuf);
unionfs_mkshadowdir_abort:
@ -566,18 +562,17 @@ unionfs_mkwhiteout(struct vnode *dvp, struct componentname *cnp, const char *pat
int error;
struct vnode *wvp;
struct componentname cn;
char *pnbuf;
if (path == NULL)
path = cnp->cn_nameptr;
wvp = NULLVP;
if ((error = unionfs_relookup(dvp, &wvp, cnp, &cn, path, strlen(path), CREATE)))
if ((error = unionfs_relookup(dvp, &wvp, cnp, &cn, &pnbuf,
path, strlen(path), CREATE)))
return (error);
if (wvp != NULLVP) {
if (cn.cn_flags & HASBUF) {
PNBUF_PUT(cn.cn_pnbuf);
cn.cn_flags &= ~HASBUF;
}
PNBUF_PUT(pnbuf);
if (dvp == wvp)
vrele(wvp);
else
@ -586,10 +581,7 @@ unionfs_mkwhiteout(struct vnode *dvp, struct componentname *cnp, const char *pat
return (EEXIST);
}
if (cn.cn_flags & HASBUF) {
PNBUF_PUT(cn.cn_pnbuf);
cn.cn_flags &= ~HASBUF;
}
PNBUF_PUT(pnbuf);
return (error);
}
@ -614,6 +606,7 @@ unionfs_vn_create_on_upper(struct vnode **vpp, struct vnode *udvp,
int fmode;
int error;
struct componentname cn;
char *pnbuf;
ump = MOUNTTOUNIONFSMOUNT(UNIONFSTOV(unp)->v_mount);
vp = NULLVP;
@ -630,12 +623,12 @@ unionfs_vn_create_on_upper(struct vnode **vpp, struct vnode *udvp,
panic("unionfs: un_path is null");
cn.cn_namelen = strlen(unp->un_path);
cn.cn_pnbuf = PNBUF_GET();
memcpy(cn.cn_pnbuf, unp->un_path, cn.cn_namelen + 1);
pnbuf = PNBUF_GET();
memcpy(pnbuf, unp->un_path, cn.cn_namelen + 1);
cn.cn_nameiop = CREATE;
cn.cn_flags = (LOCKPARENT | LOCKLEAF | HASBUF | SAVENAME | ISLASTCN);
cn.cn_cred = cred;
cn.cn_nameptr = cn.cn_pnbuf;
cn.cn_nameptr = pnbuf;
cn.cn_consume = 0;
vref(udvp);
@ -666,10 +659,7 @@ unionfs_vn_create_on_upper_free_out1:
VOP_UNLOCK(udvp);
unionfs_vn_create_on_upper_free_out2:
if (cn.cn_flags & HASBUF) {
PNBUF_PUT(cn.cn_pnbuf);
cn.cn_flags &= ~HASBUF;
}
PNBUF_PUT(pnbuf);
return (error);
}
@ -869,7 +859,6 @@ unionfs_check_rmdir(struct vnode *vp, kauth_cred_t cred)
continue;
cn.cn_namelen = dp->d_namlen;
cn.cn_pnbuf = NULL;
cn.cn_nameptr = dp->d_name;
cn.cn_nameiop = LOOKUP;
cn.cn_flags = (LOCKPARENT | LOCKLEAF | SAVENAME | RDONLY | ISLASTCN);

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_exec.c,v 1.301 2010/11/19 06:44:42 dholland Exp $ */
/* $NetBSD: kern_exec.c,v 1.302 2010/11/30 10:30:02 dholland Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -59,7 +59,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.301 2010/11/19 06:44:42 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.302 2010/11/30 10:30:02 dholland Exp $");
#include "opt_ktrace.h"
#include "opt_modular.h"
@ -292,14 +292,12 @@ check_exec(struct lwp *l, struct exec_package *epp, struct pathbuf *pb)
return error;
epp->ep_vp = vp = nd.ni_vp;
/* this cannot overflow as both are size PATH_MAX */
strcpy(epp->ep_resolvedname, nd.ni_cnd.cn_pnbuf);
strcpy(epp->ep_resolvedname, nd.ni_pnbuf);
/* dump this right away */
#ifdef DIAGNOSTIC
/* paranoia (take this out once namei stuff stabilizes) */
memset(nd.ni_cnd.cn_pnbuf, '~', PATH_MAX);
memset(nd.ni_pnbuf, '~', PATH_MAX);
#endif
PNBUF_PUT(nd.ni_cnd.cn_pnbuf);
/* check access and type */
if (vp->v_type != VREG) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: vfs_getcwd.c,v 1.46 2010/07/21 09:01:36 hannken Exp $ */
/* $NetBSD: vfs_getcwd.c,v 1.47 2010/11/30 10:30:02 dholland Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vfs_getcwd.c,v 1.46 2010/07/21 09:01:36 hannken Exp $");
__KERNEL_RCSID(0, "$NetBSD: vfs_getcwd.c,v 1.47 2010/11/30 10:30:02 dholland Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -128,7 +128,6 @@ getcwd_scandir(struct vnode **lvpp, struct vnode **uvpp, char **bpp,
cn.cn_nameiop = LOOKUP;
cn.cn_flags = ISLASTCN | ISDOTDOT | RDONLY;
cn.cn_cred = cred;
cn.cn_pnbuf = NULL;
cn.cn_nameptr = "..";
cn.cn_namelen = 2;
cn.cn_hash = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: vfs_lookup.c,v 1.123 2010/11/19 06:44:43 dholland Exp $ */
/* $NetBSD: vfs_lookup.c,v 1.124 2010/11/30 10:30:02 dholland Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.123 2010/11/19 06:44:43 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.124 2010/11/30 10:30:02 dholland Exp $");
#include "opt_magiclinks.h"
@ -235,6 +235,21 @@ pathbuf_destroy(struct pathbuf *pb)
kmem_free(pb, sizeof(*pb));
}
struct pathbuf *
pathbuf_assimilate(char *pnbuf)
{
struct pathbuf *pb;
pb = kmem_alloc(sizeof(*pb), KM_SLEEP);
if (pb == NULL) {
return NULL;
}
pb->pb_path = pnbuf;
pb->pb_pathcopy = NULL;
pb->pb_pathcopyuses = 0;
return pb;
}
struct pathbuf *
pathbuf_create(const char *path)
{
@ -430,12 +445,12 @@ namei_start1(struct namei_state *state)
panic("namei: flags contaminated with nameiops");
#endif
KASSERT((state->cnp->cn_flags & HASBUF) == 0);
/*
* Get a buffer for the name to be translated, and copy the
* name into the buffer.
* The buffer for name translation shall be the one inside the
* pathbuf.
*/
if ((state->cnp->cn_flags & HASBUF) == 0)
state->cnp->cn_pnbuf = PNBUF_GET();
state->ndp->ni_pnbuf = state->ndp->ni_pathbuf->pb_path;
}
/*
@ -451,17 +466,18 @@ namei_start2(struct namei_state *state)
struct cwdinfo *cwdi; /* pointer to cwd state */
struct lwp *self = curlwp; /* thread doing namei() */
#if 0 /* not any more */
/* as both buffers are size PATH_MAX this cannot overflow */
strcpy(cnp->cn_pnbuf, ndp->ni_pathbuf->pb_path);
#endif
/* length includes null terminator (was originally from copyinstr) */
ndp->ni_pathlen = strlen(cnp->cn_pnbuf) + 1;
ndp->ni_pathlen = strlen(ndp->ni_pnbuf) + 1;
/*
* POSIX.1 requirement: "" is not a valid file name.
*/
if (ndp->ni_pathlen == 1) {
PNBUF_PUT(cnp->cn_pnbuf);
ndp->ni_vp = NULL;
return ENOENT;
}
@ -481,16 +497,16 @@ namei_start2(struct namei_state *state)
/*
* Check if starting from root directory or current directory.
*/
if (cnp->cn_pnbuf[0] == '/') {
if (ndp->ni_pnbuf[0] == '/') {
if (cnp->cn_flags & TRYEMULROOT) {
if (cnp->cn_flags & EMULROOTSET) {
/* Called from (eg) emul_find_interp() */
state->namei_startdir = ndp->ni_erootdir;
} else {
if (cwdi->cwdi_edir == NULL
|| (cnp->cn_pnbuf[1] == '.'
&& cnp->cn_pnbuf[2] == '.'
&& cnp->cn_pnbuf[3] == '/')) {
|| (ndp->ni_pnbuf[1] == '.'
&& ndp->ni_pnbuf[2] == '.'
&& ndp->ni_pnbuf[3] == '/')) {
ndp->ni_erootdir = NULL;
} else {
state->namei_startdir = cwdi->cwdi_edir;
@ -528,9 +544,9 @@ namei_start2(struct namei_state *state)
else
emul_path = self->l_proc->p_emul->e_path;
ktrnamei2(emul_path, strlen(emul_path),
cnp->cn_pnbuf, ndp->ni_pathlen);
ndp->ni_pnbuf, ndp->ni_pathlen);
} else
ktrnamei(cnp->cn_pnbuf, ndp->ni_pathlen);
ktrnamei(ndp->ni_pnbuf, ndp->ni_pathlen);
}
vn_lock(state->namei_startdir, LK_EXCLUSIVE | LK_RETRY);
@ -546,8 +562,6 @@ static void
namei_end(struct namei_state *state)
{
vput(state->namei_startdir);
PNBUF_PUT(state->cnp->cn_pnbuf);
//state->cnp->cn_pnbuf = NULL; // not yet (just in case) (XXX)
}
/*
@ -583,10 +597,9 @@ namei_follow(struct namei_state *state)
if (error != 0)
return error;
}
if (ndp->ni_pathlen > 1)
cp = PNBUF_GET();
else
cp = cnp->cn_pnbuf;
/* FUTURE: fix this to not use a second buffer */
cp = PNBUF_GET();
aiov.iov_base = cp;
aiov.iov_len = MAXPATHLEN;
auio.uio_iov = &aiov;
@ -597,15 +610,13 @@ namei_follow(struct namei_state *state)
UIO_SETUP_SYSSPACE(&auio);
error = VOP_READLINK(ndp->ni_vp, &auio, cnp->cn_cred);
if (error) {
badlink:
if (ndp->ni_pathlen > 1)
PNBUF_PUT(cp);
PNBUF_PUT(cp);
return error;
}
linklen = MAXPATHLEN - auio.uio_resid;
if (linklen == 0) {
error = ENOENT;
goto badlink;
PNBUF_PUT(cp);
return ENOENT;
}
/*
@ -615,29 +626,32 @@ badlink:
if ((vfs_magiclinks &&
symlink_magic(self->l_proc, cp, &linklen)) ||
(linklen + ndp->ni_pathlen >= MAXPATHLEN)) {
error = ENAMETOOLONG;
goto badlink;
PNBUF_PUT(cp);
return ENAMETOOLONG;
}
if (ndp->ni_pathlen > 1) {
/* includes a null-terminator */
memcpy(cp + linklen, ndp->ni_next, ndp->ni_pathlen);
PNBUF_PUT(cnp->cn_pnbuf);
cnp->cn_pnbuf = cp;
} else
cnp->cn_pnbuf[linklen] = '\0';
} else {
cp[linklen] = '\0';
}
ndp->ni_pathlen += linklen;
memcpy(ndp->ni_pnbuf, cp, ndp->ni_pathlen);
PNBUF_PUT(cp);
vput(ndp->ni_vp);
state->namei_startdir = ndp->ni_dvp;
/*
* Check if root directory should replace current directory.
*/
if (cnp->cn_pnbuf[0] == '/') {
if (ndp->ni_pnbuf[0] == '/') {
vput(state->namei_startdir);
/* Keep absolute symbolic links inside emulation root */
state->namei_startdir = ndp->ni_erootdir;
if (state->namei_startdir == NULL || (cnp->cn_pnbuf[1] == '.'
&& cnp->cn_pnbuf[2] == '.'
&& cnp->cn_pnbuf[3] == '/')) {
if (state->namei_startdir == NULL ||
(ndp->ni_pnbuf[1] == '.'
&& ndp->ni_pnbuf[2] == '.'
&& ndp->ni_pnbuf[3] == '/')) {
ndp->ni_erootdir = NULL;
state->namei_startdir = ndp->ni_rootdir;
}
@ -657,15 +671,30 @@ do_namei(struct namei_state *state)
struct nameidata *ndp = state->ndp;
struct componentname *cnp = state->cnp;
const char *savepath = NULL;
KASSERT(cnp == &ndp->ni_cnd);
namei_start1(state);
if (cnp->cn_flags & TRYEMULROOT) {
savepath = pathbuf_stringcopy_get(ndp->ni_pathbuf);
}
emul_retry:
if (savepath != NULL) {
/* kinda gross */
strcpy(ndp->ni_pathbuf->pb_path, savepath);
pathbuf_stringcopy_put(ndp->ni_pathbuf, savepath);
savepath = NULL;
}
error = namei_start2(state);
if (error) {
if (savepath != NULL) {
pathbuf_stringcopy_put(ndp->ni_pathbuf, savepath);
}
return error;
}
@ -673,10 +702,13 @@ do_namei(struct namei_state *state)
for (;;) {
if (state->namei_startdir->v_mount == NULL) {
/* Give up if the directory is no longer mounted */
if (savepath != NULL) {
pathbuf_stringcopy_put(ndp->ni_pathbuf, savepath);
}
namei_end(state);
return (ENOENT);
}
cnp->cn_nameptr = cnp->cn_pnbuf;
cnp->cn_nameptr = ndp->ni_pnbuf;
ndp->ni_startdir = state->namei_startdir;
error = do_lookup(state);
if (error != 0) {
@ -689,7 +721,7 @@ do_namei(struct namei_state *state)
cnp->cn_flags &= ~TRYEMULROOT;
goto emul_retry;
}
PNBUF_PUT(cnp->cn_pnbuf);
KASSERT(savepath == NULL);
return (error);
}
@ -703,7 +735,9 @@ do_namei(struct namei_state *state)
vput(ndp->ni_dvp);
vput(ndp->ni_vp);
ndp->ni_vp = NULL;
PNBUF_PUT(cnp->cn_pnbuf);
if (savepath != NULL) {
pathbuf_stringcopy_put(ndp->ni_pathbuf, savepath);
}
return error;
}
}
@ -723,13 +757,9 @@ do_namei(struct namei_state *state)
vput(ndp->ni_dvp);
}
}
if ((cnp->cn_flags & (SAVENAME | SAVESTART)) == 0) {
PNBUF_PUT(cnp->cn_pnbuf);
#if defined(DIAGNOSTIC)
cnp->cn_pnbuf = NULL;
#endif /* defined(DIAGNOSTIC) */
} else {
cnp->cn_flags |= HASBUF;
if (savepath != NULL) {
pathbuf_stringcopy_put(ndp->ni_pathbuf, savepath);
}
return 0;
@ -1300,7 +1330,7 @@ lookup_for_nfsd(struct nameidata *ndp, struct vnode *dp, int neverfollow)
int linklen;
char *cp;
/* For now at least we don't have to frob the state */
ndp->ni_pnbuf = ndp->ni_pathbuf->pb_path;
namei_init(&state, ndp);
/*
@ -1312,7 +1342,7 @@ lookup_for_nfsd(struct nameidata *ndp, struct vnode *dp, int neverfollow)
for (;;) {
state.cnp->cn_nameptr = state.cnp->cn_pnbuf;
state.cnp->cn_nameptr = state.ndp->ni_pnbuf;
state.ndp->ni_startdir = dp;
/*
@ -1325,7 +1355,6 @@ lookup_for_nfsd(struct nameidata *ndp, struct vnode *dp, int neverfollow)
if (ndp->ni_dvp) {
vput(ndp->ni_dvp);
}
PNBUF_PUT(state.cnp->cn_pnbuf);
/* END from nfsd */
namei_cleanup(&state);
return error;
@ -1346,14 +1375,6 @@ lookup_for_nfsd(struct nameidata *ndp, struct vnode *dp, int neverfollow)
vput(state.ndp->ni_dvp);
}
}
if (state.cnp->cn_flags & (SAVENAME | SAVESTART)) {
state.cnp->cn_flags |= HASBUF;
} else {
PNBUF_PUT(state.cnp->cn_pnbuf);
#if defined(DIAGNOSTIC)
state.cnp->cn_pnbuf = NULL;
#endif /* defined(DIAGNOSTIC) */
}
return (0);
} else {
if (neverfollow) {
@ -1369,10 +1390,7 @@ lookup_for_nfsd(struct nameidata *ndp, struct vnode *dp, int neverfollow)
if (error != 0)
goto out;
}
if (state.ndp->ni_pathlen > 1)
cp = PNBUF_GET();
else
cp = state.cnp->cn_pnbuf;
cp = PNBUF_GET();
aiov.iov_base = cp;
aiov.iov_len = MAXPATHLEN;
auio.uio_iov = &aiov;
@ -1383,34 +1401,36 @@ lookup_for_nfsd(struct nameidata *ndp, struct vnode *dp, int neverfollow)
UIO_SETUP_SYSSPACE(&auio);
error = VOP_READLINK(ndp->ni_vp, &auio, state.cnp->cn_cred);
if (error) {
badlink:
if (ndp->ni_pathlen > 1)
PNBUF_PUT(cp);
PNBUF_PUT(cp);
goto out;
}
linklen = MAXPATHLEN - auio.uio_resid;
if (linklen == 0) {
PNBUF_PUT(cp);
error = ENOENT;
goto badlink;
goto out;
}
if (linklen + ndp->ni_pathlen >= MAXPATHLEN) {
PNBUF_PUT(cp);
error = ENAMETOOLONG;
goto badlink;
goto out;
}
if (ndp->ni_pathlen > 1) {
/* includes a null-terminator */
memcpy(cp + linklen, ndp->ni_next, ndp->ni_pathlen);
PNBUF_PUT(state.cnp->cn_pnbuf);
state.cnp->cn_pnbuf = cp;
} else
state.cnp->cn_pnbuf[linklen] = '\0';
} else {
cp[linklen] = '\0';
}
state.ndp->ni_pathlen += linklen;
memcpy(state.ndp->ni_pnbuf, cp, state.ndp->ni_pathlen);
PNBUF_PUT(cp);
vput(state.ndp->ni_vp);
dp = state.ndp->ni_dvp;
/*
* Check if root directory should replace current directory.
*/
if (state.cnp->cn_pnbuf[0] == '/') {
if (state.ndp->ni_pnbuf[0] == '/') {
vput(dp);
dp = ndp->ni_rootdir;
vref(dp);
@ -1423,7 +1443,6 @@ badlink:
vput(state.ndp->ni_vp);
vput(state.ndp->ni_dvp);
state.ndp->ni_vp = NULL;
PNBUF_PUT(state.cnp->cn_pnbuf);
/*
* END wodge of code from nfsd
@ -1439,7 +1458,9 @@ lookup_for_nfsd_index(struct nameidata *ndp)
struct namei_state state;
int error;
/* For now at least we don't have to frob the state */
ndp->ni_pnbuf = ndp->ni_pathbuf->pb_path;
ndp->ni_cnd.cn_nameptr = ndp->ni_pnbuf;
namei_init(&state, ndp);
error = do_lookup(&state);
namei_cleanup(&state);

View File

@ -1,4 +1,4 @@
/* $NetBSD: vfs_syscalls.c,v 1.409 2010/11/19 06:44:43 dholland Exp $ */
/* $NetBSD: vfs_syscalls.c,v 1.410 2010/11/30 10:30:02 dholland Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.409 2010/11/19 06:44:43 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.410 2010/11/30 10:30:02 dholland Exp $");
#ifdef _KERNEL_OPT
#include "opt_fileassoc.h"
@ -3599,11 +3599,9 @@ out:
vrele(fvp);
}
vrele(tond.ni_startdir);
PNBUF_PUT(tond.ni_cnd.cn_pnbuf);
out1:
if (fromnd.ni_startdir)
vrele(fromnd.ni_startdir);
PNBUF_PUT(fromnd.ni_cnd.cn_pnbuf);
pathbuf_destroy(frompb);
pathbuf_destroy(topb);
return (error == -1 ? 0 : error);

View File

@ -1,4 +1,4 @@
/* $NetBSD: genfs_vnops.c,v 1.183 2010/09/01 16:56:19 chs Exp $ */
/* $NetBSD: genfs_vnops.c,v 1.184 2010/11/30 10:30:02 dholland Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -57,7 +57,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.183 2010/09/01 16:56:19 chs Exp $");
__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.184 2010/11/30 10:30:02 dholland Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -121,8 +121,8 @@ genfs_abortop(void *v)
struct componentname *a_cnp;
} */ *ap = v;
if ((ap->a_cnp->cn_flags & (HASBUF | SAVESTART)) == HASBUF)
PNBUF_PUT(ap->a_cnp->cn_pnbuf);
(void)ap;
return (0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfs_serv.c,v 1.151 2010/06/24 13:03:17 hannken Exp $ */
/* $NetBSD: nfs_serv.c,v 1.152 2010/11/30 10:30:03 dholland Exp $ */
/*
* Copyright (c) 1989, 1993
@ -55,7 +55,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.151 2010/06/24 13:03:17 hannken Exp $");
__KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.152 2010/11/30 10:30:03 dholland Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -390,6 +390,7 @@ nfsrv_lookup(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *l
kauth_cred_t cred = nfsd->nd_cr;
struct nfs_fattr *fp;
struct nameidata nd, ind, *ndp = &nd;
struct pathbuf *ipb = NULL;
struct vnode *vp, *dirp;
nfsrvfh_t nsfh;
char *cp;
@ -416,7 +417,8 @@ nfsrv_lookup(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *l
&dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), pubflag);
if (!error && pubflag) {
if (nd.ni_vp->v_type == VDIR && nfs_pub.np_index != NULL) {
if (nd.ni_vp->v_type == VDIR && nfs_pub.np_index != NULL &&
(ipb = pathbuf_create(nfs_pub.np_index)) != NULL) {
/*
* Setup call to lookup() to see if we can find
* the index file. Arguably, this doesn't belong
@ -424,9 +426,10 @@ nfsrv_lookup(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *l
*/
ind = nd;
VOP_UNLOCK(nd.ni_vp);
ind.ni_pathbuf = ipb;
ind.ni_pathlen = strlen(nfs_pub.np_index);
ind.ni_cnd.cn_nameptr = ind.ni_cnd.cn_pnbuf =
nfs_pub.np_index;
ind.ni_pnbuf = NULL;
ind.ni_cnd.cn_nameptr = NULL;
ind.ni_startdir = nd.ni_vp;
vref(ind.ni_startdir);
error = lookup_for_nfsd_index(&ind);
@ -468,7 +471,10 @@ nfsrv_lookup(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *l
}
nqsrv_getl(ndp->ni_startdir, ND_READ);
PNBUF_PUT(nd.ni_cnd.cn_pnbuf);
pathbuf_destroy(nd.ni_pathbuf);
if (ipb != NULL) {
pathbuf_destroy(ipb);
}
vp = ndp->ni_vp;
error = nfsrv_composefh(vp, &nsfh, v3);
if (!error)
@ -1424,6 +1430,10 @@ nfsrv_create(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *l
nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft);
if (dirp)
vrele(dirp);
if (nd.ni_pathbuf != NULL) {
pathbuf_destroy(nd.ni_pathbuf);
nd.ni_pathbuf = NULL;
}
return (0);
}
abort = 1;
@ -1504,6 +1514,10 @@ nfsrv_create(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *l
vput(nd.ni_dvp);
abort = 0;
nfsm_reply(0);
if (nd.ni_pathbuf != NULL) {
pathbuf_destroy(nd.ni_pathbuf);
nd.ni_pathbuf = NULL;
}
return (error);
} else
va.va_rdev = (dev_t)rdev;
@ -1517,12 +1531,20 @@ nfsrv_create(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *l
vput(nd.ni_vp);
vrele(nd.ni_dvp);
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
if (nd.ni_pathbuf != NULL) {
pathbuf_destroy(nd.ni_pathbuf);
nd.ni_pathbuf = NULL;
}
error = EINVAL;
abort = 0;
nfsm_reply(0);
}
} else {
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
if (nd.ni_pathbuf != NULL) {
pathbuf_destroy(nd.ni_pathbuf);
nd.ni_pathbuf = NULL;
}
vput(nd.ni_dvp);
error = ENXIO;
abort = 0;
@ -1530,6 +1552,10 @@ nfsrv_create(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *l
vp = nd.ni_vp;
} else {
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
if (nd.ni_pathbuf != NULL) {
pathbuf_destroy(nd.ni_pathbuf);
nd.ni_pathbuf = NULL;
}
vp = nd.ni_vp;
if (nd.ni_dvp == vp)
vrele(nd.ni_dvp);
@ -1575,6 +1601,10 @@ nfsrv_create(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *l
vrele(dirp);
dirp = NULL;
}
if (nd.ni_pathbuf != NULL) {
pathbuf_destroy(nd.ni_pathbuf);
nd.ni_pathbuf = NULL;
}
abort = 0;
nfsm_reply(NFSX_SRVFH(&nsfh, v3) + NFSX_FATTR(v3) + NFSX_WCCDATA(v3));
if (v3) {
@ -1601,6 +1631,10 @@ nfsmout:
if (nd.ni_vp)
vput(nd.ni_vp);
}
if (nd.ni_pathbuf != NULL) {
pathbuf_destroy(nd.ni_pathbuf);
nd.ni_pathbuf = NULL;
}
return (error);
}
@ -1644,6 +1678,10 @@ nfsrv_mknod(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lw
nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft);
if (dirp)
vrele(dirp);
if (nd.ni_pathbuf != NULL) {
pathbuf_destroy(nd.ni_pathbuf);
nd.ni_pathbuf = NULL;
}
return (0);
}
abort = 1;
@ -1683,6 +1721,10 @@ abort:
vput(nd.ni_dvp);
if (nd.ni_vp)
vput(nd.ni_vp);
if (nd.ni_pathbuf != NULL) {
pathbuf_destroy(nd.ni_pathbuf);
nd.ni_pathbuf = NULL;
}
goto out;
}
va.va_type = vtyp;
@ -1720,6 +1762,10 @@ out:
vrele(dirp);
dirp = NULL;
}
if (nd.ni_pathbuf != NULL) {
pathbuf_destroy(nd.ni_pathbuf);
nd.ni_pathbuf = NULL;
}
abort = 0;
nfsm_reply(NFSX_SRVFH(&nsfh, true) + NFSX_POSTOPATTR(1) +
NFSX_WCCDATA(1));
@ -1739,6 +1785,10 @@ nfsmout:
if (nd.ni_vp)
vput(nd.ni_vp);
}
if (nd.ni_pathbuf != NULL) {
pathbuf_destroy(nd.ni_pathbuf);
nd.ni_pathbuf = NULL;
}
if (dirp)
vrele(dirp);
return (error);
@ -1806,6 +1856,10 @@ out:
vput(vp);
}
}
if (nd.ni_pathbuf != NULL) {
pathbuf_destroy(nd.ni_pathbuf);
nd.ni_pathbuf = NULL;
}
if (dirp) {
if (v3) {
diraft_ret = VOP_GETATTR(dirp, &diraft, cred);
@ -1875,6 +1929,7 @@ nfsrv_rename(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *l
nfsm_srvwcc_data(tdirfor_ret, &tdirfor, tdiraft_ret, &tdiraft);
if (fdirp)
vrele(fdirp);
pathbuf_destroy(fromnd.ni_pathbuf);
return (0);
}
if (fromnd.ni_dvp != fromnd.ni_vp) {
@ -2028,7 +2083,7 @@ out:
error = 0;
}
vrele(tond.ni_startdir);
PNBUF_PUT(tond.ni_cnd.cn_pnbuf);
pathbuf_destroy(tond.ni_pathbuf);
tond.ni_cnd.cn_nameiop = 0;
out1:
if (fdirp) {
@ -2046,7 +2101,7 @@ out1:
tdirp = NULL;
}
vrele(fromnd.ni_startdir);
PNBUF_PUT(fromnd.ni_cnd.cn_pnbuf);
pathbuf_destroy(fromnd.ni_pathbuf);
fromnd.ni_cnd.cn_nameiop = 0;
localfs = NULL;
nfsm_reply(2 * NFSX_WCCDATA(v3));
@ -2065,15 +2120,15 @@ nfsmout:
#endif
if (tond.ni_cnd.cn_nameiop) {
vrele(tond.ni_startdir);
PNBUF_PUT(tond.ni_cnd.cn_pnbuf);
pathbuf_destroy(tond.ni_pathbuf);
}
if (localfs) {
VFS_RENAMELOCK_EXIT(localfs);
}
if (fromnd.ni_cnd.cn_nameiop) {
vrele(fromnd.ni_startdir);
PNBUF_PUT(fromnd.ni_cnd.cn_pnbuf);
VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd);
pathbuf_destroy(fromnd.ni_pathbuf);
vrele(fromnd.ni_dvp);
vrele(fvp);
}
@ -2160,6 +2215,7 @@ out1:
vrele(dirp);
}
vrele(vp);
pathbuf_destroy(nd.ni_pathbuf);
nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3));
if (v3) {
nfsm_srvpostop_attr(getret, &at);
@ -2275,6 +2331,7 @@ out:
vrele(dirp);
dirp = NULL;
}
pathbuf_destroy(nd.ni_pathbuf);
abort = 0;
nfsm_reply(NFSX_SRVFH(&nsfh, v3) + NFSX_POSTOPATTR(v3) +
NFSX_WCCDATA(v3));
@ -2295,6 +2352,7 @@ nfsmout:
vput(nd.ni_dvp);
if (nd.ni_vp)
vrele(nd.ni_vp);
pathbuf_destroy(nd.ni_pathbuf);
}
if (dirp)
vrele(dirp);
@ -2340,6 +2398,9 @@ nfsrv_mkdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lw
dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred);
}
if (error) {
if (nd.ni_pathbuf != NULL) {
pathbuf_destroy(nd.ni_pathbuf);
}
nfsm_reply(NFSX_WCCDATA(v3));
nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft);
if (dirp)
@ -2384,6 +2445,7 @@ out:
vrele(dirp);
dirp = NULL;
}
pathbuf_destroy(nd.ni_pathbuf);
abort = 0;
nfsm_reply(NFSX_SRVFH(&nsfh, v3) + NFSX_POSTOPATTR(v3) +
NFSX_WCCDATA(v3));
@ -2408,6 +2470,7 @@ nfsmout:
vput(nd.ni_dvp);
if (nd.ni_vp)
vrele(nd.ni_vp);
pathbuf_destroy(nd.ni_pathbuf);
}
if (dirp)
vrele(dirp);
@ -2448,6 +2511,9 @@ nfsrv_rmdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lw
dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred);
}
if (error) {
if (nd.ni_pathbuf != NULL) {
pathbuf_destroy(nd.ni_pathbuf);
}
nfsm_reply(NFSX_WCCDATA(v3));
nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft);
if (dirp)
@ -2484,6 +2550,7 @@ out:
vput(nd.ni_dvp);
vput(vp);
}
pathbuf_destroy(nd.ni_pathbuf);
if (dirp) {
if (v3) {
diraft_ret = VOP_GETATTR(dirp, &diraft, cred);

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfs_srvsubs.c,v 1.7 2010/11/19 06:44:46 dholland Exp $ */
/* $NetBSD: nfs_srvsubs.c,v 1.8 2010/11/30 10:30:03 dholland Exp $ */
/*
* Copyright (c) 1989, 1993
@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nfs_srvsubs.c,v 1.7 2010/11/19 06:44:46 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: nfs_srvsubs.c,v 1.8 2010/11/30 10:30:03 dholland Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@ -120,26 +120,27 @@ nfs_namei(struct nameidata *ndp, nfsrvfh_t *nsfh, uint32_t len, struct nfssvc_so
{
int i, rem;
struct mbuf *md;
char *fromcp, *tocp, *cp;
char *fromcp, *tocp, *cp, *path;
struct vnode *dp;
int error, rdonly;
int neverfollow;
struct componentname *cnp = &ndp->ni_cnd;
*retdirp = NULL;
ndp->ni_pathbuf = NULL;
if ((len + 1) > MAXPATHLEN)
return (ENAMETOOLONG);
if (len == 0)
return (EACCES);
cnp->cn_pnbuf = PNBUF_GET();
/*
* Copy the name from the mbuf list to ndp->ni_pnbuf
* Copy the name from the mbuf list to ndp->ni_pathbuf
* and set the various ndp fields appropriately.
*/
path = PNBUF_GET();
fromcp = *dposp;
tocp = cnp->cn_pnbuf;
tocp = path;
md = *mdp;
rem = mtod(md, char *) + md->m_len - fromcp;
for (i = 0; i < len; i++) {
@ -194,7 +195,7 @@ nfs_namei(struct nameidata *ndp, nfsrvfh_t *nsfh, uint32_t len, struct nfssvc_so
* and the 'native path' indicator.
*/
cp = PNBUF_GET();
fromcp = cnp->cn_pnbuf;
fromcp = path;
tocp = cp;
if ((unsigned char)*fromcp >= WEBNFS_SPECCHAR_START) {
switch ((unsigned char)*fromcp) {
@ -236,18 +237,23 @@ nfs_namei(struct nameidata *ndp, nfsrvfh_t *nsfh, uint32_t len, struct nfssvc_so
*tocp++ = *fromcp++;
}
*tocp = '\0';
PNBUF_PUT(cnp->cn_pnbuf);
cnp->cn_pnbuf = cp;
PNBUF_PUT(path);
path = cp;
}
ndp->ni_pathlen = (tocp - cnp->cn_pnbuf) + 1;
ndp->ni_pathbuf = pathbuf_assimilate(path);
if (ndp->ni_pathbuf == NULL) {
error = ENOMEM;
goto out;
}
ndp->ni_pathlen = (tocp - path) + 1;
/*ndp->ni_segflg = UIO_SYSSPACE; - obsolete */
ndp->ni_rootdir = rootvnode;
ndp->ni_erootdir = NULL;
if (pubflag) {
ndp->ni_loopcnt = 0;
if (cnp->cn_pnbuf[0] == '/')
if (path[0] == '/')
dp = rootvnode;
} else {
cnp->cn_flags |= NOCROSSMOUNT;
@ -257,6 +263,9 @@ nfs_namei(struct nameidata *ndp, nfsrvfh_t *nsfh, uint32_t len, struct nfssvc_so
/*
* And call lookup() to do the real work
*
* Note: ndp->ni_pathbuf is left undestroyed; caller must
* clean it up.
*/
error = lookup_for_nfsd(ndp, dp, neverfollow);
if (error) {
@ -265,7 +274,11 @@ nfs_namei(struct nameidata *ndp, nfsrvfh_t *nsfh, uint32_t len, struct nfssvc_so
return 0;
out:
PNBUF_PUT(cnp->cn_pnbuf);
if (ndp->ni_pathbuf != NULL) {
pathbuf_destroy(ndp->ni_pathbuf);
} else {
PNBUF_PUT(path);
}
return (error);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfs_vnops.c,v 1.285 2010/10/26 11:44:53 cegger Exp $ */
/* $NetBSD: nfs_vnops.c,v 1.286 2010/11/30 10:30:03 dholland Exp $ */
/*
* Copyright (c) 1989, 1993
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.285 2010/10/26 11:44:53 cegger Exp $");
__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.286 2010/11/30 10:30:03 dholland Exp $");
#ifdef _KERNEL_OPT
#include "opt_nfs.h"
@ -1568,7 +1568,6 @@ nfs_mknodrpc(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp, s
nfs_cache_enter(dvp, newvp, cnp);
*vpp = newvp;
}
PNBUF_PUT(cnp->cn_pnbuf);
VTONFS(dvp)->n_flag |= NMODIFIED;
if (!wccflag)
NFS_INVALIDATE_ATTRCACHE(VTONFS(dvp));
@ -1732,7 +1731,6 @@ again:
if (error == EEXIST)
cache_purge1(dvp, cnp, 0);
}
PNBUF_PUT(cnp->cn_pnbuf);
VTONFS(dvp)->n_flag |= NMODIFIED;
if (!wccflag)
NFS_INVALIDATE_ATTRCACHE(VTONFS(dvp));
@ -1798,7 +1796,6 @@ nfs_remove(void *v)
cnp->cn_namelen, cnp->cn_cred, curlwp);
} else if (!np->n_sillyrename)
error = nfs_sillyrename(dvp, vp, cnp, false);
PNBUF_PUT(cnp->cn_pnbuf);
if (!error && nfs_getattrcache(vp, &vattr) == 0 &&
vattr.va_nlink == 1) {
np->n_flag |= NREMOVED;
@ -2102,7 +2099,6 @@ nfs_link(void *v)
if (error == 0)
cache_purge1(dvp, cnp, 0);
PNBUF_PUT(cnp->cn_pnbuf);
if (dvp != vp)
VOP_UNLOCK(vp);
VN_KNOTE(vp, NOTE_LINK);
@ -2193,7 +2189,6 @@ nfs_symlink(void *v)
} else {
*ap->a_vpp = newvp;
}
PNBUF_PUT(cnp->cn_pnbuf);
VTONFS(dvp)->n_flag |= NMODIFIED;
if (!wccflag)
NFS_INVALIDATE_ATTRCACHE(VTONFS(dvp));
@ -2290,7 +2285,6 @@ nfs_mkdir(void *v)
nfs_cache_enter(dvp, newvp, cnp);
*ap->a_vpp = newvp;
}
PNBUF_PUT(cnp->cn_pnbuf);
vput(dvp);
return (error);
}
@ -2326,7 +2320,6 @@ nfs_rmdir(void *v)
if (dvp == vp) {
vrele(dvp);
vput(dvp);
PNBUF_PUT(cnp->cn_pnbuf);
return (EINVAL);
}
nfsstats.rpccnt[NFSPROC_RMDIR]++;
@ -2341,7 +2334,6 @@ nfs_rmdir(void *v)
nfsm_wcc_data(dvp, wccflag, 0, !error);
#endif
nfsm_reqdone;
PNBUF_PUT(cnp->cn_pnbuf);
VTONFS(dvp)->n_flag |= NMODIFIED;
if (!wccflag)
NFS_INVALIDATE_ATTRCACHE(VTONFS(dvp));

View File

@ -1,4 +1,4 @@
/* $NetBSD: namei.src,v 1.15 2010/11/19 06:44:34 dholland Exp $ */
/* $NetBSD: namei.src,v 1.16 2010/11/30 10:29:57 dholland Exp $ */
/*
* Copyright (c) 1985, 1989, 1991, 1993
@ -52,10 +52,17 @@
* STRUCT NAMEIDATA IS DEAD, call pathbuf_destroy. Don't destroy the
* pathbuf before you've finished using the nameidata, or mysterious
* bad things may happen.
*
* pathbuf_assimilate is like pathbuf_create but assumes ownership of
* the string buffer passed in, which MUST BE of size PATH_MAX and
* have been allocated with PNBUF_GET(). This should only be used when
* absolutely necessary; e.g. nfsd uses it for loading paths from
* mbufs.
*/
struct pathbuf;
struct pathbuf *pathbuf_create(const char *path);
struct pathbuf *pathbuf_assimilate(char *path);
int pathbuf_copyin(const char *userpath, struct pathbuf **ret);
void pathbuf_destroy(struct pathbuf *);
@ -77,8 +84,7 @@ struct nameidata {
* Arguments to namei/lookup.
*/
struct pathbuf *ni_pathbuf; /* pathname container */
//const char *ni_dirp; /* pathname pointer */
//enum uio_seg ni_segflg; /* location of pathname */
char *ni_pnbuf; /* extra pathname buffer ref (XXX) */
/*
* Arguments to lookup.
*/
@ -111,7 +117,6 @@ struct nameidata {
/*
* Shared between lookup and commit routines.
*/
char *cn_pnbuf; /* pathname buffer */
const char *cn_nameptr; /* pointer to looked up name */
size_t cn_namelen; /* length of looked up comp */
u_long cn_hash; /* hash val of looked up name */

View File

@ -1,4 +1,4 @@
/* $NetBSD: ext2fs_vnops.c,v 1.94 2010/07/28 11:03:48 hannken Exp $ */
/* $NetBSD: ext2fs_vnops.c,v 1.95 2010/11/30 10:30:03 dholland Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.94 2010/07/28 11:03:48 hannken Exp $");
__KERNEL_RCSID(0, "$NetBSD: ext2fs_vnops.c,v 1.95 2010/11/30 10:30:03 dholland Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -606,7 +606,6 @@ ext2fs_link(void *v)
ip->i_e2fs_nlink--;
ip->i_flag |= IN_CHANGE;
}
PNBUF_PUT(cnp->cn_pnbuf);
out1:
if (dvp != vp)
VOP_UNLOCK(vp);
@ -1165,7 +1164,6 @@ bad:
*ap->a_vpp = tvp;
}
out:
PNBUF_PUT(cnp->cn_pnbuf);
vput(dvp);
return (error);
}
@ -1436,7 +1434,6 @@ ext2fs_makeinode(int mode, struct vnode *dvp, struct vnode **vpp,
mode |= IFREG;
if ((error = ext2fs_valloc(dvp, mode, cnp->cn_cred, &tvp)) != 0) {
PNBUF_PUT(cnp->cn_pnbuf);
vput(dvp);
return (error);
}
@ -1469,8 +1466,6 @@ ext2fs_makeinode(int mode, struct vnode *dvp, struct vnode **vpp,
error = ext2fs_direnter(ip, dvp, cnp);
if (error != 0)
goto bad;
if ((cnp->cn_flags & SAVESTART) == 0)
PNBUF_PUT(cnp->cn_pnbuf);
vput(dvp);
*vpp = tvp;
return (0);
@ -1484,7 +1479,6 @@ bad:
ip->i_e2fs_nlink = 0;
ip->i_flag |= IN_CHANGE;
vput(tvp);
PNBUF_PUT(cnp->cn_pnbuf);
vput(dvp);
return (error);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ufs_extattr.c,v 1.27 2010/06/24 13:03:20 hannken Exp $ */
/* $NetBSD: ufs_extattr.c,v 1.28 2010/11/30 10:30:04 dholland Exp $ */
/*-
* Copyright (c) 1999-2002 Robert N. M. Watson
@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ufs_extattr.c,v 1.27 2010/06/24 13:03:20 hannken Exp $");
__KERNEL_RCSID(0, "$NetBSD: ufs_extattr.c,v 1.28 2010/11/30 10:30:04 dholland Exp $");
#ifdef _KERNEL_OPT
#include "opt_ffs.h"
@ -258,23 +258,24 @@ ufs_extattr_lookup(struct vnode *start_dvp, int lockparent, const char *dirname,
struct vop_lookup_args vargs;
struct componentname cnp;
struct vnode *target_vp;
char *pnbuf;
int error;
KASSERT(VOP_ISLOCKED(start_dvp) == LK_EXCLUSIVE);
pnbuf = PNBUF_GET();
memset(&cnp, 0, sizeof(cnp));
cnp.cn_nameiop = LOOKUP;
cnp.cn_flags = ISLASTCN | lockparent;
cnp.cn_cred = l->l_cred;
cnp.cn_pnbuf = PNBUF_GET();
cnp.cn_nameptr = cnp.cn_pnbuf;
error = copystr(dirname, cnp.cn_pnbuf, MAXPATHLEN,
(size_t *) &cnp.cn_namelen);
cnp.cn_nameptr = pnbuf;
error = copystr(dirname, pnbuf, MAXPATHLEN, &cnp.cn_namelen);
if (error) {
if (lockparent == 0) {
VOP_UNLOCK(start_dvp);
}
PNBUF_PUT(cnp.cn_pnbuf);
PNBUF_PUT(pnbuf);
printf("ufs_extattr_lookup: copystr failed\n");
return (error);
}
@ -284,7 +285,7 @@ ufs_extattr_lookup(struct vnode *start_dvp, int lockparent, const char *dirname,
vargs.a_vpp = &target_vp;
vargs.a_cnp = &cnp;
error = ufs_lookup(&vargs);
PNBUF_PUT(cnp.cn_pnbuf);
PNBUF_PUT(pnbuf);
if (error) {
VOP_UNLOCK(start_dvp);
return (error);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ufs_vnops.c,v 1.183 2010/06/24 13:03:20 hannken Exp $ */
/* $NetBSD: ufs_vnops.c,v 1.184 2010/11/30 10:30:04 dholland Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.183 2010/06/24 13:03:20 hannken Exp $");
__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.184 2010/11/30 10:30:04 dholland Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ffs.h"
@ -855,7 +855,6 @@ ufs_link(void *v)
ip->i_flag |= IN_CHANGE;
UFS_WAPBL_UPDATE(vp, NULL, NULL, UPDATE_DIROP);
}
PNBUF_PUT(cnp->cn_pnbuf);
UFS_WAPBL_END(vp->v_mount);
out1:
if (dvp != vp)
@ -929,10 +928,6 @@ ufs_whiteout(void *v)
panic("ufs_whiteout: unknown op");
/* NOTREACHED */
}
if (cnp->cn_flags & HASBUF) {
PNBUF_PUT(cnp->cn_pnbuf);
cnp->cn_flags &= ~HASBUF;
}
fstrans_done(dvp->v_mount);
return (error);
}
@ -1399,7 +1394,6 @@ ufs_mkdir(void *v)
DIP_ASSIGN(ip, gid, ip->i_gid);
#ifdef QUOTA
if ((error = chkiq(ip, 1, cnp->cn_cred, 0))) {
PNBUF_PUT(cnp->cn_pnbuf);
UFS_VFREE(tvp, ip->i_number, dmode);
UFS_WAPBL_END(dvp->v_mount);
fstrans_done(dvp->v_mount);
@ -1500,7 +1494,6 @@ ufs_mkdir(void *v)
vput(tvp);
}
out:
PNBUF_PUT(cnp->cn_pnbuf);
fstrans_done(dvp->v_mount);
vput(dvp);
return (error);
@ -2192,7 +2185,6 @@ ufs_makeinode(int mode, struct vnode *dvp, struct vnode **vpp,
mode |= IFREG;
if ((error = UFS_VALLOC(dvp, mode, cnp->cn_cred, vpp)) != 0) {
PNBUF_PUT(cnp->cn_pnbuf);
vput(dvp);
return (error);
}
@ -2210,7 +2202,6 @@ ufs_makeinode(int mode, struct vnode *dvp, struct vnode **vpp,
* the vnode dangling from the journal.
*/
vput(tvp);
PNBUF_PUT(cnp->cn_pnbuf);
vput(dvp);
return (error);
}
@ -2219,7 +2210,6 @@ ufs_makeinode(int mode, struct vnode *dvp, struct vnode **vpp,
UFS_VFREE(tvp, ip->i_number, mode);
UFS_WAPBL_END1(dvp->v_mount, dvp);
vput(tvp);
PNBUF_PUT(cnp->cn_pnbuf);
vput(dvp);
return (error);
}
@ -2253,8 +2243,6 @@ ufs_makeinode(int mode, struct vnode *dvp, struct vnode **vpp,
pool_cache_put(ufs_direct_cache, newdir);
if (error)
goto bad;
if ((cnp->cn_flags & SAVESTART) == 0)
PNBUF_PUT(cnp->cn_pnbuf);
vput(dvp);
*vpp = tvp;
return (0);
@ -2273,7 +2261,6 @@ ufs_makeinode(int mode, struct vnode *dvp, struct vnode **vpp,
tvp->v_type = VNON; /* explodes later if VBLK */
UFS_WAPBL_END1(dvp->v_mount, dvp);
vput(tvp);
PNBUF_PUT(cnp->cn_pnbuf);
vput(dvp);
return (error);
}