Date: Sun, 23 Aug 2020 21:05:39 +0000 (UTC) From: Mateusz Guzik <mjg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r364540 - in head/sys: kern sys Message-ID: <202008232105.07NL5dKx047651@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mjg Date: Sun Aug 23 21:05:39 2020 New Revision: 364540 URL: https://svnweb.freebsd.org/changeset/base/364540 Log: vfs: convert nameiop into an enum While here change the field size from long to int and move it into the gap next to cn_flags. Shrinks struct componentname from 64 to 56 bytes on amd64. Modified: head/sys/kern/vfs_lookup.c head/sys/sys/namei.h Modified: head/sys/kern/vfs_lookup.c ============================================================================== --- head/sys/kern/vfs_lookup.c Sun Aug 23 21:05:06 2020 (r364539) +++ head/sys/kern/vfs_lookup.c Sun Aug 23 21:05:39 2020 (r364540) @@ -484,10 +484,6 @@ namei(struct nameidata *ndp) td = cnp->cn_thread; ndp->ni_cnd.cn_cred = ndp->ni_cnd.cn_thread->td_ucred; KASSERT(cnp->cn_cred && td->td_proc, ("namei: bad cred/proc")); - KASSERT((cnp->cn_nameiop & (~OPMASK)) == 0, - ("namei: nameiop contaminated with flags")); - KASSERT((cnp->cn_flags & OPMASK) == 0, - ("namei: flags contaminated with nameiops")); KASSERT((cnp->cn_flags & NAMEI_INTERNAL_FLAGS) == 0, ("namei: unexpected flags: %" PRIx64 "\n", cnp->cn_flags & NAMEI_INTERNAL_FLAGS)); Modified: head/sys/sys/namei.h ============================================================================== --- head/sys/sys/namei.h Sun Aug 23 21:05:06 2020 (r364539) +++ head/sys/sys/namei.h Sun Aug 23 21:05:39 2020 (r364540) @@ -40,14 +40,16 @@ #include <sys/queue.h> #include <sys/_uio.h> +enum nameiop { LOOKUP, CREATE, DELETE, RENAME }; + struct componentname { /* * Arguments to lookup. */ - u_long cn_nameiop; /* namei operation */ u_int64_t cn_flags; /* flags to namei */ struct thread *cn_thread;/* thread requesting lookup */ struct ucred *cn_cred; /* credentials */ + enum nameiop cn_nameiop; /* namei operation */ int cn_lkflags; /* Lock flags LK_EXCLUSIVE or LK_SHARED */ /* * Shared between lookup and commit routines. @@ -115,13 +117,10 @@ int cache_fplookup(struct nameidata *ndp, enum cache_f struct pwd **pwdp); /* - * namei operations + * Flags for namei. + * + * If modifying the list make sure to check whether NDVALIDATE needs updating. */ -#define LOOKUP 0 /* perform name lookup only */ -#define CREATE 1 /* setup for file creation */ -#define DELETE 2 /* setup for file deletion */ -#define RENAME 3 /* setup for file renaming */ -#define OPMASK 3 /* mask for operation */ /* * namei operational modifier flags, stored in ni_cnd.flags */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202008232105.07NL5dKx047651>