Define namei flag INRENAME and set it if a lookup operation is part

of rename.  This helps with building better asserts for rename in
the DELETE lookup ... the RENAME lookup is quite obviously a part
of rename.
This commit is contained in:
pooka 2009-12-23 01:09:24 +00:00
parent bb27c3b9ac
commit 3142d3ac31
3 changed files with 12 additions and 10 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: vfs_syscalls.c,v 1.400 2009/12/19 20:28:27 martin Exp $ */
/* $NetBSD: vfs_syscalls.c,v 1.401 2009/12/23 01:09:24 pooka 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.400 2009/12/19 20:28:27 martin Exp $");
__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.401 2009/12/23 01:09:24 pooka Exp $");
#ifdef _KERNEL_OPT
#include "opt_fileassoc.h"
@ -3264,7 +3264,7 @@ do_sys_rename(const char *from, const char *to, enum uio_seg seg, int retain)
uint32_t saveflag;
int error;
NDINIT(&fromnd, DELETE, LOCKPARENT | SAVESTART | TRYEMULROOT,
NDINIT(&fromnd, DELETE, LOCKPARENT | SAVESTART | TRYEMULROOT | INRENAME,
seg, from);
if ((error = namei(&fromnd)) != 0)
return (error);
@ -3329,7 +3329,7 @@ do_sys_rename(const char *from, const char *to, enum uio_seg seg, int retain)
NDINIT(&tond, RENAME,
LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART | TRYEMULROOT
| (fvp->v_type == VDIR ? CREATEDIR : 0),
| INRENAME | (fvp->v_type == VDIR ? CREATEDIR : 0),
seg, to);
if ((error = namei(&tond)) != 0) {
VFS_RENAMELOCK_EXIT(fs);

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfs_serv.c,v 1.148 2009/11/07 07:27:49 cegger Exp $ */
/* $NetBSD: nfs_serv.c,v 1.149 2009/12/23 01:09:25 pooka Exp $ */
/*
* Copyright (c) 1989, 1993
@ -55,7 +55,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.148 2009/11/07 07:27:49 cegger Exp $");
__KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.149 2009/12/23 01:09:25 pooka Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -1863,7 +1863,7 @@ nfsrv_rename(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *l
saved_uid = kauth_cred_geteuid(cred);
fromnd.ni_cnd.cn_cred = cred;
fromnd.ni_cnd.cn_nameiop = DELETE;
fromnd.ni_cnd.cn_flags = LOCKPARENT | SAVESTART;
fromnd.ni_cnd.cn_flags = LOCKPARENT | SAVESTART | INRENAME;
error = nfs_namei(&fromnd, &fnsfh, len, slp, nam, &md,
&dpos, &fdirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
if (fdirp && v3) {
@ -1934,7 +1934,8 @@ nfsrv_rename(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *l
kauth_cred_seteuid(cred, saved_uid);
tond.ni_cnd.cn_cred = cred;
tond.ni_cnd.cn_nameiop = RENAME;
tond.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART;
tond.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | NOCACHE |
SAVESTART | INRENAME;
error = nfs_namei(&tond, &tnsfh, len2, slp, nam, &md,
&dpos, &tdirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
if (tdirp && v3) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: namei.src,v 1.13 2009/09/27 17:23:54 dholland Exp $ */
/* $NetBSD: namei.src,v 1.14 2009/12/23 01:09:24 pooka Exp $ */
/*
* Copyright (c) 1985, 1989, 1991, 1993
@ -139,7 +139,8 @@ NAMEIFL ISWHITEOUT 0x0020000 /* found whiteout */
NAMEIFL DOWHITEOUT 0x0040000 /* do whiteouts */
NAMEIFL REQUIREDIR 0x0080000 /* must be a directory */
NAMEIFL CREATEDIR 0x0200000 /* trailing slashes are ok */
NAMEIFL PARAMASK 0x02fff00 /* mask of parameter descriptors */
NAMEIFL INRENAME 0x0400000 /* operation is a part of ``rename'' */
NAMEIFL PARAMASK 0x06fff00 /* mask of parameter descriptors */
/*
* Initialization of an nameidata structure.