STRUCT EXPORT_OPERATIONS(9)
okay so bestie π welcome to the struct export_operations(9) page from the Kernel API Manual β manual name folded in near the top like a lil ribbon π. this struct is the main character for nfsd talking to filesystems, and we are gonna go through every single member, flag, and caveat. no cap.
πΈ NAME πΈ
struct export_operations β for nfsd to communicate with file systems. that's the whole point, periodt π
.
β¨ SYNOPSIS β¨
here's the struct layout, bestie β every signature and macro is below π«Ά:
struct export_operations {
int (*encode_fh)(struct inode *inode, __u32 *fh, int *max_len,
struct inode *parent);
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);
int (*get_name)(struct dentry *parent, char *name,
struct dentry *child);
struct dentry * (*get_parent)(struct dentry *child);
int (*commit_metadata)(struct inode *inode);
int (*permission)(struct handle_to_path_ctx *ctx, unsigned int oflags);
struct file * (*open)(const struct path *path, unsigned int oflags);
#define EXPORT_OP_NOWCC (0x1) ;
#define EXPORT_OP_NOSUBTREECHK (0x2) ;
#define EXPORT_OP_CLOSE_BEFORE_UNLINK (0x4) ;
#define EXPORT_OP_REMOTE_FS (0x8) ;
#define EXPORT_OP_NOATOMIC_ATTR (0x10) #define EXPORT_OP_FLUSH_ON_CLOSE (0x20) ;
#define EXPORT_OP_NOLOCKS (0x40) ;
unsigned long flags;
#ifdef CONFIG_EXPORTFS_BLOCK_OPS;
const struct exportfs_block_ops *block_ops;
#endif;
};
π§ Members π§
encode_fhβencode_fhshould store in the file handle fragmentfh(using at mostmax_lenbytes) information that can be used bydecode_fhto recover the file referred to by thestruct dentry de. Ifflaghas theCONNECTABLEbit set,encode_fhshould store sufficient information so that a good attempt can be made to find not only the file but also its place in the filesystem. This typically means storing a reference tode->d_parentin the filehandle fragment.encode_fhshould return thefileid_typeon success and on error returns255(if the space needed to encodefhis greater thanmax_len*4bytes). On errormax_lencontains the minimum size (in 4 byte unit) needed to encode the file handle.fh_to_dentryβfh_to_dentryis given astruct super_block(sb) and a file handle fragment (fh,fh_len). It should return astruct dentrywhich refers to the same file that the file handle fragment refers to. If it cannot, it should return aNULLpointer if the file cannot be found, or anERR_PTRerror code ofENOMEMif a memory allocation failure occurred. Any other error code is treated likeNULL, and will cause anESTALEerror for callers ofexportfs_decode_fh. Any suitable dentry can be returned including, if necessary, a new dentry created withd_alloc_root. The caller can then find any other extant dentries by following thed_aliaslinks.fh_to_parentβ Same asfh_to_dentry, except that it returns a pointer to the parent dentry if it was encoded into the filehandle fragment byencode_fh.get_nameβget_nameshould find a name for the givenchildin the givenparentdirectory. The name should be stored inname(with the understanding that it is already pointing to aNAME_MAX + 1sized buffer).get_nameshould return0on success, a negative error code or error.get_namewill be called withoutparent->i_rwsemheld.get_parentβget_parentshould find the parent directory for the givenchildwhich is also a directory. In the event that it cannot be found, or storage space cannot be allocated, aERR_PTRshould be returned.commit_metadataβcommit_metadatashould commit metadata changes to stable storage. that's it, that's the vibe β¨.permissionβ Allow filesystems to specify a custom permission function for theopen_by_handle_at(2)syscall instead of the default permission check. This custom permission function is not respected by nfsd π.openβ Allow filesystems to specify a custom open function for theopen_by_handle_at(2)syscall instead of the defaultfile_open_root. This custom open function is not respected by nfsd π.flagsβ Allows the filesystem to communicate to nfsd that it may want to do things differently when dealing with it. The synopsis has these flag macros:EXPORT_OP_NOWCC(0x1),EXPORT_OP_NOSUBTREECHK(0x2),EXPORT_OP_CLOSE_BEFORE_UNLINK(0x4),EXPORT_OP_REMOTE_FS(0x8),EXPORT_OP_NOATOMIC_ATTR(0x10),EXPORT_OP_FLUSH_ON_CLOSE(0x20), andEXPORT_OP_NOLOCKS(0x40) π.block_opsβ Operations for layout grants to block on the underlying device.
π Description π
Methods for open_by_handle(2) syscall with special kernel file systems:
See Documentation/filesystems/nfs/exporting.rst for details on how to use this interface correctly and the definition of the flags π.
Locking rules: get_parent is called with child->d_inode->i_rwsem down; get_name is not (which is possibly inconsistent π).
π«Ά SEE ALSO π«Ά
- Kernel file
./include/linux/exportfs.h exportfs_cannot_lock(9)
mwah π this page is chillin' in ./include/linux and it's stamped October 2026 β slay, bye bestie π
β¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms