namei: add NDPREINIT() macro

Its intent is to do the initialization of the future part of struct nameidata
which should be used across several namei() and VOPs.  Right now it is NOP.

Reviewed by:	mckusick
Discussed with:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D30041
This commit is contained in:
Konstantin Belousov 2021-06-14 22:03:41 +03:00
parent 71faea9307
commit 802cf4ab0e
2 changed files with 12 additions and 0 deletions

View file

@ -1328,6 +1328,7 @@ kern_mknodat(struct thread *td, int fd, const char *path, enum uio_seg pathseg,
}
if (error != 0)
return (error);
NDPREINIT(&nd);
restart:
bwillwrite();
NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | SAVENAME | AUDITVNODE1 |
@ -1436,6 +1437,7 @@ kern_mkfifoat(struct thread *td, int fd, const char *path,
int error;
AUDIT_ARG_MODE(mode);
NDPREINIT(&nd);
restart:
bwillwrite();
NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | SAVENAME | AUDITVNODE1 |
@ -1566,6 +1568,7 @@ kern_linkat(struct thread *td, int fd1, int fd2, const char *path1,
struct nameidata nd;
int error;
NDPREINIT(&nd);
do {
bwillwrite();
NDINIT_ATRIGHTS(&nd, LOOKUP, AUDITVNODE1 | at2cnpflags(flag,
@ -1714,6 +1717,7 @@ kern_symlinkat(struct thread *td, const char *path1, int fd, const char *path2,
syspath = tmppath;
}
AUDIT_ARG_TEXT(syspath);
NDPREINIT(&nd);
restart:
bwillwrite();
NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | SAVENAME | AUDITVNODE1 |
@ -1778,6 +1782,7 @@ sys_undelete(struct thread *td, struct undelete_args *uap)
struct nameidata nd;
int error;
NDPREINIT(&nd);
restart:
bwillwrite();
NDINIT(&nd, DELETE, LOCKPARENT | DOWHITEOUT | AUDITVNODE1,
@ -1891,6 +1896,7 @@ kern_funlinkat(struct thread *td, int dfd, const char *path, int fd,
return (error);
}
NDPREINIT(&nd);
restart:
bwillwrite();
NDINIT_ATRIGHTS(&nd, DELETE, LOCKPARENT | LOCKLEAF | AUDITVNODE1 |
@ -3422,6 +3428,7 @@ kern_truncate(struct thread *td, const char *path, enum uio_seg pathseg,
if (length < 0)
return (EINVAL);
NDPREINIT(&nd);
retry:
NDINIT(&nd, LOOKUP, FOLLOW | AUDITVNODE1, pathseg, path, td);
if ((error = namei(&nd)) != 0)
@ -3789,6 +3796,7 @@ kern_mkdirat(struct thread *td, int fd, const char *path, enum uio_seg segflg,
int error;
AUDIT_ARG_MODE(mode);
NDPREINIT(&nd);
restart:
bwillwrite();
NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | SAVENAME | AUDITVNODE1 |
@ -3859,6 +3867,7 @@ kern_frmdirat(struct thread *td, int dfd, const char *path, int fd,
return (error);
}
NDPREINIT(&nd);
restart:
bwillwrite();
NDINIT_ATRIGHTS(&nd, DELETE, LOCKPARENT | LOCKLEAF | AUDITVNODE1 |

View file

@ -265,6 +265,9 @@ do { \
_ndp->ni_startdir = NULL; \
} while (0)
#define NDPREINIT(ndp) do { \
} while (0)
#define NDF_NO_DVP_RELE 0x00000001
#define NDF_NO_DVP_UNLOCK 0x00000002
#define NDF_NO_DVP_PUT 0x00000003