vfs: stop open-coding setting WILLBEDIR flag
This commit is contained in:
parent
002e18eb7f
commit
8c9d74634a
@ -3610,6 +3610,7 @@ kern_renameat(struct thread *td, int oldfd, const char *old, int newfd,
|
||||
struct mount *mp = NULL;
|
||||
struct vnode *tvp, *fvp, *tdvp;
|
||||
struct nameidata fromnd, tond;
|
||||
u_int64_t tondflags;
|
||||
int error;
|
||||
|
||||
again:
|
||||
@ -3630,11 +3631,11 @@ again:
|
||||
}
|
||||
#endif
|
||||
fvp = fromnd.ni_vp;
|
||||
NDINIT_ATRIGHTS(&tond, RENAME, LOCKPARENT | LOCKLEAF | NOCACHE |
|
||||
SAVESTART | AUDITVNODE2, pathseg, new, newfd,
|
||||
&cap_renameat_target_rights, td);
|
||||
tondflags = LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART | AUDITVNODE2;
|
||||
if (fromnd.ni_vp->v_type == VDIR)
|
||||
tond.ni_cnd.cn_flags |= WILLBEDIR;
|
||||
tondflags |= WILLBEDIR;
|
||||
NDINIT_ATRIGHTS(&tond, RENAME, tondflags, pathseg, new, newfd,
|
||||
&cap_renameat_target_rights, td);
|
||||
if ((error = namei(&tond)) != 0) {
|
||||
/* Translate error code for rename("dir1", "dir2/."). */
|
||||
if (error == EISDIR && fvp->v_type == VDIR)
|
||||
@ -3776,9 +3777,8 @@ kern_mkdirat(struct thread *td, int fd, const char *path, enum uio_seg segflg,
|
||||
restart:
|
||||
bwillwrite();
|
||||
NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | SAVENAME | AUDITVNODE1 |
|
||||
NC_NOMAKEENTRY | NC_KEEPPOSENTRY | FAILIFEXISTS, segflg, path, fd,
|
||||
&cap_mkdirat_rights, td);
|
||||
nd.ni_cnd.cn_flags |= WILLBEDIR;
|
||||
NC_NOMAKEENTRY | NC_KEEPPOSENTRY | FAILIFEXISTS | WILLBEDIR,
|
||||
segflg, path, fd, &cap_mkdirat_rights, td);
|
||||
if ((error = namei(&nd)) != 0)
|
||||
return (error);
|
||||
if (vn_start_write(nd.ni_dvp, &mp, V_NOWAIT) != 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user