1#ifndef _LINUX_NAMEI_H
2#define _LINUX_NAMEI_H
3
4#include <linux/dcache.h>
5#include <linux/errno.h>
6#include <linux/linkage.h>
7#include <linux/path.h>
8
9struct vfsmount;
10
11enum { MAX_NESTED_LINKS = 8 };
12
13struct nameidata {
14 struct path path;
15 struct qstr last;
16 struct path root;
17 struct inode *inode;
18 unsigned int flags;
19 unsigned seq;
20 int last_type;
21 unsigned depth;
22 char *saved_names[MAX_NESTED_LINKS + 1];
23 RH_KABI_EXTEND(unsigned m_seq)
24};
25
26
27
28
29enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT, LAST_BIND};
30
31
32
33
34
35
36
37
38
39
40#define LOOKUP_FOLLOW 0x0001
41#define LOOKUP_DIRECTORY 0x0002
42#define LOOKUP_AUTOMOUNT 0x0004
43
44#define LOOKUP_PARENT 0x0010
45#define LOOKUP_REVAL 0x0020
46#define LOOKUP_RCU 0x0040
47
48
49
50
51#define LOOKUP_OPEN 0x0100
52#define LOOKUP_CREATE 0x0200
53#define LOOKUP_EXCL 0x0400
54#define LOOKUP_RENAME_TARGET 0x0800
55
56#define LOOKUP_JUMPED 0x1000
57#define LOOKUP_ROOT 0x2000
58#define LOOKUP_EMPTY 0x4000
59#define LOOKUP_DOWN 0x8000
60
61extern int user_path_at(int, const char __user *, unsigned, struct path *);
62extern int user_path_at_empty(int, const char __user *, unsigned, struct path *, int *empty);
63
64#define user_path(name, path) user_path_at(AT_FDCWD, name, LOOKUP_FOLLOW, path)
65#define user_lpath(name, path) user_path_at(AT_FDCWD, name, 0, path)
66#define user_path_dir(name, path) \
67 user_path_at(AT_FDCWD, name, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, path)
68
69extern int kern_path(const char *, unsigned, struct path *);
70
71extern struct dentry *kern_path_create(int, const char *, struct path *, unsigned int);
72extern struct dentry *user_path_create(int, const char __user *, struct path *, unsigned int);
73extern void done_path_create(struct path *, struct dentry *);
74extern struct dentry *kern_path_locked(const char *, struct path *);
75extern int kern_path_mountpoint(int, const char *, struct path *, unsigned int);
76
77extern struct dentry *lookup_one_len(const char *, struct dentry *, int);
78extern struct dentry *lookup_one_len_unlocked(const char *, struct dentry *, int);
79
80extern int follow_down_one(struct path *);
81extern int follow_down(struct path *);
82extern int follow_up(struct path *);
83
84extern struct dentry *lock_rename(struct dentry *, struct dentry *);
85extern void unlock_rename(struct dentry *, struct dentry *);
86
87extern void nd_jump_link(struct nameidata *nd, struct path *path);
88
89static inline void nd_set_link(struct nameidata *nd, char *path)
90{
91 nd->saved_names[nd->depth] = path;
92}
93
94static inline char *nd_get_link(struct nameidata *nd)
95{
96 return nd->saved_names[nd->depth];
97}
98
99static inline void nd_terminate_link(void *name, size_t len, size_t maxlen)
100{
101 ((char *) name)[min(len, maxlen)] = '\0';
102}
103
104
105
106
107
108
109
110
111
112
113
114static inline bool
115retry_estale(const long error, const unsigned int flags)
116{
117 return error == -ESTALE && !(flags & LOOKUP_REVAL);
118}
119
120#endif
121