Blame view

include/linux/namei.h 3.79 KB
b24413180   Greg Kroah-Hartman   License cleanup: ...
1
  /* SPDX-License-Identifier: GPL-2.0 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
3
  #ifndef _LINUX_NAMEI_H
  #define _LINUX_NAMEI_H
adb21d2b5   Aleksa Sarai   namei: LOOKUP_BEN...
4
  #include <linux/fs.h>
b853a1617   Al Viro   turn user_{path_a...
5
  #include <linux/kernel.h>
c5e725f33   Jan Blunck   Move struct path ...
6
  #include <linux/path.h>
b853a1617   Al Viro   turn user_{path_a...
7
8
  #include <linux/fcntl.h>
  #include <linux/errno.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
9

737bebd13   Al Viro   [PATCH] symlink n...
10
  enum { MAX_NESTED_LINKS = 8 };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
11

894bc8c46   Al Viro   namei: remove res...
12
  #define MAXSYMLINKS 40
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
13
14
15
  /*
   * Type of the last component on LOOKUP_PARENT
   */
b4c035369   Al Viro   sanitize handling...
16
  enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT};
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
17

6b61aed06   Al Viro   namei.h: get the ...
18
19
20
21
22
23
  /* 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 */
161aff1d9   Al Viro   LOOKUP_MOUNTPOINT...
24
  #define LOOKUP_MOUNTPOINT	0x0080	/* follow mounts in the end */
6b61aed06   Al Viro   namei.h: get the ...
25
26
27
28
29
30
31
32
33
34
35
  
  #define LOOKUP_REVAL		0x0020	/* tell ->d_revalidate() to trust no cache */
  #define LOOKUP_RCU		0x0040	/* RCU pathwalk mode; semi-internal */
  
  /* 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() */
  
  /* internal use only */
31e6b01f4   Nick Piggin   fs: rcu-walk for ...
36
  #define LOOKUP_PARENT		0x0010
16c2cd717   Al Viro   untangle the "nee...
37
  #define LOOKUP_JUMPED		0x1000
5b6ca027d   Al Viro   reduce vfs_path_l...
38
  #define LOOKUP_ROOT		0x2000
84a2bd394   Al Viro   fs/namei.c: keep ...
39
  #define LOOKUP_ROOT_GRABBED	0x0008
16c2cd717   Al Viro   untangle the "nee...
40

278121417   Aleksa Sarai   namei: LOOKUP_NO_...
41
42
  /* Scoping flags for lookup. */
  #define LOOKUP_NO_SYMLINKS	0x010000 /* No symlink crossing. */
4b99d4996   Aleksa Sarai   namei: LOOKUP_NO_...
43
  #define LOOKUP_NO_MAGICLINKS	0x020000 /* No nd_jump_link() crossing. */
72ba29297   Aleksa Sarai   namei: LOOKUP_NO_...
44
  #define LOOKUP_NO_XDEV		0x040000 /* No mountpoint crossing. */
adb21d2b5   Aleksa Sarai   namei: LOOKUP_BEN...
45
  #define LOOKUP_BENEATH		0x080000 /* No escaping from starting point. */
8db52c7e7   Aleksa Sarai   namei: LOOKUP_IN_...
46
  #define LOOKUP_IN_ROOT		0x100000 /* Treat dirfd as fs root. */
adb21d2b5   Aleksa Sarai   namei: LOOKUP_BEN...
47
  /* LOOKUP_* flags which do scope-related checks based on the dirfd. */
8db52c7e7   Aleksa Sarai   namei: LOOKUP_IN_...
48
  #define LOOKUP_IS_SCOPED (LOOKUP_BENEATH | LOOKUP_IN_ROOT)
278121417   Aleksa Sarai   namei: LOOKUP_NO_...
49

eedf265aa   Eric W. Biederman   devpts: Make each...
50
  extern int path_pts(struct path *path);
1fa1e7f61   Andy Whitcroft   readlinkat: ensur...
51
  extern int user_path_at_empty(int, const char __user *, unsigned, struct path *, int *empty);
2d8f30380   Al Viro   [PATCH] sanitize ...
52

b853a1617   Al Viro   turn user_{path_a...
53
54
55
56
57
  static inline int user_path_at(int dfd, const char __user *name, unsigned flags,
  		 struct path *path)
  {
  	return user_path_at_empty(dfd, name, flags, path, NULL);
  }
d18114657   Al Viro   [PATCH] new helpe...
58
  extern int kern_path(const char *, unsigned, struct path *);
1ac12b4b6   Jeff Layton   vfs: turn is_dir ...
59
60
  extern struct dentry *kern_path_create(int, const char *, struct path *, unsigned int);
  extern struct dentry *user_path_create(int, const char __user *, struct path *, unsigned int);
921a1650d   Al Viro   new helper: done_...
61
  extern void done_path_create(struct path *, struct dentry *);
79714f72d   Al Viro   get rid of kern_p...
62
  extern struct dentry *kern_path_locked(const char *, struct path *);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
63

0da0b7fd7   David Howells   afs: Display manu...
64
  extern struct dentry *try_lookup_one_len(const char *, struct dentry *, int);
eead19115   Christoph Hellwig   partially fix up ...
65
  extern struct dentry *lookup_one_len(const char *, struct dentry *, int);
bbddca8e8   NeilBrown   nfsd: don't hold ...
66
  extern struct dentry *lookup_one_len_unlocked(const char *, struct dentry *, int);
6c2d4798a   Al Viro   new helper: looku...
67
  extern struct dentry *lookup_positive_unlocked(const char *, struct dentry *, int);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
68

cc53ce53c   David Howells   Add a dentry op t...
69
  extern int follow_down_one(struct path *);
7cc90cc3f   Al Viro   don't pass 'mount...
70
  extern int follow_down(struct path *);
bab77ebf5   Al Viro   switch follow_up(...
71
  extern int follow_up(struct path *);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
72
73
74
  
  extern struct dentry *lock_rename(struct dentry *, struct dentry *);
  extern void unlock_rename(struct dentry *, struct dentry *);
1bc82070f   Aleksa Sarai   namei: allow nd_j...
75
  extern int __must_check nd_jump_link(struct path *path);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
76

035146851   Duane Griffin   vfs: introduce he...
77
78
79
80
  static inline void nd_terminate_link(void *name, size_t len, size_t maxlen)
  {
  	((char *) name)[min(len, maxlen)] = '\0';
  }
b9d6ba94b   Jeff Layton   vfs: add a retry_...
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
  /**
   * retry_estale - determine whether the caller should retry an operation
   * @error: the error that would currently be returned
   * @flags: flags being used for next lookup attempt
   *
   * Check to see if the error code was -ESTALE, and then determine whether
   * to retry the call based on whether "flags" already has LOOKUP_REVAL set.
   *
   * Returns true if the caller should try the operation again.
   */
  static inline bool
  retry_estale(const long error, const unsigned int flags)
  {
  	return error == -ESTALE && !(flags & LOOKUP_REVAL);
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
96
  #endif /* _LINUX_NAMEI_H */