Skip to content

Commit 2c3230f

Browse files
neilbrownbrauner
authored andcommitted
VFS: repack LOOKUP_ bit flags.
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent 9748cb2 commit 2c3230f

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

include/linux/namei.h

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,36 @@ enum { MAX_NESTED_LINKS = 8 };
1818
enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT};
1919

2020
/* pathwalk mode */
21-
#define LOOKUP_FOLLOW 0x0001 /* follow links at the end */
22-
#define LOOKUP_DIRECTORY 0x0002 /* require a directory */
23-
#define LOOKUP_AUTOMOUNT 0x0004 /* force terminal automount */
24-
#define LOOKUP_EMPTY 0x4000 /* accept empty path [user_... only] */
25-
#define LOOKUP_DOWN 0x8000 /* follow mounts in the starting point */
26-
#define LOOKUP_MOUNTPOINT 0x0080 /* follow mounts in the end */
27-
28-
#define LOOKUP_REVAL 0x0020 /* tell ->d_revalidate() to trust no cache */
29-
#define LOOKUP_RCU 0x0040 /* RCU pathwalk mode; semi-internal */
21+
#define LOOKUP_FOLLOW BIT(0) /* follow links at the end */
22+
#define LOOKUP_DIRECTORY BIT(1) /* require a directory */
23+
#define LOOKUP_AUTOMOUNT BIT(2) /* force terminal automount */
24+
#define LOOKUP_EMPTY BIT(3) /* accept empty path [user_... only] */
25+
#define LOOKUP_LINKAT_EMPTY BIT(4) /* Linkat request with empty path. */
26+
#define LOOKUP_DOWN BIT(5) /* follow mounts in the starting point */
27+
#define LOOKUP_MOUNTPOINT BIT(6) /* follow mounts in the end */
28+
#define LOOKUP_REVAL BIT(7) /* tell ->d_revalidate() to trust no cache */
29+
#define LOOKUP_RCU BIT(8) /* RCU pathwalk mode; semi-internal */
30+
#define LOOKUP_CACHED BIT(9) /* Only do cached lookup */
31+
#define LOOKUP_PARENT BIT(10) /* Looking up final parent in path */
32+
/* 5 spare bits for pathwalk */
3033

3134
/* These tell filesystem methods that we are dealing with the final component... */
32-
#define LOOKUP_OPEN 0x0100 /* ... in open */
33-
#define LOOKUP_CREATE 0x0200 /* ... in object creation */
34-
#define LOOKUP_EXCL 0x0400 /* ... in exclusive creation */
35-
#define LOOKUP_RENAME_TARGET 0x0800 /* ... in destination of rename() */
35+
#define LOOKUP_OPEN BIT(16) /* ... in open */
36+
#define LOOKUP_CREATE BIT(17) /* ... in object creation */
37+
#define LOOKUP_EXCL BIT(18) /* ... in target must not exist */
38+
#define LOOKUP_RENAME_TARGET BIT(19) /* ... in destination of rename() */
3639

37-
/* internal use only */
38-
#define LOOKUP_PARENT 0x0010
40+
/* 4 spare bits for intent */
3941

4042
/* Scoping flags for lookup. */
41-
#define LOOKUP_NO_SYMLINKS 0x010000 /* No symlink crossing. */
42-
#define LOOKUP_NO_MAGICLINKS 0x020000 /* No nd_jump_link() crossing. */
43-
#define LOOKUP_NO_XDEV 0x040000 /* No mountpoint crossing. */
44-
#define LOOKUP_BENEATH 0x080000 /* No escaping from starting point. */
45-
#define LOOKUP_IN_ROOT 0x100000 /* Treat dirfd as fs root. */
46-
#define LOOKUP_CACHED 0x200000 /* Only do cached lookup */
47-
#define LOOKUP_LINKAT_EMPTY 0x400000 /* Linkat request with empty path. */
43+
#define LOOKUP_NO_SYMLINKS BIT(24) /* No symlink crossing. */
44+
#define LOOKUP_NO_MAGICLINKS BIT(25) /* No nd_jump_link() crossing. */
45+
#define LOOKUP_NO_XDEV BIT(26) /* No mountpoint crossing. */
46+
#define LOOKUP_BENEATH BIT(27) /* No escaping from starting point. */
47+
#define LOOKUP_IN_ROOT BIT(28) /* Treat dirfd as fs root. */
4848
/* LOOKUP_* flags which do scope-related checks based on the dirfd. */
4949
#define LOOKUP_IS_SCOPED (LOOKUP_BENEATH | LOOKUP_IN_ROOT)
50+
/* 3 spare bits for scoping */
5051

5152
extern int path_pts(struct path *path);
5253

0 commit comments

Comments
 (0)