diff options
author | Mateusz Guzik <mjg@FreeBSD.org> | 2021-01-12 11:36:30 +0000 |
---|---|---|
committer | Mateusz Guzik <mjg@FreeBSD.org> | 2021-01-12 13:16:10 +0000 |
commit | cdb62ab74ee0cb99988c7831d950a6021aaa4879 (patch) | |
tree | 1f0850e494c28af6bcc382020c2b795aa0908c37 /sys/kern/vfs_lookup.c | |
parent | 6b3a9a0f3d2cd66145e89fdd8d07cb33a9963e8f (diff) | |
download | src-cdb62ab74ee0cb99988c7831d950a6021aaa4879.tar.gz src-cdb62ab74ee0cb99988c7831d950a6021aaa4879.zip |
vfs: add NDFREE_NOTHING and convert several NDFREE_PNBUF callers
Check the comment above the routine for reasoning.
Diffstat (limited to 'sys/kern/vfs_lookup.c')
-rw-r--r-- | sys/kern/vfs_lookup.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index da04dd09af40..3b8ee558e023 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -1487,6 +1487,33 @@ NDFREE_PNBUF(struct nameidata *ndp) } } +/* + * NDFREE_PNBUF replacement for callers that know there is no buffer. + * + * This is a hack. Preferably the VFS layer would not produce anything more + * than it was asked to do. Unfortunately several non-LOOKUP cases can add the + * HASBUF flag to the result. Even then an interface could be implemented where + * the caller specifies what they expected to see in the result and what they + * are going to take care of. + * + * In the meantime provide this kludge as a trivial replacement for NDFREE_PNBUF + * calls scattered throughout the kernel where we know for a fact the flag must not + * be seen. + */ +#ifdef INVARIANTS +void +NDFREE_NOTHING(struct nameidata *ndp) +{ + struct componentname *cnp; + + cnp = &ndp->ni_cnd; + KASSERT(cnp->cn_nameiop == LOOKUP, ("%s: got non-LOOKUP op %d\n", + __func__, cnp->cn_nameiop)); + KASSERT((cnp->cn_flags & (SAVENAME | HASBUF)) == 0, + ("%s: bad flags \%" PRIx64 "\n", __func__, cnp->cn_flags)); +} +#endif + void (NDFREE)(struct nameidata *ndp, const u_int flags) { |