diff options
Diffstat (limited to 'include/linux/exportfs.h')
-rw-r--r-- | include/linux/exportfs.h | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/include/linux/exportfs.h b/include/linux/exportfs.h new file mode 100644 index 000000000000..fdc306fbba50 --- /dev/null +++ b/include/linux/exportfs.h | |||
@@ -0,0 +1,119 @@ | |||
1 | #ifndef LINUX_EXPORTFS_H | ||
2 | #define LINUX_EXPORTFS_H 1 | ||
3 | |||
4 | #include <linux/types.h> | ||
5 | |||
6 | struct dentry; | ||
7 | struct super_block; | ||
8 | |||
9 | |||
10 | /** | ||
11 | * struct export_operations - for nfsd to communicate with file systems | ||
12 | * @decode_fh: decode a file handle fragment and return a &struct dentry | ||
13 | * @encode_fh: encode a file handle fragment from a dentry | ||
14 | * @get_name: find the name for a given inode in a given directory | ||
15 | * @get_parent: find the parent of a given directory | ||
16 | * @get_dentry: find a dentry for the inode given a file handle sub-fragment | ||
17 | * @find_exported_dentry: | ||
18 | * set by the exporting module to a standard helper function. | ||
19 | * | ||
20 | * Description: | ||
21 | * The export_operations structure provides a means for nfsd to communicate | ||
22 | * with a particular exported file system - particularly enabling nfsd and | ||
23 | * the filesystem to co-operate when dealing with file handles. | ||
24 | * | ||
25 | * export_operations contains two basic operation for dealing with file | ||
26 | * handles, decode_fh() and encode_fh(), and allows for some other | ||
27 | * operations to be defined which standard helper routines use to get | ||
28 | * specific information from the filesystem. | ||
29 | * | ||
30 | * nfsd encodes information use to determine which filesystem a filehandle | ||
31 | * applies to in the initial part of the file handle. The remainder, termed | ||
32 | * a file handle fragment, is controlled completely by the filesystem. The | ||
33 | * standard helper routines assume that this fragment will contain one or | ||
34 | * two sub-fragments, one which identifies the file, and one which may be | ||
35 | * used to identify the (a) directory containing the file. | ||
36 | * | ||
37 | * In some situations, nfsd needs to get a dentry which is connected into a | ||
38 | * specific part of the file tree. To allow for this, it passes the | ||
39 | * function acceptable() together with a @context which can be used to see | ||
40 | * if the dentry is acceptable. As there can be multiple dentrys for a | ||
41 | * given file, the filesystem should check each one for acceptability before | ||
42 | * looking for the next. As soon as an acceptable one is found, it should | ||
43 | * be returned. | ||
44 | * | ||
45 | * decode_fh: | ||
46 | * @decode_fh is given a &struct super_block (@sb), a file handle fragment | ||
47 | * (@fh, @fh_len) and an acceptability testing function (@acceptable, | ||
48 | * @context). It should return a &struct dentry which refers to the same | ||
49 | * file that the file handle fragment refers to, and which passes the | ||
50 | * acceptability test. If it cannot, it should return a %NULL pointer if | ||
51 | * the file was found but no acceptable &dentries were available, or a | ||
52 | * %ERR_PTR error code indicating why it couldn't be found (e.g. %ENOENT or | ||
53 | * %ENOMEM). | ||
54 | * | ||
55 | * encode_fh: | ||
56 | * @encode_fh should store in the file handle fragment @fh (using at most | ||
57 | * @max_len bytes) information that can be used by @decode_fh to recover the | ||
58 | * file refered to by the &struct dentry @de. If the @connectable flag is | ||
59 | * set, the encode_fh() should store sufficient information so that a good | ||
60 | * attempt can be made to find not only the file but also it's place in the | ||
61 | * filesystem. This typically means storing a reference to de->d_parent in | ||
62 | * the filehandle fragment. encode_fh() should return the number of bytes | ||
63 | * stored or a negative error code such as %-ENOSPC | ||
64 | * | ||
65 | * get_name: | ||
66 | * @get_name should find a name for the given @child in the given @parent | ||
67 | * directory. The name should be stored in the @name (with the | ||
68 | * understanding that it is already pointing to a a %NAME_MAX+1 sized | ||
69 | * buffer. get_name() should return %0 on success, a negative error code | ||
70 | * or error. @get_name will be called without @parent->i_mutex held. | ||
71 | * | ||
72 | * get_parent: | ||
73 | * @get_parent should find the parent directory for the given @child which | ||
74 | * is also a directory. In the event that it cannot be found, or storage | ||
75 | * space cannot be allocated, a %ERR_PTR should be returned. | ||
76 | * | ||
77 | * get_dentry: | ||
78 | * Given a &super_block (@sb) and a pointer to a file-system specific inode | ||
79 | * identifier, possibly an inode number, (@inump) get_dentry() should find | ||
80 | * the identified inode and return a dentry for that inode. Any suitable | ||
81 | * dentry can be returned including, if necessary, a new dentry created with | ||
82 | * d_alloc_root. The caller can then find any other extant dentrys by | ||
83 | * following the d_alias links. If a new dentry was created using | ||
84 | * d_alloc_root, DCACHE_NFSD_DISCONNECTED should be set, and the dentry | ||
85 | * should be d_rehash()ed. | ||
86 | * | ||
87 | * If the inode cannot be found, either a %NULL pointer or an %ERR_PTR code | ||
88 | * can be returned. The @inump will be whatever was passed to | ||
89 | * nfsd_find_fh_dentry() in either the @obj or @parent parameters. | ||
90 | * | ||
91 | * Locking rules: | ||
92 | * get_parent is called with child->d_inode->i_mutex down | ||
93 | * get_name is not (which is possibly inconsistent) | ||
94 | */ | ||
95 | |||
96 | struct export_operations { | ||
97 | struct dentry *(*decode_fh)(struct super_block *sb, __u32 *fh, | ||
98 | int fh_len, int fh_type, | ||
99 | int (*acceptable)(void *context, struct dentry *de), | ||
100 | void *context); | ||
101 | int (*encode_fh)(struct dentry *de, __u32 *fh, int *max_len, | ||
102 | int connectable); | ||
103 | int (*get_name)(struct dentry *parent, char *name, | ||
104 | struct dentry *child); | ||
105 | struct dentry * (*get_parent)(struct dentry *child); | ||
106 | struct dentry * (*get_dentry)(struct super_block *sb, void *inump); | ||
107 | |||
108 | /* This is set by the exporting module to a standard helper */ | ||
109 | struct dentry * (*find_exported_dentry)( | ||
110 | struct super_block *sb, void *obj, void *parent, | ||
111 | int (*acceptable)(void *context, struct dentry *de), | ||
112 | void *context); | ||
113 | }; | ||
114 | |||
115 | extern struct dentry *find_exported_dentry(struct super_block *sb, void *obj, | ||
116 | void *parent, int (*acceptable)(void *context, struct dentry *de), | ||
117 | void *context); | ||
118 | |||
119 | #endif /* LINUX_EXPORTFS_H */ | ||