0001
0002 #ifndef _LINUX_NAMEI_H
0003 #define _LINUX_NAMEI_H
0004
0005 #include <linux/fs.h>
0006 #include <linux/kernel.h>
0007 #include <linux/path.h>
0008 #include <linux/fcntl.h>
0009 #include <linux/errno.h>
0010
0011 enum { MAX_NESTED_LINKS = 8 };
0012
0013 #define MAXSYMLINKS 40
0014
0015
0016
0017
0018 enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT};
0019
0020
0021 #define LOOKUP_FOLLOW 0x0001
0022 #define LOOKUP_DIRECTORY 0x0002
0023 #define LOOKUP_AUTOMOUNT 0x0004
0024 #define LOOKUP_EMPTY 0x4000
0025 #define LOOKUP_DOWN 0x8000
0026 #define LOOKUP_MOUNTPOINT 0x0080
0027
0028 #define LOOKUP_REVAL 0x0020
0029 #define LOOKUP_RCU 0x0040
0030
0031
0032 #define LOOKUP_OPEN 0x0100
0033 #define LOOKUP_CREATE 0x0200
0034 #define LOOKUP_EXCL 0x0400
0035 #define LOOKUP_RENAME_TARGET 0x0800
0036
0037
0038 #define LOOKUP_PARENT 0x0010
0039
0040
0041 #define LOOKUP_NO_SYMLINKS 0x010000
0042 #define LOOKUP_NO_MAGICLINKS 0x020000
0043 #define LOOKUP_NO_XDEV 0x040000
0044 #define LOOKUP_BENEATH 0x080000
0045 #define LOOKUP_IN_ROOT 0x100000
0046 #define LOOKUP_CACHED 0x200000
0047
0048 #define LOOKUP_IS_SCOPED (LOOKUP_BENEATH | LOOKUP_IN_ROOT)
0049
0050 extern int path_pts(struct path *path);
0051
0052 extern int user_path_at_empty(int, const char __user *, unsigned, struct path *, int *empty);
0053
0054 static inline int user_path_at(int dfd, const char __user *name, unsigned flags,
0055 struct path *path)
0056 {
0057 return user_path_at_empty(dfd, name, flags, path, NULL);
0058 }
0059
0060 extern int kern_path(const char *, unsigned, struct path *);
0061
0062 extern struct dentry *kern_path_create(int, const char *, struct path *, unsigned int);
0063 extern struct dentry *user_path_create(int, const char __user *, struct path *, unsigned int);
0064 extern void done_path_create(struct path *, struct dentry *);
0065 extern struct dentry *kern_path_locked(const char *, struct path *);
0066
0067 extern struct dentry *try_lookup_one_len(const char *, struct dentry *, int);
0068 extern struct dentry *lookup_one_len(const char *, struct dentry *, int);
0069 extern struct dentry *lookup_one_len_unlocked(const char *, struct dentry *, int);
0070 extern struct dentry *lookup_positive_unlocked(const char *, struct dentry *, int);
0071 struct dentry *lookup_one(struct user_namespace *, const char *, struct dentry *, int);
0072 struct dentry *lookup_one_unlocked(struct user_namespace *mnt_userns,
0073 const char *name, struct dentry *base,
0074 int len);
0075 struct dentry *lookup_one_positive_unlocked(struct user_namespace *mnt_userns,
0076 const char *name,
0077 struct dentry *base, int len);
0078
0079 extern int follow_down_one(struct path *);
0080 extern int follow_down(struct path *);
0081 extern int follow_up(struct path *);
0082
0083 extern struct dentry *lock_rename(struct dentry *, struct dentry *);
0084 extern void unlock_rename(struct dentry *, struct dentry *);
0085
0086 extern int __must_check nd_jump_link(struct path *path);
0087
0088 static inline void nd_terminate_link(void *name, size_t len, size_t maxlen)
0089 {
0090 ((char *) name)[min(len, maxlen)] = '\0';
0091 }
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103 static inline bool
0104 retry_estale(const long error, const unsigned int flags)
0105 {
0106 return error == -ESTALE && !(flags & LOOKUP_REVAL);
0107 }
0108
0109 #endif