hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/include/linux/namei.h
....@@ -2,6 +2,7 @@
22 #ifndef _LINUX_NAMEI_H
33 #define _LINUX_NAMEI_H
44
5
+#include <linux/fs.h>
56 #include <linux/kernel.h>
67 #include <linux/path.h>
78 #include <linux/fcntl.h>
....@@ -14,38 +15,40 @@
1415 /*
1516 * Type of the last component on LOOKUP_PARENT
1617 */
17
-enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT, LAST_BIND};
18
+enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT};
1819
19
-/*
20
- * The bitmask for a lookup event:
21
- * - follow links at the end
22
- * - require a directory
23
- * - ending slashes ok even for nonexistent files
24
- * - internal "there are more path components" flag
25
- * - dentry cache is untrusted; force a real lookup
26
- * - suppress terminal automount
27
- */
28
-#define LOOKUP_FOLLOW 0x0001
29
-#define LOOKUP_DIRECTORY 0x0002
30
-#define LOOKUP_AUTOMOUNT 0x0004
20
+/* 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 */
3127
28
+#define LOOKUP_REVAL 0x0020 /* tell ->d_revalidate() to trust no cache */
29
+#define LOOKUP_RCU 0x0040 /* RCU pathwalk mode; semi-internal */
30
+
31
+/* 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() */
36
+
37
+/* internal use only */
3238 #define LOOKUP_PARENT 0x0010
33
-#define LOOKUP_REVAL 0x0020
34
-#define LOOKUP_RCU 0x0040
35
-#define LOOKUP_NO_REVAL 0x0080
36
-
37
-/*
38
- * Intent data
39
- */
40
-#define LOOKUP_OPEN 0x0100
41
-#define LOOKUP_CREATE 0x0200
42
-#define LOOKUP_EXCL 0x0400
43
-#define LOOKUP_RENAME_TARGET 0x0800
44
-
4539 #define LOOKUP_JUMPED 0x1000
4640 #define LOOKUP_ROOT 0x2000
47
-#define LOOKUP_EMPTY 0x4000
48
-#define LOOKUP_DOWN 0x8000
41
+#define LOOKUP_ROOT_GRABBED 0x0008
42
+
43
+/* Scoping flags for lookup. */
44
+#define LOOKUP_NO_SYMLINKS 0x010000 /* No symlink crossing. */
45
+#define LOOKUP_NO_MAGICLINKS 0x020000 /* No nd_jump_link() crossing. */
46
+#define LOOKUP_NO_XDEV 0x040000 /* No mountpoint crossing. */
47
+#define LOOKUP_BENEATH 0x080000 /* No escaping from starting point. */
48
+#define LOOKUP_IN_ROOT 0x100000 /* Treat dirfd as fs root. */
49
+#define LOOKUP_CACHED 0x200000 /* Only do cached lookup */
50
+/* LOOKUP_* flags which do scope-related checks based on the dirfd. */
51
+#define LOOKUP_IS_SCOPED (LOOKUP_BENEATH | LOOKUP_IN_ROOT)
4952
5053 extern int path_pts(struct path *path);
5154
....@@ -57,36 +60,17 @@
5760 return user_path_at_empty(dfd, name, flags, path, NULL);
5861 }
5962
60
-static inline int user_path(const char __user *name, struct path *path)
61
-{
62
- return user_path_at_empty(AT_FDCWD, name, LOOKUP_FOLLOW, path, NULL);
63
-}
64
-
65
-static inline int user_lpath(const char __user *name, struct path *path)
66
-{
67
- return user_path_at_empty(AT_FDCWD, name, 0, path, NULL);
68
-}
69
-
70
-static inline int user_path_dir(const char __user *name, struct path *path)
71
-{
72
- return user_path_at_empty(AT_FDCWD, name,
73
- LOOKUP_FOLLOW | LOOKUP_DIRECTORY, path, NULL);
74
-}
75
-
7663 extern int kern_path(const char *, unsigned, struct path *);
7764
7865 extern struct dentry *kern_path_create(int, const char *, struct path *, unsigned int);
7966 extern struct dentry *user_path_create(int, const char __user *, struct path *, unsigned int);
8067 extern void done_path_create(struct path *, struct dentry *);
8168 extern struct dentry *kern_path_locked(const char *, struct path *);
82
-extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
83
- const char *, unsigned int, struct path *);
84
-extern int kern_path_mountpoint(int, const char *, struct path *, unsigned int);
8569
8670 extern struct dentry *try_lookup_one_len(const char *, struct dentry *, int);
8771 extern struct dentry *lookup_one_len(const char *, struct dentry *, int);
88
-extern struct dentry *lookup_one_len2(const char *, struct vfsmount *mnt, struct dentry *, int);
8972 extern struct dentry *lookup_one_len_unlocked(const char *, struct dentry *, int);
73
+extern struct dentry *lookup_positive_unlocked(const char *, struct dentry *, int);
9074
9175 extern int follow_down_one(struct path *);
9276 extern int follow_down(struct path *);
....@@ -95,7 +79,7 @@
9579 extern struct dentry *lock_rename(struct dentry *, struct dentry *);
9680 extern void unlock_rename(struct dentry *, struct dentry *);
9781
98
-extern void nd_jump_link(struct path *path);
82
+extern int __must_check nd_jump_link(struct path *path);
9983
10084 static inline void nd_terminate_link(void *name, size_t len, size_t maxlen)
10185 {