aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/exportfs.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/exportfs.h')
-rw-r--r--include/linux/exportfs.h141
1 files changed, 73 insertions, 68 deletions
diff --git a/include/linux/exportfs.h b/include/linux/exportfs.h
index 8872fe8392d6..51d214138814 100644
--- a/include/linux/exportfs.h
+++ b/include/linux/exportfs.h
@@ -4,9 +4,48 @@
4#include <linux/types.h> 4#include <linux/types.h>
5 5
6struct dentry; 6struct dentry;
7struct inode;
7struct super_block; 8struct super_block;
8struct vfsmount; 9struct vfsmount;
9 10
11/*
12 * The fileid_type identifies how the file within the filesystem is encoded.
13 * In theory this is freely set and parsed by the filesystem, but we try to
14 * stick to conventions so we can share some generic code and don't confuse
15 * sniffers like ethereal/wireshark.
16 *
17 * The filesystem must not use the value '0' or '0xff'.
18 */
19enum fid_type {
20 /*
21 * The root, or export point, of the filesystem.
22 * (Never actually passed down to the filesystem.
23 */
24 FILEID_ROOT = 0,
25
26 /*
27 * 32bit inode number, 32 bit generation number.
28 */
29 FILEID_INO32_GEN = 1,
30
31 /*
32 * 32bit inode number, 32 bit generation number,
33 * 32 bit parent directory inode number.
34 */
35 FILEID_INO32_GEN_PARENT = 2,
36};
37
38struct fid {
39 union {
40 struct {
41 u32 ino;
42 u32 gen;
43 u32 parent_ino;
44 u32 parent_gen;
45 } i32;
46 __u32 raw[6];
47 };
48};
10 49
11/** 50/**
12 * struct export_operations - for nfsd to communicate with file systems 51 * struct export_operations - for nfsd to communicate with file systems
@@ -15,43 +54,9 @@ struct vfsmount;
15 * @get_name: find the name for a given inode in a given directory 54 * @get_name: find the name for a given inode in a given directory
16 * @get_parent: find the parent of a given directory 55 * @get_parent: find the parent of a given directory
17 * @get_dentry: find a dentry for the inode given a file handle sub-fragment 56 * @get_dentry: find a dentry for the inode given a file handle sub-fragment
18 * @find_exported_dentry:
19 * set by the exporting module to a standard helper function.
20 *
21 * Description:
22 * The export_operations structure provides a means for nfsd to communicate
23 * with a particular exported file system - particularly enabling nfsd and
24 * the filesystem to co-operate when dealing with file handles.
25 *
26 * export_operations contains two basic operation for dealing with file
27 * handles, decode_fh() and encode_fh(), and allows for some other
28 * operations to be defined which standard helper routines use to get
29 * specific information from the filesystem.
30 *
31 * nfsd encodes information use to determine which filesystem a filehandle
32 * applies to in the initial part of the file handle. The remainder, termed
33 * a file handle fragment, is controlled completely by the filesystem. The
34 * standard helper routines assume that this fragment will contain one or
35 * two sub-fragments, one which identifies the file, and one which may be
36 * used to identify the (a) directory containing the file.
37 * 57 *
38 * In some situations, nfsd needs to get a dentry which is connected into a 58 * See Documentation/filesystems/Exporting for details on how to use
39 * specific part of the file tree. To allow for this, it passes the 59 * this interface correctly.
40 * function acceptable() together with a @context which can be used to see
41 * if the dentry is acceptable. As there can be multiple dentrys for a
42 * given file, the filesystem should check each one for acceptability before
43 * looking for the next. As soon as an acceptable one is found, it should
44 * be returned.
45 *
46 * decode_fh:
47 * @decode_fh is given a &struct super_block (@sb), a file handle fragment
48 * (@fh, @fh_len) and an acceptability testing function (@acceptable,
49 * @context). It should return a &struct dentry which refers to the same
50 * file that the file handle fragment refers to, and which passes the
51 * acceptability test. If it cannot, it should return a %NULL pointer if
52 * the file was found but no acceptable &dentries were available, or a
53 * %ERR_PTR error code indicating why it couldn't be found (e.g. %ENOENT or
54 * %ENOMEM).
55 * 60 *
56 * encode_fh: 61 * encode_fh:
57 * @encode_fh should store in the file handle fragment @fh (using at most 62 * @encode_fh should store in the file handle fragment @fh (using at most
@@ -63,6 +68,21 @@ struct vfsmount;
63 * the filehandle fragment. encode_fh() should return the number of bytes 68 * the filehandle fragment. encode_fh() should return the number of bytes
64 * stored or a negative error code such as %-ENOSPC 69 * stored or a negative error code such as %-ENOSPC
65 * 70 *
71 * fh_to_dentry:
72 * @fh_to_dentry is given a &struct super_block (@sb) and a file handle
73 * fragment (@fh, @fh_len). It should return a &struct dentry which refers
74 * to the same file that the file handle fragment refers to. If it cannot,
75 * it should return a %NULL pointer if the file was found but no acceptable
76 * &dentries were available, or an %ERR_PTR error code indicating why it
77 * couldn't be found (e.g. %ENOENT or %ENOMEM). Any suitable dentry can be
78 * returned including, if necessary, a new dentry created with d_alloc_root.
79 * The caller can then find any other extant dentries by following the
80 * d_alias links.
81 *
82 * fh_to_parent:
83 * Same as @fh_to_dentry, except that it returns a pointer to the parent
84 * dentry if it was encoded into the filehandle fragment by @encode_fh.
85 *
66 * get_name: 86 * get_name:
67 * @get_name should find a name for the given @child in the given @parent 87 * @get_name should find a name for the given @child in the given @parent
68 * directory. The name should be stored in the @name (with the 88 * directory. The name should be stored in the @name (with the
@@ -75,52 +95,37 @@ struct vfsmount;
75 * is also a directory. In the event that it cannot be found, or storage 95 * is also a directory. In the event that it cannot be found, or storage
76 * space cannot be allocated, a %ERR_PTR should be returned. 96 * space cannot be allocated, a %ERR_PTR should be returned.
77 * 97 *
78 * get_dentry:
79 * Given a &super_block (@sb) and a pointer to a file-system specific inode
80 * identifier, possibly an inode number, (@inump) get_dentry() should find
81 * the identified inode and return a dentry for that inode. Any suitable
82 * dentry can be returned including, if necessary, a new dentry created with
83 * d_alloc_root. The caller can then find any other extant dentrys by
84 * following the d_alias links. If a new dentry was created using
85 * d_alloc_root, DCACHE_NFSD_DISCONNECTED should be set, and the dentry
86 * should be d_rehash()ed.
87 *
88 * If the inode cannot be found, either a %NULL pointer or an %ERR_PTR code
89 * can be returned. The @inump will be whatever was passed to
90 * nfsd_find_fh_dentry() in either the @obj or @parent parameters.
91 *
92 * Locking rules: 98 * Locking rules:
93 * get_parent is called with child->d_inode->i_mutex down 99 * get_parent is called with child->d_inode->i_mutex down
94 * get_name is not (which is possibly inconsistent) 100 * get_name is not (which is possibly inconsistent)
95 */ 101 */
96 102
97struct export_operations { 103struct export_operations {
98 struct dentry *(*decode_fh)(struct super_block *sb, __u32 *fh,
99 int fh_len, int fh_type,
100 int (*acceptable)(void *context, struct dentry *de),
101 void *context);
102 int (*encode_fh)(struct dentry *de, __u32 *fh, int *max_len, 104 int (*encode_fh)(struct dentry *de, __u32 *fh, int *max_len,
103 int connectable); 105 int connectable);
106 struct dentry * (*fh_to_dentry)(struct super_block *sb, struct fid *fid,
107 int fh_len, int fh_type);
108 struct dentry * (*fh_to_parent)(struct super_block *sb, struct fid *fid,
109 int fh_len, int fh_type);
104 int (*get_name)(struct dentry *parent, char *name, 110 int (*get_name)(struct dentry *parent, char *name,
105 struct dentry *child); 111 struct dentry *child);
106 struct dentry * (*get_parent)(struct dentry *child); 112 struct dentry * (*get_parent)(struct dentry *child);
107 struct dentry * (*get_dentry)(struct super_block *sb, void *inump);
108
109 /* This is set by the exporting module to a standard helper */
110 struct dentry * (*find_exported_dentry)(
111 struct super_block *sb, void *obj, void *parent,
112 int (*acceptable)(void *context, struct dentry *de),
113 void *context);
114}; 113};
115 114
116extern struct dentry *find_exported_dentry(struct super_block *sb, void *obj, 115extern int exportfs_encode_fh(struct dentry *dentry, struct fid *fid,
117 void *parent, int (*acceptable)(void *context, struct dentry *de), 116 int *max_len, int connectable);
118 void *context); 117extern struct dentry *exportfs_decode_fh(struct vfsmount *mnt, struct fid *fid,
119
120extern int exportfs_encode_fh(struct dentry *dentry, __u32 *fh, int *max_len,
121 int connectable);
122extern struct dentry *exportfs_decode_fh(struct vfsmount *mnt, __u32 *fh,
123 int fh_len, int fileid_type, int (*acceptable)(void *, struct dentry *), 118 int fh_len, int fileid_type, int (*acceptable)(void *, struct dentry *),
124 void *context); 119 void *context);
125 120
121/*
122 * Generic helpers for filesystems.
123 */
124extern struct dentry *generic_fh_to_dentry(struct super_block *sb,
125 struct fid *fid, int fh_len, int fh_type,
126 struct inode *(*get_inode) (struct super_block *sb, u64 ino, u32 gen));
127extern struct dentry *generic_fh_to_parent(struct super_block *sb,
128 struct fid *fid, int fh_len, int fh_type,
129 struct inode *(*get_inode) (struct super_block *sb, u64 ino, u32 gen));
130
126#endif /* LINUX_EXPORTFS_H */ 131#endif /* LINUX_EXPORTFS_H */