When referencing nd_cnp after namei(), always pass SAVENAME into

NDINIT() operation flags.

Submitted by:	green
Obtained from:	TrustedBSD Project
Sponsored by:	DARPA, NAI Labs
This commit is contained in:
Robert Watson 2002-07-30 18:48:25 +00:00
parent e37b1fcdee
commit e66c87b70e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=100961
2 changed files with 18 additions and 10 deletions

View File

@ -798,7 +798,8 @@ mknod(td, uap)
return (error);
restart:
bwillwrite();
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), td);
NDINIT(&nd, CREATE, LOCKPARENT | SAVENAME, UIO_USERSPACE,
SCARG(uap, path), td);
if ((error = namei(&nd)) != 0)
return (error);
vp = nd.ni_vp;
@ -882,7 +883,8 @@ mkfifo(td, uap)
restart:
bwillwrite();
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), td);
NDINIT(&nd, CREATE, LOCKPARENT | SAVENAME, UIO_USERSPACE,
SCARG(uap, path), td);
if ((error = namei(&nd)) != 0)
return (error);
if (nd.ni_vp != NULL) {
@ -950,7 +952,8 @@ link(td, uap)
vrele(vp);
return (error);
}
NDINIT(&nd, CREATE, LOCKPARENT|NOOBJ, UIO_USERSPACE, SCARG(uap, link), td);
NDINIT(&nd, CREATE, LOCKPARENT | NOOBJ | SAVENAME, UIO_USERSPACE,
SCARG(uap, link), td);
if ((error = namei(&nd)) == 0) {
if (nd.ni_vp != NULL) {
vrele(nd.ni_vp);
@ -999,7 +1002,8 @@ symlink(td, uap)
goto out;
restart:
bwillwrite();
NDINIT(&nd, CREATE, LOCKPARENT|NOOBJ, UIO_USERSPACE, SCARG(uap, link), td);
NDINIT(&nd, CREATE, LOCKPARENT | NOOBJ | SAVENAME, UIO_USERSPACE,
SCARG(uap, link), td);
if ((error = namei(&nd)) != 0)
goto out;
if (nd.ni_vp) {
@ -2613,7 +2617,7 @@ vn_mkdir(path, mode, segflg, td)
restart:
bwillwrite();
NDINIT(&nd, CREATE, LOCKPARENT, segflg, path, td);
NDINIT(&nd, CREATE, LOCKPARENT | SAVENAME, segflg, path, td);
nd.ni_cnd.cn_flags |= WILLBEDIR;
if ((error = namei(&nd)) != 0)
return (error);

View File

@ -798,7 +798,8 @@ mknod(td, uap)
return (error);
restart:
bwillwrite();
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), td);
NDINIT(&nd, CREATE, LOCKPARENT | SAVENAME, UIO_USERSPACE,
SCARG(uap, path), td);
if ((error = namei(&nd)) != 0)
return (error);
vp = nd.ni_vp;
@ -882,7 +883,8 @@ mkfifo(td, uap)
restart:
bwillwrite();
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), td);
NDINIT(&nd, CREATE, LOCKPARENT | SAVENAME, UIO_USERSPACE,
SCARG(uap, path), td);
if ((error = namei(&nd)) != 0)
return (error);
if (nd.ni_vp != NULL) {
@ -950,7 +952,8 @@ link(td, uap)
vrele(vp);
return (error);
}
NDINIT(&nd, CREATE, LOCKPARENT|NOOBJ, UIO_USERSPACE, SCARG(uap, link), td);
NDINIT(&nd, CREATE, LOCKPARENT | NOOBJ | SAVENAME, UIO_USERSPACE,
SCARG(uap, link), td);
if ((error = namei(&nd)) == 0) {
if (nd.ni_vp != NULL) {
vrele(nd.ni_vp);
@ -999,7 +1002,8 @@ symlink(td, uap)
goto out;
restart:
bwillwrite();
NDINIT(&nd, CREATE, LOCKPARENT|NOOBJ, UIO_USERSPACE, SCARG(uap, link), td);
NDINIT(&nd, CREATE, LOCKPARENT | NOOBJ | SAVENAME, UIO_USERSPACE,
SCARG(uap, link), td);
if ((error = namei(&nd)) != 0)
goto out;
if (nd.ni_vp) {
@ -2613,7 +2617,7 @@ vn_mkdir(path, mode, segflg, td)
restart:
bwillwrite();
NDINIT(&nd, CREATE, LOCKPARENT, segflg, path, td);
NDINIT(&nd, CREATE, LOCKPARENT | SAVENAME, segflg, path, td);
nd.ni_cnd.cn_flags |= WILLBEDIR;
if ((error = namei(&nd)) != 0)
return (error);