SCCS-vsn: sys/kern/vfs_syscalls.c 7.78
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)vfs_syscalls.c 7.77 (Berkeley) %G%
+ * @(#)vfs_syscalls.c 7.78 (Berkeley) %G%
#include "uio.h"
#include "malloc.h"
#include "uio.h"
#include "malloc.h"
-/* NEEDSWORK: debugging */
-#define CURCOUNT (curproc?curproc->p_spare[2]:0)
-#define CHECKPOINT int oldrefcount=CURCOUNT;
-#define CHECKCHECK(F) if (oldrefcount!=CURCOUNT) { printf("REFCOUNT: %s, old=%d, new=%d\n", (F), oldrefcount, CURCOUNT); }
-
/*
* Virtual File System System Calls
*/
/*
* Virtual File System System Calls
*/
- register struct nameidata *ndp;
register struct vnode *vp;
register struct mount *mp;
int error, flag;
register struct vnode *vp;
register struct mount *mp;
int error, flag;
/*
* Get vnode to be covered
*/
/*
* Get vnode to be covered
*/
- ndp = &nd;
- ndp->ni_nameiop = LOOKUP | FOLLOW | LOCKLEAF;
- ndp->ni_segflg = UIO_USERSPACE;
- ndp->ni_dirp = uap->dir;
- if (error = namei(ndp, p))
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->dir, p);
+ if (error = namei(&nd))
if (uap->flags & MNT_UPDATE) {
if ((vp->v_flag & VROOT) == 0) {
vput(vp);
if (uap->flags & MNT_UPDATE) {
if ((vp->v_flag & VROOT) == 0) {
vput(vp);
/*
* Mount the filesystem.
*/
/*
* Mount the filesystem.
*/
- error = VFS_MOUNT(mp, uap->dir, uap->data, ndp, p);
+ error = VFS_MOUNT(mp, uap->dir, uap->data, &nd, p);
if (mp->mnt_flag & MNT_UPDATE) {
mp->mnt_flag &= ~MNT_UPDATE;
vrele(vp);
if (mp->mnt_flag & MNT_UPDATE) {
mp->mnt_flag &= ~MNT_UPDATE;
vrele(vp);
int *retval;
{
register struct vnode *vp;
int *retval;
{
register struct vnode *vp;
- register struct nameidata *ndp;
struct mount *mp;
int error;
struct nameidata nd;
struct mount *mp;
int error;
struct nameidata nd;
if (error = suser(p->p_ucred, &p->p_acflag))
return (error);
if (error = suser(p->p_ucred, &p->p_acflag))
return (error);
- ndp = &nd;
- ndp->ni_nameiop = LOOKUP | LOCKLEAF | FOLLOW;
- ndp->ni_segflg = UIO_USERSPACE;
- ndp->ni_dirp = uap->pathp;
- if (error = namei(ndp, p))
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->pathp, p);
+ if (error = namei(&nd))
/*
* Must be the root of the filesystem
*/
/*
* Must be the root of the filesystem
*/
int *retval;
{
register struct mount *mp;
int *retval;
{
register struct mount *mp;
- register struct nameidata *ndp;
int error;
struct nameidata nd;
int error;
struct nameidata nd;
- ndp = &nd;
- ndp->ni_nameiop = LOOKUP | FOLLOW;
- ndp->ni_segflg = UIO_USERSPACE;
- ndp->ni_dirp = uap->path;
- if (error = namei(ndp, p))
+ NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
+ if (error = namei(&nd))
- mp = ndp->ni_vp->v_mount;
- vrele(ndp->ni_vp);
+ mp = nd.ni_vp->v_mount;
+ vrele(nd.ni_vp);
return (VFS_QUOTACTL(mp, uap->cmd, uap->uid, uap->arg, p));
}
return (VFS_QUOTACTL(mp, uap->cmd, uap->uid, uap->arg, p));
}
int *retval;
{
register struct mount *mp;
int *retval;
{
register struct mount *mp;
- register struct nameidata *ndp;
register struct statfs *sp;
int error;
struct nameidata nd;
register struct statfs *sp;
int error;
struct nameidata nd;
- ndp = &nd;
- ndp->ni_nameiop = LOOKUP | FOLLOW;
- ndp->ni_segflg = UIO_USERSPACE;
- ndp->ni_dirp = uap->path;
- if (error = namei(ndp, p))
+ NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
+ if (error = namei(&nd))
- mp = ndp->ni_vp->v_mount;
+ mp = nd.ni_vp->v_mount;
if (error = VFS_STATFS(mp, sp, p))
return (error);
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
if (error = VFS_STATFS(mp, sp, p))
return (error);
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
- register struct nameidata *ndp;
register struct filedesc *fdp = p->p_fd;
int error;
struct nameidata nd;
register struct filedesc *fdp = p->p_fd;
int error;
struct nameidata nd;
- ndp = &nd;
- ndp->ni_nameiop = LOOKUP | FOLLOW | LOCKLEAF;
- ndp->ni_segflg = UIO_USERSPACE;
- ndp->ni_dirp = uap->fname;
- if (error = chdirec(ndp, p))
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->fname, p);
+ if (error = chdirec(&nd))
return (error);
vrele(fdp->fd_cdir);
return (error);
vrele(fdp->fd_cdir);
- fdp->fd_cdir = ndp->ni_vp;
+ fdp->fd_cdir = nd.ni_vp;
- register struct nameidata *ndp;
register struct filedesc *fdp = p->p_fd;
int error;
struct nameidata nd;
if (error = suser(p->p_ucred, &p->p_acflag))
return (error);
register struct filedesc *fdp = p->p_fd;
int error;
struct nameidata nd;
if (error = suser(p->p_ucred, &p->p_acflag))
return (error);
- ndp = &nd;
- ndp->ni_nameiop = LOOKUP | FOLLOW | LOCKLEAF;
- ndp->ni_segflg = UIO_USERSPACE;
- ndp->ni_dirp = uap->fname;
- if (error = chdirec(ndp, p))
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->fname, p);
+ if (error = chdirec(&nd))
return (error);
if (fdp->fd_rdir != NULL)
vrele(fdp->fd_rdir);
return (error);
if (fdp->fd_rdir != NULL)
vrele(fdp->fd_rdir);
- fdp->fd_rdir = ndp->ni_vp;
+ fdp->fd_rdir = nd.ni_vp;
* Common routine for chroot and chdir.
*/
chdirec(ndp, p)
* Common routine for chroot and chdir.
*/
chdirec(ndp, p)
+ register struct nameidata *ndp;
struct proc *p;
{
struct vnode *vp;
int error;
struct proc *p;
{
struct vnode *vp;
int error;
- if (error = namei(ndp, p))
+ if (error = namei(ndp))
return (error);
vp = ndp->ni_vp;
if (vp->v_type != VDIR)
return (error);
vp = ndp->ni_vp;
if (vp->v_type != VDIR)
register struct filedesc *fdp = p->p_fd;
register struct file *fp;
register struct vnode *vp;
register struct filedesc *fdp = p->p_fd;
register struct file *fp;
register struct vnode *vp;
fp = nfp;
fmode = FFLAGS(uap->mode);
cmode = ((uap->crtmode &~ fdp->fd_cmask) & 07777) &~ S_ISVTX;
fp = nfp;
fmode = FFLAGS(uap->mode);
cmode = ((uap->crtmode &~ fdp->fd_cmask) & 07777) &~ S_ISVTX;
- ndp = &nd;
- ndp->ni_segflg = UIO_USERSPACE;
- ndp->ni_dirp = uap->fname;
+ NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->fname, p);
p->p_dupfd = -indx - 1; /* XXX check for fdopen */
p->p_dupfd = -indx - 1; /* XXX check for fdopen */
- if (error = vn_open(ndp, p, fmode, cmode)) {
+ if (error = vn_open(&nd, fmode, cmode)) {
ffree(fp);
if (error == ENODEV && /* XXX from fdopen */
p->p_dupfd >= 0 &&
ffree(fp);
if (error == ENODEV && /* XXX from fdopen */
p->p_dupfd >= 0 &&
fdp->fd_ofiles[indx] = NULL;
return (error);
}
fdp->fd_ofiles[indx] = NULL;
return (error);
}
fp->f_flag = fmode & FMASK;
if (fmode & (O_EXLOCK | O_SHLOCK)) {
lf.l_whence = SEEK_SET;
fp->f_flag = fmode & FMASK;
if (fmode & (O_EXLOCK | O_SHLOCK)) {
lf.l_whence = SEEK_SET;
- register struct nameidata *ndp;
register struct vnode *vp;
struct vattr vattr;
int error;
struct nameidata nd;
register struct vnode *vp;
struct vattr vattr;
int error;
struct nameidata nd;
if (error = suser(p->p_ucred, &p->p_acflag))
return (error);
if (error = suser(p->p_ucred, &p->p_acflag))
return (error);
- ndp = &nd;
- ndp->ni_nameiop = CREATE | LOCKPARENT;
- ndp->ni_segflg = UIO_USERSPACE;
- ndp->ni_dirp = uap->fname;
- if (error = namei(ndp, p))
+ NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->fname, p);
+ if (error = namei(&nd))
if (vp != NULL) {
error = EEXIST;
goto out;
if (vp != NULL) {
error = EEXIST;
goto out;
vattr.va_rdev = uap->dev;
out:
if (!error) {
vattr.va_rdev = uap->dev;
out:
if (!error) {
- LEASE_CHECK(ndp->ni_dvp, p, p->p_ucred, LEASE_WRITE);
- error = VOP_MKNOD(ndp->ni_dvp, &ndp->ni_vp, &ndp->ni_cnd, &vattr);
+ LEASE_CHECK(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
+ error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr);
- VOP_ABORTOP(ndp->ni_dvp, &ndp->ni_cnd);
- if (ndp->ni_dvp == vp)
- vrele(ndp->ni_dvp);
+ VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
+ if (nd.ni_dvp == vp)
+ vrele(nd.ni_dvp);
- register struct nameidata *ndp;
struct vattr vattr;
int error;
struct nameidata nd;
struct vattr vattr;
int error;
struct nameidata nd;
#ifndef FIFO
return (EOPNOTSUPP);
#else
#ifndef FIFO
return (EOPNOTSUPP);
#else
- ndp = &nd;
- ndp->ni_nameiop = CREATE | LOCKPARENT;
- ndp->ni_segflg = UIO_USERSPACE;
- ndp->ni_dirp = uap->fname;
- if (error = namei(ndp, p))
+ NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->fname, p);
+ if (error = namei(&nd))
- if (ndp->ni_vp != NULL) {
- VOP_ABORTOP(ndp->ni_dvp, &ndp->ni_cnd);
- if (ndp->ni_dvp == ndp->ni_vp)
- vrele(ndp->ni_dvp);
+ if (nd.ni_vp != NULL) {
+ VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
+ if (nd.ni_dvp == nd.ni_vp)
+ vrele(nd.ni_dvp);
- vput(ndp->ni_dvp);
- vrele(ndp->ni_vp);
+ vput(nd.ni_dvp);
+ vrele(nd.ni_vp);
return (EEXIST);
}
VATTR_NULL(&vattr);
vattr.va_type = VFIFO;
vattr.va_mode = (uap->fmode & 07777) &~ p->p_fd->fd_cmask;
return (EEXIST);
}
VATTR_NULL(&vattr);
vattr.va_type = VFIFO;
vattr.va_mode = (uap->fmode & 07777) &~ p->p_fd->fd_cmask;
- LEASE_CHECK(ndp->ni_dvp, p, p->p_ucred, LEASE_WRITE);
- return (VOP_MKNOD(ndp->ni_dvp, &ndp->ni_vp, &ndp->ni_cnd, &vattr));
+ LEASE_CHECK(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
+ return (VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr));
- register struct nameidata *ndp;
register struct vnode *vp, *xp;
int error;
struct nameidata nd;
register struct vnode *vp, *xp;
int error;
struct nameidata nd;
- CHECKPOINT;
- ndp = &nd;
- ndp->ni_nameiop = LOOKUP | FOLLOW;
- ndp->ni_segflg = UIO_USERSPACE;
- ndp->ni_dirp = uap->target;
- if (error = namei(ndp, p))
+ NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->target, p);
+ if (error = namei(&nd))
if (vp->v_type == VDIR &&
(error = suser(p->p_ucred, &p->p_acflag)))
goto out1;
if (vp->v_type == VDIR &&
(error = suser(p->p_ucred, &p->p_acflag)))
goto out1;
- ndp->ni_nameiop = CREATE | LOCKPARENT;
- ndp->ni_dirp = (caddr_t)uap->linkname;
- if (error = namei(ndp, p))
+ nd.ni_cnd.cn_nameiop = CREATE;
+ nd.ni_cnd.cn_flags = LOCKPARENT;
+ nd.ni_dirp = (caddr_t)uap->linkname;
+ if (error = namei(&nd))
if (xp != NULL) {
error = EEXIST;
goto out;
}
if (xp != NULL) {
error = EEXIST;
goto out;
}
if (vp->v_mount != xp->v_mount)
error = EXDEV;
out:
if (!error) {
LEASE_CHECK(xp, p, p->p_ucred, LEASE_WRITE);
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
if (vp->v_mount != xp->v_mount)
error = EXDEV;
out:
if (!error) {
LEASE_CHECK(xp, p, p->p_ucred, LEASE_WRITE);
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
- error = VOP_LINK(vp, ndp->ni_dvp, &ndp->ni_cnd);
+ error = VOP_LINK(vp, nd.ni_dvp, &nd.ni_cnd);
- VOP_ABORTOP(ndp->ni_dvp, &ndp->ni_cnd);
- if (ndp->ni_dvp == ndp->ni_vp)
- vrele(ndp->ni_dvp);
+ VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
+ if (nd.ni_dvp == nd.ni_vp)
+ vrele(nd.ni_dvp);
- vput(ndp->ni_dvp);
- if (ndp->ni_vp)
- vrele(ndp->ni_vp);
+ vput(nd.ni_dvp);
+ if (nd.ni_vp)
+ vrele(nd.ni_vp);
- register struct nameidata *ndp;
struct vattr vattr;
char *target;
int error;
struct nameidata nd;
struct vattr vattr;
char *target;
int error;
struct nameidata nd;
- CHECKPOINT;
- ndp = &nd;
- ndp->ni_segflg = UIO_USERSPACE;
- ndp->ni_dirp = uap->linkname;
MALLOC(target, char *, MAXPATHLEN, M_NAMEI, M_WAITOK);
if (error = copyinstr(uap->target, target, MAXPATHLEN, (u_int *)0))
goto out;
MALLOC(target, char *, MAXPATHLEN, M_NAMEI, M_WAITOK);
if (error = copyinstr(uap->target, target, MAXPATHLEN, (u_int *)0))
goto out;
- ndp->ni_nameiop = CREATE | LOCKPARENT;
- if (error = namei(ndp, p))
+ NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->linkname, p);
+ if (error = namei(&nd))
- if (ndp->ni_vp) {
- VOP_ABORTOP(ndp->ni_dvp, &ndp->ni_cnd);
- if (ndp->ni_dvp == ndp->ni_vp)
- vrele(ndp->ni_dvp);
+ if (nd.ni_vp) {
+ VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
+ if (nd.ni_dvp == nd.ni_vp)
+ vrele(nd.ni_dvp);
- vput(ndp->ni_dvp);
- vrele(ndp->ni_vp);
+ vput(nd.ni_dvp);
+ vrele(nd.ni_vp);
error = EEXIST;
goto out;
}
VATTR_NULL(&vattr);
vattr.va_mode = 0777 &~ p->p_fd->fd_cmask;
error = EEXIST;
goto out;
}
VATTR_NULL(&vattr);
vattr.va_mode = 0777 &~ p->p_fd->fd_cmask;
- LEASE_CHECK(ndp->ni_dvp, p, p->p_ucred, LEASE_WRITE);
- error = VOP_SYMLINK(ndp->ni_dvp, &ndp->ni_vp, &ndp->ni_cnd, &vattr, target);
+ LEASE_CHECK(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
+ error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr, target);
out:
FREE(target, M_NAMEI);
out:
FREE(target, M_NAMEI);
unlink(p, uap, retval)
struct proc *p;
struct args {
unlink(p, uap, retval)
struct proc *p;
struct args {
- register struct nameidata *ndp;
register struct vnode *vp;
int error;
struct nameidata nd;
register struct vnode *vp;
int error;
struct nameidata nd;
- CHECKPOINT;
- ndp = &nd;
- ndp->ni_nameiop = DELETE | LOCKPARENT | LOCKLEAF;
- ndp->ni_segflg = UIO_USERSPACE;
- ndp->ni_dirp = uap->fname;
- if (error = namei(ndp, p))
+ NDINIT(&nd, DELETE, LOCKPARENT | LOCKLEAF, UIO_USERSPACE, uap->name, p);
+ if (error = namei(&nd))
if (vp->v_type == VDIR &&
(error = suser(p->p_ucred, &p->p_acflag)))
goto out;
if (vp->v_type == VDIR &&
(error = suser(p->p_ucred, &p->p_acflag)))
goto out;
(void) vnode_pager_uncache(vp);
out:
if (!error) {
(void) vnode_pager_uncache(vp);
out:
if (!error) {
- LEASE_CHECK(ndp->ni_dvp, p, p->p_ucred, LEASE_WRITE);
+ LEASE_CHECK(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
- error = VOP_REMOVE(ndp->ni_dvp, ndp->ni_vp, &ndp->ni_cnd);
+ error = VOP_REMOVE(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd);
- VOP_ABORTOP(ndp->ni_dvp, &ndp->ni_cnd);
- if (ndp->ni_dvp == vp)
- vrele(ndp->ni_dvp);
+ VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
+ if (nd.ni_dvp == vp)
+ vrele(nd.ni_dvp);
- register struct nameidata *ndp;
register struct ucred *cred = p->p_ucred;
register struct vnode *vp;
int error, mode, svuid, svgid;
struct nameidata nd;
register struct ucred *cred = p->p_ucred;
register struct vnode *vp;
int error, mode, svuid, svgid;
struct nameidata nd;
svuid = cred->cr_uid;
svgid = cred->cr_groups[0];
cred->cr_uid = p->p_cred->p_ruid;
cred->cr_groups[0] = p->p_cred->p_rgid;
svuid = cred->cr_uid;
svgid = cred->cr_groups[0];
cred->cr_uid = p->p_cred->p_ruid;
cred->cr_groups[0] = p->p_cred->p_rgid;
- ndp->ni_nameiop = LOOKUP | FOLLOW | LOCKLEAF;
- ndp->ni_segflg = UIO_USERSPACE;
- ndp->ni_dirp = uap->fname;
- if (error = namei(ndp, p))
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->fname, p);
+ if (error = namei(&nd))
/*
* fmode == 0 means only check for exist
*/
/*
* fmode == 0 means only check for exist
*/
- register struct nameidata *ndp;
struct stat sb;
int error;
struct nameidata nd;
struct stat sb;
int error;
struct nameidata nd;
- ndp = &nd;
- ndp->ni_nameiop = LOOKUP | LOCKLEAF | FOLLOW;
- ndp->ni_segflg = UIO_USERSPACE;
- ndp->ni_dirp = uap->fname;
- if (error = namei(ndp, p))
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->fname, p);
+ if (error = namei(&nd))
- error = vn_stat(ndp->ni_vp, &sb, p);
- vput(ndp->ni_vp);
+ error = vn_stat(nd.ni_vp, &sb, p);
+ vput(nd.ni_vp);
if (error)
return (error);
error = copyout((caddr_t)&sb, (caddr_t)uap->ub, sizeof (sb));
if (error)
return (error);
error = copyout((caddr_t)&sb, (caddr_t)uap->ub, sizeof (sb));
- register struct nameidata *ndp;
struct stat sb;
int error;
struct nameidata nd;
struct stat sb;
int error;
struct nameidata nd;
- ndp = &nd;
- ndp->ni_nameiop = LOOKUP | LOCKLEAF | NOFOLLOW;
- ndp->ni_segflg = UIO_USERSPACE;
- ndp->ni_dirp = uap->fname;
- if (error = namei(ndp, p))
+ NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF, UIO_USERSPACE, uap->fname, p);
+ if (error = namei(&nd))
- error = vn_stat(ndp->ni_vp, &sb, p);
- vput(ndp->ni_vp);
+ error = vn_stat(nd.ni_vp, &sb, p);
+ vput(nd.ni_vp);
if (error)
return (error);
error = copyout((caddr_t)&sb, (caddr_t)uap->ub, sizeof (sb));
if (error)
return (error);
error = copyout((caddr_t)&sb, (caddr_t)uap->ub, sizeof (sb));
- register struct nameidata *ndp;
register struct vnode *vp;
struct iovec aiov;
struct uio auio;
int error;
struct nameidata nd;
register struct vnode *vp;
struct iovec aiov;
struct uio auio;
int error;
struct nameidata nd;
- CHECKPOINT;
- ndp = &nd;
- ndp->ni_nameiop = LOOKUP | LOCKLEAF;
- ndp->ni_segflg = UIO_USERSPACE;
- ndp->ni_dirp = uap->name;
- if (error = namei(ndp, p))
+ NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF, UIO_USERSPACE, uap->name, p);
+ if (error = namei(&nd))
if (vp->v_type != VLNK) {
error = EINVAL;
goto out;
if (vp->v_type != VLNK) {
error = EINVAL;
goto out;
out:
vput(vp);
*retval = uap->count - auio.uio_resid;
out:
vput(vp);
*retval = uap->count - auio.uio_resid;
- CHECKCHECK("readlink");
- register struct nameidata *ndp;
register struct vnode *vp;
struct vattr vattr;
int error;
struct nameidata nd;
register struct vnode *vp;
struct vattr vattr;
int error;
struct nameidata nd;
- ndp = &nd;
- ndp->ni_nameiop = LOOKUP | FOLLOW | LOCKLEAF;
- ndp->ni_segflg = UIO_USERSPACE;
- ndp->ni_dirp = uap->fname;
- if (error = namei(ndp, p))
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->fname, p);
+ if (error = namei(&nd))
if (vp->v_mount->mnt_flag & MNT_RDONLY) {
error = EROFS;
goto out;
if (vp->v_mount->mnt_flag & MNT_RDONLY) {
error = EROFS;
goto out;
- register struct nameidata *ndp;
register struct vnode *vp;
struct vattr vattr;
int error;
struct nameidata nd;
register struct vnode *vp;
struct vattr vattr;
int error;
struct nameidata nd;
- ndp = &nd;
- ndp->ni_nameiop = LOOKUP | FOLLOW | LOCKLEAF;
- ndp->ni_segflg = UIO_USERSPACE;
- ndp->ni_dirp = uap->fname;
- if (error = namei(ndp, p))
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->fname, p);
+ if (error = namei(&nd))
if (vp->v_mount->mnt_flag & MNT_RDONLY) {
error = EROFS;
goto out;
if (vp->v_mount->mnt_flag & MNT_RDONLY) {
error = EROFS;
goto out;
- register struct nameidata *ndp;
register struct vnode *vp;
struct vattr vattr;
int error;
struct nameidata nd;
register struct vnode *vp;
struct vattr vattr;
int error;
struct nameidata nd;
- ndp = &nd;
- ndp->ni_nameiop = LOOKUP | NOFOLLOW | LOCKLEAF;
- ndp->ni_segflg = UIO_USERSPACE;
- ndp->ni_dirp = uap->fname;
- if (error = namei(ndp, p))
+ NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF, UIO_USERSPACE, uap->fname, p);
+ if (error = namei(&nd))
if (vp->v_mount->mnt_flag & MNT_RDONLY) {
error = EROFS;
goto out;
if (vp->v_mount->mnt_flag & MNT_RDONLY) {
error = EROFS;
goto out;
- register struct nameidata *ndp;
register struct vnode *vp;
struct timeval tv[2];
struct vattr vattr;
register struct vnode *vp;
struct timeval tv[2];
struct vattr vattr;
if (error = copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof (tv)))
return (error);
if (error = copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof (tv)))
return (error);
- ndp = &nd;
- ndp->ni_nameiop = LOOKUP | FOLLOW | LOCKLEAF;
- ndp->ni_segflg = UIO_USERSPACE;
- ndp->ni_dirp = uap->fname;
- if (error = namei(ndp, p))
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->fname, p);
+ if (error = namei(&nd))
if (vp->v_mount->mnt_flag & MNT_RDONLY) {
error = EROFS;
goto out;
if (vp->v_mount->mnt_flag & MNT_RDONLY) {
error = EROFS;
goto out;
- register struct nameidata *ndp;
register struct vnode *vp;
struct vattr vattr;
int error;
struct nameidata nd;
register struct vnode *vp;
struct vattr vattr;
int error;
struct nameidata nd;
- ndp = &nd;
- ndp->ni_nameiop = LOOKUP | FOLLOW | LOCKLEAF;
- ndp->ni_segflg = UIO_USERSPACE;
- ndp->ni_dirp = uap->fname;
- if (error = namei(ndp, p))
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->fname, p);
+ if (error = namei(&nd))
if (vp->v_type == VDIR) {
error = EISDIR;
goto out;
if (vp->v_type == VDIR) {
error = EISDIR;
goto out;
struct nameidata fromnd, tond;
int error;
struct nameidata fromnd, tond;
int error;
- CHECKPOINT;
- fromnd.ni_nameiop = DELETE | WANTPARENT | SAVESTART;
- fromnd.ni_segflg = UIO_USERSPACE;
- fromnd.ni_dirp = uap->from;
- if (error = namei(&fromnd, p))
+ NDINIT(&fromnd, DELETE, WANTPARENT | SAVESTART, UIO_USERSPACE,
+ uap->from, p);
+ if (error = namei(&fromnd))
return (error);
fvp = fromnd.ni_vp;
return (error);
fvp = fromnd.ni_vp;
- tond.ni_nameiop = RENAME | LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART;
- tond.ni_segflg = UIO_USERSPACE;
- tond.ni_dirp = uap->to;
- if (error = namei(&tond, p)) {
+ NDINIT(&tond, RENAME, LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART,
+ UIO_USERSPACE, uap->to, p);
+ if (error = namei(&tond)) {
VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd);
vrele(fromnd.ni_dvp);
vrele(fvp);
VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd);
vrele(fromnd.ni_dvp);
vrele(fvp);
* then there is nothing to do.
*/
if (fvp == tvp && fromnd.ni_dvp == tdvp &&
* then there is nothing to do.
*/
if (fvp == tvp && fromnd.ni_dvp == tdvp &&
- fromnd.ni_namelen == tond.ni_namelen &&
- !bcmp(fromnd.ni_ptr, tond.ni_ptr, fromnd.ni_namelen))
+ fromnd.ni_cnd.cn_namelen == tond.ni_cnd.cn_namelen &&
+ !bcmp(fromnd.ni_cnd.cn_nameptr, tond.ni_cnd.cn_nameptr,
+ fromnd.ni_cnd.cn_namelen))
error = -1;
out:
if (!error) {
error = -1;
out:
if (!error) {
LEASE_CHECK(fromnd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
if (tvp)
LEASE_CHECK(tvp, p, p->p_ucred, LEASE_WRITE);
LEASE_CHECK(fromnd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
if (tvp)
LEASE_CHECK(tvp, p, p->p_ucred, LEASE_WRITE);
- if (fromnd.ni_startdir != fromnd.ni_dvp ||
- tond.ni_startdir != tond.ni_dvp) /* NEEDSWORK: debug */
- printf ("rename: f.startdir=%x, dvp=%x; t.startdir=%x, dvp=%x\n", fromnd.ni_startdir, fromnd.ni_dvp, tond.ni_startdir, tond.ni_dvp);
error = VOP_RENAME(fromnd.ni_dvp, fromnd.ni_vp, &fromnd.ni_cnd,
tond.ni_dvp, tond.ni_vp, &tond.ni_cnd);
error = VOP_RENAME(fromnd.ni_dvp, fromnd.ni_vp, &fromnd.ni_cnd,
tond.ni_dvp, tond.ni_vp, &tond.ni_cnd);
- if (fromnd.ni_startdir != fromnd.ni_dvp ||
- tond.ni_startdir != tond.ni_dvp) /* NEEDSWORK: debug */
- printf ("rename: f.startdir=%x, dvp=%x; t.startdir=%x, dvp=%x\n", fromnd.ni_startdir, fromnd.ni_dvp, tond.ni_startdir, tond.ni_dvp);
} else {
VOP_ABORTOP(tond.ni_dvp, &tond.ni_cnd);
if (tdvp == tvp)
} else {
VOP_ABORTOP(tond.ni_dvp, &tond.ni_cnd);
if (tdvp == tvp)
}
p->p_spare[1]--;
vrele(tond.ni_startdir);
}
p->p_spare[1]--;
vrele(tond.ni_startdir);
- FREE(tond.ni_pnbuf, M_NAMEI);
+ FREE(tond.ni_cnd.cn_pnbuf, M_NAMEI);
out1:
p->p_spare[1]--;
vrele(fromnd.ni_startdir);
out1:
p->p_spare[1]--;
vrele(fromnd.ni_startdir);
- FREE(fromnd.ni_pnbuf, M_NAMEI);
- CHECKCHECK("rename");
+ FREE(fromnd.ni_cnd.cn_pnbuf, M_NAMEI);
if (error == -1)
return (0);
return (error);
if (error == -1)
return (0);
return (error);
- register struct nameidata *ndp;
register struct vnode *vp;
struct vattr vattr;
int error;
struct nameidata nd;
register struct vnode *vp;
struct vattr vattr;
int error;
struct nameidata nd;
- CHECKPOINT;
- ndp = &nd;
- ndp->ni_nameiop = CREATE | LOCKPARENT;
- ndp->ni_segflg = UIO_USERSPACE;
- ndp->ni_dirp = uap->name;
- if (error = namei(ndp, p))
+ NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->name, p);
+ if (error = namei(&nd))
- VOP_ABORTOP(ndp->ni_dvp, &ndp->ni_cnd);
- if (ndp->ni_dvp == vp)
- vrele(ndp->ni_dvp);
+ VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
+ if (nd.ni_dvp == vp)
+ vrele(nd.ni_dvp);
return (EEXIST);
}
VATTR_NULL(&vattr);
vattr.va_type = VDIR;
vattr.va_mode = (uap->dmode & 0777) &~ p->p_fd->fd_cmask;
return (EEXIST);
}
VATTR_NULL(&vattr);
vattr.va_type = VDIR;
vattr.va_mode = (uap->dmode & 0777) &~ p->p_fd->fd_cmask;
- LEASE_CHECK(ndp->ni_dvp, p, p->p_ucred, LEASE_WRITE);
- error = VOP_MKDIR(ndp->ni_dvp, &ndp->ni_vp, &ndp->ni_cnd, &vattr);
+ LEASE_CHECK(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
+ error = VOP_MKDIR(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr);
- vput(ndp->ni_vp);
- CHECKCHECK("mkdir2");
- register struct nameidata *ndp;
register struct vnode *vp;
int error;
struct nameidata nd;
register struct vnode *vp;
int error;
struct nameidata nd;
- CHECKPOINT;
- ndp = &nd;
- ndp->ni_nameiop = DELETE | LOCKPARENT | LOCKLEAF;
- ndp->ni_segflg = UIO_USERSPACE;
- ndp->ni_dirp = uap->name;
- if (error = namei(ndp, p))
+ NDINIT(&nd, DELETE, LOCKPARENT | LOCKLEAF, UIO_USERSPACE, uap->name, p);
+ if (error = namei(&nd))
if (vp->v_type != VDIR) {
error = ENOTDIR;
goto out;
if (vp->v_type != VDIR) {
error = ENOTDIR;
goto out;
/*
* No rmdir "." please.
*/
/*
* No rmdir "." please.
*/
- if (ndp->ni_dvp == vp) {
error = EINVAL;
goto out;
}
error = EINVAL;
goto out;
}
error = EBUSY;
out:
if (!error) {
error = EBUSY;
out:
if (!error) {
- LEASE_CHECK(ndp->ni_dvp, p, p->p_ucred, LEASE_WRITE);
+ LEASE_CHECK(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
- error = VOP_RMDIR(ndp->ni_dvp, ndp->ni_vp, &ndp->ni_cnd);
+ error = VOP_RMDIR(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd);
- VOP_ABORTOP(ndp->ni_dvp, &ndp->ni_cnd);
- if (ndp->ni_dvp == vp)
- vrele(ndp->ni_dvp);
+ VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
+ if (nd.ni_dvp == vp)
+ vrele(nd.ni_dvp);
- register struct nameidata *ndp;
register struct vnode *vp;
struct vattr vattr;
int error;
struct nameidata nd;
register struct vnode *vp;
struct vattr vattr;
int error;
struct nameidata nd;
- ndp = &nd;
- ndp->ni_nameiop = LOOKUP | FOLLOW;
- ndp->ni_segflg = UIO_USERSPACE;
- ndp->ni_dirp = uap->fname;
- if (error = namei(ndp, p))
+ NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->fname, p);
+ if (error = namei(&nd))
if (vp->v_type != VCHR && vp->v_type != VBLK) {
error = EINVAL;
goto out;
if (vp->v_type != VCHR && vp->v_type != VBLK) {
error = EINVAL;
goto out;