Blame view
include/linux/exportfs.h
5.94 KB
a56942551
|
1 2 3 4 5 6 |
#ifndef LINUX_EXPORTFS_H #define LINUX_EXPORTFS_H 1 #include <linux/types.h> struct dentry; |
2596110a3
|
7 |
struct inode; |
a56942551
|
8 |
struct super_block; |
d37065cd6
|
9 |
struct vfsmount; |
a56942551
|
10 |
|
6e91ea2bb
|
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
/* * The fileid_type identifies how the file within the filesystem is encoded. * In theory this is freely set and parsed by the filesystem, but we try to * stick to conventions so we can share some generic code and don't confuse * sniffers like ethereal/wireshark. * * The filesystem must not use the value '0' or '0xff'. */ enum fid_type { /* * The root, or export point, of the filesystem. * (Never actually passed down to the filesystem. */ FILEID_ROOT = 0, /* * 32bit inode number, 32 bit generation number. */ FILEID_INO32_GEN = 1, /* * 32bit inode number, 32 bit generation number, * 32 bit parent directory inode number. */ FILEID_INO32_GEN_PARENT = 2, |
221e583a7
|
36 37 |
/* |
e4464facd
|
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
* 64 bit object ID, 64 bit root object ID, * 32 bit generation number. */ FILEID_BTRFS_WITHOUT_PARENT = 0x4d, /* * 64 bit object ID, 64 bit root object ID, * 32 bit generation number, * 64 bit parent object ID, 32 bit parent generation. */ FILEID_BTRFS_WITH_PARENT = 0x4e, /* * 64 bit object ID, 64 bit root object ID, * 32 bit generation number, * 64 bit parent object ID, 32 bit parent generation, * 64 bit parent root object ID. */ FILEID_BTRFS_WITH_PARENT_ROOT = 0x4f, /* |
221e583a7
|
59 60 61 62 63 64 65 66 67 68 69 |
* 32 bit block number, 16 bit partition reference, * 16 bit unused, 32 bit generation number. */ FILEID_UDF_WITHOUT_PARENT = 0x51, /* * 32 bit block number, 16 bit partition reference, * 16 bit unused, 32 bit generation number, * 32 bit parent block number, 32 bit parent generation number */ FILEID_UDF_WITH_PARENT = 0x52, |
6e91ea2bb
|
70 71 72 73 74 75 76 77 78 79 |
}; struct fid { union { struct { u32 ino; u32 gen; u32 parent_ino; u32 parent_gen; } i32; |
221e583a7
|
80 81 82 83 84 85 86 87 |
struct { u32 block; u16 partref; u16 parent_partref; u32 generation; u32 parent_block; u32 parent_generation; } udf; |
9078dc081
|
88 |
__u32 raw[0]; |
6e91ea2bb
|
89 90 |
}; }; |
a56942551
|
91 92 93 |
/** * struct export_operations - for nfsd to communicate with file systems |
a56942551
|
94 |
* @encode_fh: encode a file handle fragment from a dentry |
9b89ca7a3
|
95 96 |
* @fh_to_dentry: find the implied object and get a dentry for it * @fh_to_parent: find the implied object's parent and get a dentry for it |
a56942551
|
97 98 |
* @get_name: find the name for a given inode in a given directory * @get_parent: find the parent of a given directory |
f501912a3
|
99 |
* @commit_metadata: commit metadata changes to stable storage |
a56942551
|
100 |
* |
dc7a08166
|
101 |
* See Documentation/filesystems/nfs/Exporting for details on how to use |
e38f98175
|
102 |
* this interface correctly. |
a56942551
|
103 |
* |
a56942551
|
104 105 106 107 108 109 110 111 112 113 |
* encode_fh: * @encode_fh should store in the file handle fragment @fh (using at most * @max_len bytes) information that can be used by @decode_fh to recover the * file refered to by the &struct dentry @de. If the @connectable flag is * set, the encode_fh() should store sufficient information so that a good * attempt can be made to find not only the file but also it's place in the * filesystem. This typically means storing a reference to de->d_parent in * the filehandle fragment. encode_fh() should return the number of bytes * stored or a negative error code such as %-ENOSPC * |
2596110a3
|
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
* fh_to_dentry: * @fh_to_dentry is given a &struct super_block (@sb) and a file handle * fragment (@fh, @fh_len). It should return a &struct dentry which refers * to the same file that the file handle fragment refers to. If it cannot, * it should return a %NULL pointer if the file was found but no acceptable * &dentries were available, or an %ERR_PTR error code indicating why it * couldn't be found (e.g. %ENOENT or %ENOMEM). Any suitable dentry can be * returned including, if necessary, a new dentry created with d_alloc_root. * The caller can then find any other extant dentries by following the * d_alias links. * * fh_to_parent: * Same as @fh_to_dentry, except that it returns a pointer to the parent * dentry if it was encoded into the filehandle fragment by @encode_fh. * |
a56942551
|
129 130 131 132 133 134 135 136 137 138 139 140 |
* get_name: * @get_name should find a name for the given @child in the given @parent * directory. The name should be stored in the @name (with the * understanding that it is already pointing to a a %NAME_MAX+1 sized * buffer. get_name() should return %0 on success, a negative error code * or error. @get_name will be called without @parent->i_mutex held. * * get_parent: * @get_parent should find the parent directory for the given @child which * is also a directory. In the event that it cannot be found, or storage * space cannot be allocated, a %ERR_PTR should be returned. * |
f501912a3
|
141 142 143 |
* commit_metadata: * @commit_metadata should commit metadata changes to stable storage. * |
a56942551
|
144 145 146 147 148 149 |
* Locking rules: * get_parent is called with child->d_inode->i_mutex down * get_name is not (which is possibly inconsistent) */ struct export_operations { |
a56942551
|
150 151 |
int (*encode_fh)(struct dentry *de, __u32 *fh, int *max_len, int connectable); |
2596110a3
|
152 153 154 155 |
struct dentry * (*fh_to_dentry)(struct super_block *sb, struct fid *fid, int fh_len, int fh_type); struct dentry * (*fh_to_parent)(struct super_block *sb, struct fid *fid, int fh_len, int fh_type); |
a56942551
|
156 157 158 |
int (*get_name)(struct dentry *parent, char *name, struct dentry *child); struct dentry * (*get_parent)(struct dentry *child); |
f501912a3
|
159 |
int (*commit_metadata)(struct inode *inode); |
a56942551
|
160 |
}; |
6e91ea2bb
|
161 162 163 |
extern int exportfs_encode_fh(struct dentry *dentry, struct fid *fid, int *max_len, int connectable); extern struct dentry *exportfs_decode_fh(struct vfsmount *mnt, struct fid *fid, |
d37065cd6
|
164 165 |
int fh_len, int fileid_type, int (*acceptable)(void *, struct dentry *), void *context); |
2596110a3
|
166 167 168 169 170 171 172 173 174 |
/* * Generic helpers for filesystems. */ extern struct dentry *generic_fh_to_dentry(struct super_block *sb, struct fid *fid, int fh_len, int fh_type, struct inode *(*get_inode) (struct super_block *sb, u64 ino, u32 gen)); extern struct dentry *generic_fh_to_parent(struct super_block *sb, struct fid *fid, int fh_len, int fh_type, struct inode *(*get_inode) (struct super_block *sb, u64 ino, u32 gen)); |
a56942551
|
175 |
#endif /* LINUX_EXPORTFS_H */ |