]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
VFS: repack LOOKUP_ bit flags.
authorNeilBrown <neilb@suse.de>
Thu, 6 Feb 2025 05:42:44 +0000 (16:42 +1100)
committerChristian Brauner <brauner@kernel.org>
Mon, 10 Feb 2025 09:41:00 +0000 (10:41 +0100)
The LOOKUP_ bits are not in order, which can make it awkward when adding
new bits.  Two bits have recently been added to the end which makes them
look like "scoping flags", but in fact they aren't.

Also LOOKUP_PARENT is described as "internal use only" but is used in
fs/nfs/

This patch:
 - Moves these three flags into the "pathwalk mode" section
 - changes all bits to use the BIT(n) macro
 - Allocates bits in order leaving gaps between the sections,
   and documents those gaps.

Signed-off-by: NeilBrown <neilb@suse.de>
Link: https://lore.kernel.org/r/20250206054504.2950516-8-neilb@suse.de
Signed-off-by: Christian Brauner <brauner@kernel.org>
include/linux/namei.h

index 8ec8fed3bce81d9d73de17a2c4496a89c50b5652..e3042176cdf489080933425cd4974fd8b260b02c 100644 (file)
@@ -18,35 +18,36 @@ enum { MAX_NESTED_LINKS = 8 };
 enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT};
 
 /* pathwalk mode */
-#define LOOKUP_FOLLOW          0x0001  /* follow links at the end */
-#define LOOKUP_DIRECTORY       0x0002  /* require a directory */
-#define LOOKUP_AUTOMOUNT       0x0004  /* force terminal automount */
-#define LOOKUP_EMPTY           0x4000  /* accept empty path [user_... only] */
-#define LOOKUP_DOWN            0x8000  /* follow mounts in the starting point */
-#define LOOKUP_MOUNTPOINT      0x0080  /* follow mounts in the end */
-
-#define LOOKUP_REVAL           0x0020  /* tell ->d_revalidate() to trust no cache */
-#define LOOKUP_RCU             0x0040  /* RCU pathwalk mode; semi-internal */
+#define LOOKUP_FOLLOW          BIT(0)  /* follow links at the end */
+#define LOOKUP_DIRECTORY       BIT(1)  /* require a directory */
+#define LOOKUP_AUTOMOUNT       BIT(2)  /* force terminal automount */
+#define LOOKUP_EMPTY           BIT(3)  /* accept empty path [user_... only] */
+#define LOOKUP_LINKAT_EMPTY    BIT(4) /* Linkat request with empty path. */
+#define LOOKUP_DOWN            BIT(5)  /* follow mounts in the starting point */
+#define LOOKUP_MOUNTPOINT      BIT(6)  /* follow mounts in the end */
+#define LOOKUP_REVAL           BIT(7)  /* tell ->d_revalidate() to trust no cache */
+#define LOOKUP_RCU             BIT(8)  /* RCU pathwalk mode; semi-internal */
+#define LOOKUP_CACHED          BIT(9) /* Only do cached lookup */
+#define LOOKUP_PARENT          BIT(10) /* Looking up final parent in path */
+/* 5 spare bits for pathwalk */
 
 /* These tell filesystem methods that we are dealing with the final component... */
-#define LOOKUP_OPEN            0x0100  /* ... in open */
-#define LOOKUP_CREATE          0x0200  /* ... in object creation */
-#define LOOKUP_EXCL            0x0400  /* ... in exclusive creation */
-#define LOOKUP_RENAME_TARGET   0x0800  /* ... in destination of rename() */
+#define LOOKUP_OPEN            BIT(16) /* ... in open */
+#define LOOKUP_CREATE          BIT(17) /* ... in object creation */
+#define LOOKUP_EXCL            BIT(18) /* ... in target must not exist */
+#define LOOKUP_RENAME_TARGET   BIT(19) /* ... in destination of rename() */
 
-/* internal use only */
-#define LOOKUP_PARENT          0x0010
+/* 4 spare bits for intent */
 
 /* Scoping flags for lookup. */
-#define LOOKUP_NO_SYMLINKS     0x010000 /* No symlink crossing. */
-#define LOOKUP_NO_MAGICLINKS   0x020000 /* No nd_jump_link() crossing. */
-#define LOOKUP_NO_XDEV         0x040000 /* No mountpoint crossing. */
-#define LOOKUP_BENEATH         0x080000 /* No escaping from starting point. */
-#define LOOKUP_IN_ROOT         0x100000 /* Treat dirfd as fs root. */
-#define LOOKUP_CACHED          0x200000 /* Only do cached lookup */
-#define LOOKUP_LINKAT_EMPTY    0x400000 /* Linkat request with empty path. */
+#define LOOKUP_NO_SYMLINKS     BIT(24) /* No symlink crossing. */
+#define LOOKUP_NO_MAGICLINKS   BIT(25) /* No nd_jump_link() crossing. */
+#define LOOKUP_NO_XDEV         BIT(26) /* No mountpoint crossing. */
+#define LOOKUP_BENEATH         BIT(27) /* No escaping from starting point. */
+#define LOOKUP_IN_ROOT         BIT(28) /* Treat dirfd as fs root. */
 /* LOOKUP_* flags which do scope-related checks based on the dirfd. */
 #define LOOKUP_IS_SCOPED (LOOKUP_BENEATH | LOOKUP_IN_ROOT)
+/* 3 spare bits for scoping */
 
 extern int path_pts(struct path *path);