namei: move saved_nd pointer into struct nameidata
[deliverable/linux.git] / include / linux / namei.h
CommitLineData
1da177e4
LT
1#ifndef _LINUX_NAMEI_H
2#define _LINUX_NAMEI_H
3
82b0547c 4#include <linux/dcache.h>
08b60f84 5#include <linux/errno.h>
1da177e4 6#include <linux/linkage.h>
c5e725f3 7#include <linux/path.h>
1da177e4
LT
8
9struct vfsmount;
10
737bebd1 11enum { MAX_NESTED_LINKS = 8 };
1da177e4 12
894bc8c4
AV
13#define MAXSYMLINKS 40
14
1da177e4
LT
15/*
16 * Type of the last component on LOOKUP_PARENT
17 */
18enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT, LAST_BIND};
19
20/*
21 * The bitmask for a lookup event:
22 * - follow links at the end
23 * - require a directory
24 * - ending slashes ok even for nonexistent files
47a0dfaa 25 * - internal "there are more path components" flag
1da177e4 26 * - dentry cache is untrusted; force a real lookup
6f45b656 27 * - suppress terminal automount
1da177e4 28 */
31e6b01f
NP
29#define LOOKUP_FOLLOW 0x0001
30#define LOOKUP_DIRECTORY 0x0002
d94c177b 31#define LOOKUP_AUTOMOUNT 0x0004
31e6b01f
NP
32
33#define LOOKUP_PARENT 0x0010
34#define LOOKUP_REVAL 0x0020
35#define LOOKUP_RCU 0x0040
b6c8069d 36
1da177e4
LT
37/*
38 * Intent data
39 */
3516586a
AV
40#define LOOKUP_OPEN 0x0100
41#define LOOKUP_CREATE 0x0200
42#define LOOKUP_EXCL 0x0400
4e9ed2f8 43#define LOOKUP_RENAME_TARGET 0x0800
1da177e4 44
16c2cd71 45#define LOOKUP_JUMPED 0x1000
5b6ca027 46#define LOOKUP_ROOT 0x2000
f52e0c11 47#define LOOKUP_EMPTY 0x4000
16c2cd71 48
2d8f3038 49extern int user_path_at(int, const char __user *, unsigned, struct path *);
1fa1e7f6 50extern int user_path_at_empty(int, const char __user *, unsigned, struct path *, int *empty);
2d8f3038
AV
51
52#define user_path(name, path) user_path_at(AT_FDCWD, name, LOOKUP_FOLLOW, path)
53#define user_lpath(name, path) user_path_at(AT_FDCWD, name, 0, path)
54#define user_path_dir(name, path) \
55 user_path_at(AT_FDCWD, name, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, path)
56
d1811465
AV
57extern int kern_path(const char *, unsigned, struct path *);
58
1ac12b4b
JL
59extern struct dentry *kern_path_create(int, const char *, struct path *, unsigned int);
60extern struct dentry *user_path_create(int, const char __user *, struct path *, unsigned int);
921a1650 61extern void done_path_create(struct path *, struct dentry *);
79714f72 62extern struct dentry *kern_path_locked(const char *, struct path *);
2d864651 63extern int kern_path_mountpoint(int, const char *, struct path *, unsigned int);
1da177e4 64
eead1911 65extern struct dentry *lookup_one_len(const char *, struct dentry *, int);
1da177e4 66
cc53ce53 67extern int follow_down_one(struct path *);
7cc90cc3 68extern int follow_down(struct path *);
bab77ebf 69extern int follow_up(struct path *);
1da177e4
LT
70
71extern struct dentry *lock_rename(struct dentry *, struct dentry *);
72extern void unlock_rename(struct dentry *, struct dentry *);
73
6e77137b 74extern void nd_jump_link(struct path *path);
1da177e4 75
03514685
DG
76static inline void nd_terminate_link(void *name, size_t len, size_t maxlen)
77{
78 ((char *) name)[min(len, maxlen)] = '\0';
79}
80
b9d6ba94
JL
81/**
82 * retry_estale - determine whether the caller should retry an operation
83 * @error: the error that would currently be returned
84 * @flags: flags being used for next lookup attempt
85 *
86 * Check to see if the error code was -ESTALE, and then determine whether
87 * to retry the call based on whether "flags" already has LOOKUP_REVAL set.
88 *
89 * Returns true if the caller should try the operation again.
90 */
91static inline bool
92retry_estale(const long error, const unsigned int flags)
93{
94 return error == -ESTALE && !(flags & LOOKUP_REVAL);
95}
96
1da177e4 97#endif /* _LINUX_NAMEI_H */
This page took 1.099803 seconds and 5 git commands to generate.