xref: /linux-6.15/include/linux/exportfs.h (revision 9254c8ae)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2a5694255SChristoph Hellwig #ifndef LINUX_EXPORTFS_H
3a5694255SChristoph Hellwig #define LINUX_EXPORTFS_H 1
4a5694255SChristoph Hellwig 
5a5694255SChristoph Hellwig #include <linux/types.h>
6c220e216SChristian Brauner #include <linux/path.h>
7a5694255SChristoph Hellwig 
8a5694255SChristoph Hellwig struct dentry;
97fbc1067SChristoph Hellwig struct iattr;
102596110aSChristoph Hellwig struct inode;
11199a31c6SChristoph Hellwig struct iomap;
12a5694255SChristoph Hellwig struct super_block;
13d37065cdSChristoph Hellwig struct vfsmount;
14a5694255SChristoph Hellwig 
15990d6c2dSAneesh Kumar K.V /* limit the handle size to NFSv4 handle size now */
16990d6c2dSAneesh Kumar K.V #define MAX_HANDLE_SZ 128
17990d6c2dSAneesh Kumar K.V 
186e91ea2bSChristoph Hellwig /*
196e91ea2bSChristoph Hellwig  * The fileid_type identifies how the file within the filesystem is encoded.
206e91ea2bSChristoph Hellwig  * In theory this is freely set and parsed by the filesystem, but we try to
216e91ea2bSChristoph Hellwig  * stick to conventions so we can share some generic code and don't confuse
226e91ea2bSChristoph Hellwig  * sniffers like ethereal/wireshark.
236e91ea2bSChristoph Hellwig  *
246e91ea2bSChristoph Hellwig  * The filesystem must not use the value '0' or '0xff'.
256e91ea2bSChristoph Hellwig  */
266e91ea2bSChristoph Hellwig enum fid_type {
276e91ea2bSChristoph Hellwig 	/*
286e91ea2bSChristoph Hellwig 	 * The root, or export point, of the filesystem.
296e91ea2bSChristoph Hellwig 	 * (Never actually passed down to the filesystem.
306e91ea2bSChristoph Hellwig 	 */
316e91ea2bSChristoph Hellwig 	FILEID_ROOT = 0,
326e91ea2bSChristoph Hellwig 
336e91ea2bSChristoph Hellwig 	/*
346e91ea2bSChristoph Hellwig 	 * 32bit inode number, 32 bit generation number.
356e91ea2bSChristoph Hellwig 	 */
366e91ea2bSChristoph Hellwig 	FILEID_INO32_GEN = 1,
376e91ea2bSChristoph Hellwig 
386e91ea2bSChristoph Hellwig 	/*
396e91ea2bSChristoph Hellwig 	 * 32bit inode number, 32 bit generation number,
406e91ea2bSChristoph Hellwig 	 * 32 bit parent directory inode number.
416e91ea2bSChristoph Hellwig 	 */
426e91ea2bSChristoph Hellwig 	FILEID_INO32_GEN_PARENT = 2,
43221e583aSRasmus Rohde 
44221e583aSRasmus Rohde 	/*
45e4464facSDavid Woodhouse 	 * 64 bit object ID, 64 bit root object ID,
46e4464facSDavid Woodhouse 	 * 32 bit generation number.
47e4464facSDavid Woodhouse 	 */
48e4464facSDavid Woodhouse 	FILEID_BTRFS_WITHOUT_PARENT = 0x4d,
49e4464facSDavid Woodhouse 
50e4464facSDavid Woodhouse 	/*
51e4464facSDavid Woodhouse 	 * 64 bit object ID, 64 bit root object ID,
52e4464facSDavid Woodhouse 	 * 32 bit generation number,
53e4464facSDavid Woodhouse 	 * 64 bit parent object ID, 32 bit parent generation.
54e4464facSDavid Woodhouse 	 */
55e4464facSDavid Woodhouse 	FILEID_BTRFS_WITH_PARENT = 0x4e,
56e4464facSDavid Woodhouse 
57e4464facSDavid Woodhouse 	/*
58e4464facSDavid Woodhouse 	 * 64 bit object ID, 64 bit root object ID,
59e4464facSDavid Woodhouse 	 * 32 bit generation number,
60e4464facSDavid Woodhouse 	 * 64 bit parent object ID, 32 bit parent generation,
61e4464facSDavid Woodhouse 	 * 64 bit parent root object ID.
62e4464facSDavid Woodhouse 	 */
63e4464facSDavid Woodhouse 	FILEID_BTRFS_WITH_PARENT_ROOT = 0x4f,
64e4464facSDavid Woodhouse 
65e4464facSDavid Woodhouse 	/*
66221e583aSRasmus Rohde 	 * 32 bit block number, 16 bit partition reference,
67221e583aSRasmus Rohde 	 * 16 bit unused, 32 bit generation number.
68221e583aSRasmus Rohde 	 */
69221e583aSRasmus Rohde 	FILEID_UDF_WITHOUT_PARENT = 0x51,
70221e583aSRasmus Rohde 
71221e583aSRasmus Rohde 	/*
72221e583aSRasmus Rohde 	 * 32 bit block number, 16 bit partition reference,
73221e583aSRasmus Rohde 	 * 16 bit unused, 32 bit generation number,
74221e583aSRasmus Rohde 	 * 32 bit parent block number, 32 bit parent generation number
75221e583aSRasmus Rohde 	 */
76221e583aSRasmus Rohde 	FILEID_UDF_WITH_PARENT = 0x52,
778e656fd5SRyusuke Konishi 
788e656fd5SRyusuke Konishi 	/*
798e656fd5SRyusuke Konishi 	 * 64 bit checkpoint number, 64 bit inode number,
808e656fd5SRyusuke Konishi 	 * 32 bit generation number.
818e656fd5SRyusuke Konishi 	 */
828e656fd5SRyusuke Konishi 	FILEID_NILFS_WITHOUT_PARENT = 0x61,
838e656fd5SRyusuke Konishi 
848e656fd5SRyusuke Konishi 	/*
858e656fd5SRyusuke Konishi 	 * 64 bit checkpoint number, 64 bit inode number,
868e656fd5SRyusuke Konishi 	 * 32 bit generation number, 32 bit parent generation.
878e656fd5SRyusuke Konishi 	 * 64 bit parent inode number.
888e656fd5SRyusuke Konishi 	 */
898e656fd5SRyusuke Konishi 	FILEID_NILFS_WITH_PARENT = 0x62,
90216b6cbdSNamjae Jeon 
91216b6cbdSNamjae Jeon 	/*
92ea3983acSNamjae Jeon 	 * 32 bit generation number, 40 bit i_pos.
93ea3983acSNamjae Jeon 	 */
94ea3983acSNamjae Jeon 	FILEID_FAT_WITHOUT_PARENT = 0x71,
95ea3983acSNamjae Jeon 
96ea3983acSNamjae Jeon 	/*
97ea3983acSNamjae Jeon 	 * 32 bit generation number, 40 bit i_pos,
98ea3983acSNamjae Jeon 	 * 32 bit parent generation number, 40 bit parent i_pos
99ea3983acSNamjae Jeon 	 */
100ea3983acSNamjae Jeon 	FILEID_FAT_WITH_PARENT = 0x72,
101ea3983acSNamjae Jeon 
102ea3983acSNamjae Jeon 	/*
10341d1ddd2SAmir Goldstein 	 * 64 bit inode number, 32 bit generation number.
10441d1ddd2SAmir Goldstein 	 */
10541d1ddd2SAmir Goldstein 	FILEID_INO64_GEN = 0x81,
10641d1ddd2SAmir Goldstein 
10741d1ddd2SAmir Goldstein 	/*
10841d1ddd2SAmir Goldstein 	 * 64 bit inode number, 32 bit generation number,
10941d1ddd2SAmir Goldstein 	 * 64 bit parent inode number, 32 bit parent generation.
11041d1ddd2SAmir Goldstein 	 */
11141d1ddd2SAmir Goldstein 	FILEID_INO64_GEN_PARENT = 0x82,
11241d1ddd2SAmir Goldstein 
11341d1ddd2SAmir Goldstein 	/*
114cb776592SDmitry Eremin 	 * 128 bit child FID (struct lu_fid)
115cb776592SDmitry Eremin 	 * 128 bit parent FID (struct lu_fid)
116cb776592SDmitry Eremin 	 */
117cb776592SDmitry Eremin 	FILEID_LUSTRE = 0x97,
118cb776592SDmitry Eremin 
119cb776592SDmitry Eremin 	/*
120b827ac41SKent Overstreet 	 * 64 bit inode number, 32 bit subvolume, 32 bit generation number:
121b827ac41SKent Overstreet 	 */
122b827ac41SKent Overstreet 	FILEID_BCACHEFS_WITHOUT_PARENT = 0xb1,
123b827ac41SKent Overstreet 	FILEID_BCACHEFS_WITH_PARENT = 0xb2,
124b827ac41SKent Overstreet 
125b827ac41SKent Overstreet 	/*
12633c5ac91STejun Heo 	 * 64 bit unique kernfs id
12733c5ac91STejun Heo 	 */
12833c5ac91STejun Heo 	FILEID_KERNFS = 0xfe,
12933c5ac91STejun Heo 
13033c5ac91STejun Heo 	/*
131216b6cbdSNamjae Jeon 	 * Filesystems must not use 0xff file ID.
132216b6cbdSNamjae Jeon 	 */
133216b6cbdSNamjae Jeon 	FILEID_INVALID = 0xff,
1346e91ea2bSChristoph Hellwig };
1356e91ea2bSChristoph Hellwig 
1366e91ea2bSChristoph Hellwig struct fid {
1376e91ea2bSChristoph Hellwig 	union {
1386e91ea2bSChristoph Hellwig 		struct {
1396e91ea2bSChristoph Hellwig 			u32 ino;
1406e91ea2bSChristoph Hellwig 			u32 gen;
1416e91ea2bSChristoph Hellwig 			u32 parent_ino;
1426e91ea2bSChristoph Hellwig 			u32 parent_gen;
1436e91ea2bSChristoph Hellwig 		} i32;
144221e583aSRasmus Rohde 		struct {
14564343119SAmir Goldstein 			u64 ino;
14664343119SAmir Goldstein 			u32 gen;
14764343119SAmir Goldstein 		} __packed i64;
14864343119SAmir Goldstein 		struct {
149221e583aSRasmus Rohde  			u32 block;
150221e583aSRasmus Rohde  			u16 partref;
151221e583aSRasmus Rohde  			u16 parent_partref;
152221e583aSRasmus Rohde  			u32 generation;
153221e583aSRasmus Rohde  			u32 parent_block;
154221e583aSRasmus Rohde  			u32 parent_generation;
155221e583aSRasmus Rohde  		} udf;
15637e2b570SGustavo A. R. Silva 		DECLARE_FLEX_ARRAY(__u32, raw);
1576e91ea2bSChristoph Hellwig 	};
1586e91ea2bSChristoph Hellwig };
159a5694255SChristoph Hellwig 
160c220e216SChristian Brauner enum handle_to_path_flags {
161c220e216SChristian Brauner 	HANDLE_CHECK_PERMS   = (1 << 0),
162c220e216SChristian Brauner 	HANDLE_CHECK_SUBTREE = (1 << 1),
163c220e216SChristian Brauner };
164c220e216SChristian Brauner 
165c220e216SChristian Brauner struct handle_to_path_ctx {
166c220e216SChristian Brauner 	struct path root;
167c220e216SChristian Brauner 	enum handle_to_path_flags flags;
168c220e216SChristian Brauner 	unsigned int fh_flags;
169c220e216SChristian Brauner };
170c220e216SChristian Brauner 
171b5287827SAmir Goldstein #define EXPORT_FH_CONNECTABLE	0x1 /* Encode file handle with parent */
172304e9c83SAmir Goldstein #define EXPORT_FH_FID		0x2 /* File handle may be non-decodeable */
173620c266fSChristian Brauner #define EXPORT_FH_DIR_ONLY	0x4 /* Only decode file handle for a directory */
174b5287827SAmir Goldstein 
1754a530a7cSAmir Goldstein /*
1764a530a7cSAmir Goldstein  * Filesystems use only lower 8 bits of file_handle type for fid_type.
1774a530a7cSAmir Goldstein  * name_to_handle_at() uses upper 16 bits of type as user flags to be
1784a530a7cSAmir Goldstein  * interpreted by open_by_handle_at().
1794a530a7cSAmir Goldstein  */
1804a530a7cSAmir Goldstein #define FILEID_USER_FLAGS_MASK	0xffff0000
1814a530a7cSAmir Goldstein #define FILEID_USER_FLAGS(type) ((type) & FILEID_USER_FLAGS_MASK)
1824a530a7cSAmir Goldstein 
1834a530a7cSAmir Goldstein /* Flags supported in encoded handle_type that is exported to user */
184c374196bSAmir Goldstein #define FILEID_IS_CONNECTABLE	0x10000
185c374196bSAmir Goldstein #define FILEID_IS_DIR		0x20000
186a20853abSAmir Goldstein #define FILEID_VALID_USER_FLAGS	(FILEID_IS_CONNECTABLE | FILEID_IS_DIR)
1874a530a7cSAmir Goldstein 
188a5694255SChristoph Hellwig /**
189a5694255SChristoph Hellwig  * struct export_operations - for nfsd to communicate with file systems
190a5694255SChristoph Hellwig  * @encode_fh:      encode a file handle fragment from a dentry
1919b89ca7aSMarc Dionne  * @fh_to_dentry:   find the implied object and get a dentry for it
1929b89ca7aSMarc Dionne  * @fh_to_parent:   find the implied object's parent and get a dentry for it
193a5694255SChristoph Hellwig  * @get_name:       find the name for a given inode in a given directory
194a5694255SChristoph Hellwig  * @get_parent:     find the parent of a given directory
195f501912aSBen Myers  * @commit_metadata: commit metadata changes to stable storage
196a5694255SChristoph Hellwig  *
197ec23eb54SMauro Carvalho Chehab  * See Documentation/filesystems/nfs/exporting.rst for details on how to use
198e38f9817SChristoph Hellwig  * this interface correctly.
199a5694255SChristoph Hellwig  *
200a5694255SChristoph Hellwig  * encode_fh:
201a5694255SChristoph Hellwig  *    @encode_fh should store in the file handle fragment @fh (using at most
202a5694255SChristoph Hellwig  *    @max_len bytes) information that can be used by @decode_fh to recover the
203b5287827SAmir Goldstein  *    file referred to by the &struct dentry @de.  If @flag has CONNECTABLE bit
204a5694255SChristoph Hellwig  *    set, the encode_fh() should store sufficient information so that a good
205a5694255SChristoph Hellwig  *    attempt can be made to find not only the file but also it's place in the
206a5694255SChristoph Hellwig  *    filesystem.   This typically means storing a reference to de->d_parent in
2075fe0c237SAneesh Kumar K.V  *    the filehandle fragment.  encode_fh() should return the fileid_type on
2085fe0c237SAneesh Kumar K.V  *    success and on error returns 255 (if the space needed to encode fh is
2095fe0c237SAneesh Kumar K.V  *    greater than @max_len*4 bytes). On error @max_len contains the minimum
2105fe0c237SAneesh Kumar K.V  *    size(in 4 byte unit) needed to encode the file handle.
211a5694255SChristoph Hellwig  *
2122596110aSChristoph Hellwig  * fh_to_dentry:
2132596110aSChristoph Hellwig  *    @fh_to_dentry is given a &struct super_block (@sb) and a file handle
2142596110aSChristoph Hellwig  *    fragment (@fh, @fh_len). It should return a &struct dentry which refers
2152596110aSChristoph Hellwig  *    to the same file that the file handle fragment refers to.  If it cannot,
21609bb8bffSNeilBrown  *    it should return a %NULL pointer if the file cannot be found, or an
21709bb8bffSNeilBrown  *    %ERR_PTR error code of %ENOMEM if a memory allocation failure occurred.
21809bb8bffSNeilBrown  *    Any other error code is treated like %NULL, and will cause an %ESTALE error
21909bb8bffSNeilBrown  *    for callers of exportfs_decode_fh().
22009bb8bffSNeilBrown  *    Any suitable dentry can be returned including, if necessary, a new dentry
22109bb8bffSNeilBrown  *    created with d_alloc_root.  The caller can then find any other extant
22209bb8bffSNeilBrown  *    dentries by following the d_alias links.
2232596110aSChristoph Hellwig  *
2242596110aSChristoph Hellwig  * fh_to_parent:
2252596110aSChristoph Hellwig  *    Same as @fh_to_dentry, except that it returns a pointer to the parent
2262596110aSChristoph Hellwig  *    dentry if it was encoded into the filehandle fragment by @encode_fh.
2272596110aSChristoph Hellwig  *
228a5694255SChristoph Hellwig  * get_name:
229a5694255SChristoph Hellwig  *    @get_name should find a name for the given @child in the given @parent
230a5694255SChristoph Hellwig  *    directory.  The name should be stored in the @name (with the
231cd1a406fSRandy Dunlap  *    understanding that it is already pointing to a %NAME_MAX+1 sized
232a5694255SChristoph Hellwig  *    buffer.   get_name() should return %0 on success, a negative error code
233a5694255SChristoph Hellwig  *    or error.  @get_name will be called without @parent->i_mutex held.
234a5694255SChristoph Hellwig  *
235a5694255SChristoph Hellwig  * get_parent:
236a5694255SChristoph Hellwig  *    @get_parent should find the parent directory for the given @child which
237a5694255SChristoph Hellwig  *    is also a directory.  In the event that it cannot be found, or storage
238a5694255SChristoph Hellwig  *    space cannot be allocated, a %ERR_PTR should be returned.
239a5694255SChristoph Hellwig  *
240c220e216SChristian Brauner  * permission:
241c220e216SChristian Brauner  *    Allow filesystems to specify a custom permission function.
242c220e216SChristian Brauner  *
24350166d57SChristian Brauner  * open:
24450166d57SChristian Brauner  *    Allow filesystems to specify a custom open function.
24550166d57SChristian Brauner  *
246f501912aSBen Myers  * commit_metadata:
247f501912aSBen Myers  *    @commit_metadata should commit metadata changes to stable storage.
248f501912aSBen Myers  *
249a5694255SChristoph Hellwig  * Locking rules:
250a5694255SChristoph Hellwig  *    get_parent is called with child->d_inode->i_mutex down
251a5694255SChristoph Hellwig  *    get_name is not (which is possibly inconsistent)
252a5694255SChristoph Hellwig  */
253a5694255SChristoph Hellwig 
254a5694255SChristoph Hellwig struct export_operations {
255b0b0382bSAl Viro 	int (*encode_fh)(struct inode *inode, __u32 *fh, int *max_len,
256b0b0382bSAl Viro 			struct inode *parent);
2572596110aSChristoph Hellwig 	struct dentry * (*fh_to_dentry)(struct super_block *sb, struct fid *fid,
2582596110aSChristoph Hellwig 			int fh_len, int fh_type);
2592596110aSChristoph Hellwig 	struct dentry * (*fh_to_parent)(struct super_block *sb, struct fid *fid,
2602596110aSChristoph Hellwig 			int fh_len, int fh_type);
261a5694255SChristoph Hellwig 	int (*get_name)(struct dentry *parent, char *name,
262a5694255SChristoph Hellwig 			struct dentry *child);
263a5694255SChristoph Hellwig 	struct dentry * (*get_parent)(struct dentry *child);
264f501912aSBen Myers 	int (*commit_metadata)(struct inode *inode);
2657fbc1067SChristoph Hellwig 
2667fbc1067SChristoph Hellwig 	int (*get_uuid)(struct super_block *sb, u8 *buf, u32 *len, u64 *offset);
2677fbc1067SChristoph Hellwig 	int (*map_blocks)(struct inode *inode, loff_t offset,
2687fbc1067SChristoph Hellwig 			  u64 len, struct iomap *iomap,
2697fbc1067SChristoph Hellwig 			  bool write, u32 *device_generation);
2707fbc1067SChristoph Hellwig 	int (*commit_blocks)(struct inode *inode, struct iomap *iomaps,
2717fbc1067SChristoph Hellwig 			     int nr_iomaps, struct iattr *iattr);
272c220e216SChristian Brauner 	int (*permission)(struct handle_to_path_ctx *ctx, unsigned int oflags);
27350166d57SChristian Brauner 	struct file * (*open)(struct path *path, unsigned int oflags);
2747f84b488SJeff Layton #define	EXPORT_OP_NOWCC			(0x1) /* don't collect v3 wcc data */
2757f84b488SJeff Layton #define	EXPORT_OP_NOSUBTREECHK		(0x2) /* no subtree checking */
2767f84b488SJeff Layton #define	EXPORT_OP_CLOSE_BEFORE_UNLINK	(0x4) /* close files before unlink */
27701cbf385STrond Myklebust #define EXPORT_OP_REMOTE_FS		(0x8) /* Filesystem is remote */
278716a8bc7STrond Myklebust #define EXPORT_OP_NOATOMIC_ATTR		(0x10) /* Filesystem cannot supply
279716a8bc7STrond Myklebust 						  atomic attribute updates
280716a8bc7STrond Myklebust 						*/
281dcb779fcSJeff Layton #define EXPORT_OP_FLUSH_ON_CLOSE	(0x20) /* fs flushes file data on close */
282*9254c8aeSMike Snitzer #define EXPORT_OP_NOLOCKS		(0x40) /* no file locking support */
283daab110eSJeff Layton 	unsigned long	flags;
284a5694255SChristoph Hellwig };
285a5694255SChristoph Hellwig 
286*9254c8aeSMike Snitzer /**
287*9254c8aeSMike Snitzer  * exportfs_cannot_lock() - check if export implements file locking
288*9254c8aeSMike Snitzer  * @export_ops:	the nfs export operations to check
289*9254c8aeSMike Snitzer  *
290*9254c8aeSMike Snitzer  * Returns true if the export does not support file locking.
291*9254c8aeSMike Snitzer  */
292*9254c8aeSMike Snitzer static inline bool
exportfs_cannot_lock(const struct export_operations * export_ops)293*9254c8aeSMike Snitzer exportfs_cannot_lock(const struct export_operations *export_ops)
294*9254c8aeSMike Snitzer {
295*9254c8aeSMike Snitzer 	return export_ops->flags & EXPORT_OP_NOLOCKS;
296*9254c8aeSMike Snitzer }
297*9254c8aeSMike Snitzer 
298711c7bf9SCyrill Gorcunov extern int exportfs_encode_inode_fh(struct inode *inode, struct fid *fid,
299304e9c83SAmir Goldstein 				    int *max_len, struct inode *parent,
300304e9c83SAmir Goldstein 				    int flags);
3016e91ea2bSChristoph Hellwig extern int exportfs_encode_fh(struct dentry *dentry, struct fid *fid,
302b5287827SAmir Goldstein 			      int *max_len, int flags);
303304e9c83SAmir Goldstein 
exportfs_can_encode_fid(const struct export_operations * nop)30466c62769SAmir Goldstein static inline bool exportfs_can_encode_fid(const struct export_operations *nop)
30566c62769SAmir Goldstein {
30664343119SAmir Goldstein 	return !nop || nop->encode_fh;
30766c62769SAmir Goldstein }
30866c62769SAmir Goldstein 
exportfs_can_decode_fh(const struct export_operations * nop)30966c62769SAmir Goldstein static inline bool exportfs_can_decode_fh(const struct export_operations *nop)
31066c62769SAmir Goldstein {
31166c62769SAmir Goldstein 	return nop && nop->fh_to_dentry;
31266c62769SAmir Goldstein }
31366c62769SAmir Goldstein 
exportfs_can_encode_fh(const struct export_operations * nop,int fh_flags)31466c62769SAmir Goldstein static inline bool exportfs_can_encode_fh(const struct export_operations *nop,
31566c62769SAmir Goldstein 					  int fh_flags)
31666c62769SAmir Goldstein {
31766c62769SAmir Goldstein 	/*
31866c62769SAmir Goldstein 	 * If a non-decodeable file handle was requested, we only need to make
31964343119SAmir Goldstein 	 * sure that filesystem did not opt-out of encoding fid.
32066c62769SAmir Goldstein 	 */
32166c62769SAmir Goldstein 	if (fh_flags & EXPORT_FH_FID)
32266c62769SAmir Goldstein 		return exportfs_can_encode_fid(nop);
32366c62769SAmir Goldstein 
32466c62769SAmir Goldstein 	/*
32566c62769SAmir Goldstein 	 * If a decodeable file handle was requested, we need to make sure that
32666c62769SAmir Goldstein 	 * filesystem can also decode file handles.
32766c62769SAmir Goldstein 	 */
32866c62769SAmir Goldstein 	return exportfs_can_decode_fh(nop);
32966c62769SAmir Goldstein }
33066c62769SAmir Goldstein 
exportfs_encode_fid(struct inode * inode,struct fid * fid,int * max_len)331304e9c83SAmir Goldstein static inline int exportfs_encode_fid(struct inode *inode, struct fid *fid,
332304e9c83SAmir Goldstein 				      int *max_len)
333304e9c83SAmir Goldstein {
334304e9c83SAmir Goldstein 	return exportfs_encode_inode_fh(inode, fid, max_len, NULL,
335304e9c83SAmir Goldstein 					EXPORT_FH_FID);
336304e9c83SAmir Goldstein }
337304e9c83SAmir Goldstein 
338d045465fSTrond Myklebust extern struct dentry *exportfs_decode_fh_raw(struct vfsmount *mnt,
339d045465fSTrond Myklebust 					     struct fid *fid, int fh_len,
340d045465fSTrond Myklebust 					     int fileid_type,
341620c266fSChristian Brauner 					     unsigned int flags,
342d045465fSTrond Myklebust 					     int (*acceptable)(void *, struct dentry *),
343d045465fSTrond Myklebust 					     void *context);
3446e91ea2bSChristoph Hellwig extern struct dentry *exportfs_decode_fh(struct vfsmount *mnt, struct fid *fid,
345d37065cdSChristoph Hellwig 	int fh_len, int fileid_type, int (*acceptable)(void *, struct dentry *),
346d37065cdSChristoph Hellwig 	void *context);
347d37065cdSChristoph Hellwig 
3482596110aSChristoph Hellwig /*
3492596110aSChristoph Hellwig  * Generic helpers for filesystems.
3502596110aSChristoph Hellwig  */
351e21fc203SAmir Goldstein int generic_encode_ino32_fh(struct inode *inode, __u32 *fh, int *max_len,
352e21fc203SAmir Goldstein 			    struct inode *parent);
353d9e5d922SAmir Goldstein struct dentry *generic_fh_to_dentry(struct super_block *sb,
3542596110aSChristoph Hellwig 	struct fid *fid, int fh_len, int fh_type,
3552596110aSChristoph Hellwig 	struct inode *(*get_inode) (struct super_block *sb, u64 ino, u32 gen));
356d9e5d922SAmir Goldstein struct dentry *generic_fh_to_parent(struct super_block *sb,
3572596110aSChristoph Hellwig 	struct fid *fid, int fh_len, int fh_type,
3582596110aSChristoph Hellwig 	struct inode *(*get_inode) (struct super_block *sb, u64 ino, u32 gen));
3592596110aSChristoph Hellwig 
360a5694255SChristoph Hellwig #endif /* LINUX_EXPORTFS_H */
361