2007-07-17 18:04:28 +07:00
|
|
|
#ifndef LINUX_EXPORTFS_H
|
|
|
|
#define LINUX_EXPORTFS_H 1
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
|
|
|
|
struct dentry;
|
2013-10-28 16:32:35 +07:00
|
|
|
struct iattr;
|
2007-10-22 06:42:05 +07:00
|
|
|
struct inode;
|
2007-07-17 18:04:28 +07:00
|
|
|
struct super_block;
|
2007-07-17 18:04:30 +07:00
|
|
|
struct vfsmount;
|
2007-07-17 18:04:28 +07:00
|
|
|
|
2011-01-29 20:13:26 +07:00
|
|
|
/* limit the handle size to NFSv4 handle size now */
|
|
|
|
#define MAX_HANDLE_SZ 128
|
|
|
|
|
2007-10-22 06:42:03 +07:00
|
|
|
/*
|
|
|
|
* 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,
|
2008-04-30 22:22:06 +07:00
|
|
|
|
2008-08-20 20:58:23 +07:00
|
|
|
/*
|
|
|
|
* 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,
|
|
|
|
|
2008-04-30 22:22:06 +07:00
|
|
|
/*
|
|
|
|
* 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,
|
2010-08-26 22:23:02 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 64 bit checkpoint number, 64 bit inode number,
|
|
|
|
* 32 bit generation number.
|
|
|
|
*/
|
|
|
|
FILEID_NILFS_WITHOUT_PARENT = 0x61,
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 64 bit checkpoint number, 64 bit inode number,
|
|
|
|
* 32 bit generation number, 32 bit parent generation.
|
|
|
|
* 64 bit parent inode number.
|
|
|
|
*/
|
|
|
|
FILEID_NILFS_WITH_PARENT = 0x62,
|
2012-08-29 21:10:10 +07:00
|
|
|
|
2013-04-30 06:21:11 +07:00
|
|
|
/*
|
|
|
|
* 32 bit generation number, 40 bit i_pos.
|
|
|
|
*/
|
|
|
|
FILEID_FAT_WITHOUT_PARENT = 0x71,
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 32 bit generation number, 40 bit i_pos,
|
|
|
|
* 32 bit parent generation number, 40 bit parent i_pos
|
|
|
|
*/
|
|
|
|
FILEID_FAT_WITH_PARENT = 0x72,
|
|
|
|
|
2016-02-15 07:13:52 +07:00
|
|
|
/*
|
|
|
|
* 128 bit child FID (struct lu_fid)
|
|
|
|
* 128 bit parent FID (struct lu_fid)
|
|
|
|
*/
|
|
|
|
FILEID_LUSTRE = 0x97,
|
|
|
|
|
2012-08-29 21:10:10 +07:00
|
|
|
/*
|
|
|
|
* Filesystems must not use 0xff file ID.
|
|
|
|
*/
|
|
|
|
FILEID_INVALID = 0xff,
|
2007-10-22 06:42:03 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct fid {
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
u32 ino;
|
|
|
|
u32 gen;
|
|
|
|
u32 parent_ino;
|
|
|
|
u32 parent_gen;
|
|
|
|
} i32;
|
2008-04-30 22:22:06 +07:00
|
|
|
struct {
|
|
|
|
u32 block;
|
|
|
|
u16 partref;
|
|
|
|
u16 parent_partref;
|
|
|
|
u32 generation;
|
|
|
|
u32 parent_block;
|
|
|
|
u32 parent_generation;
|
|
|
|
} udf;
|
2008-04-08 19:12:52 +07:00
|
|
|
__u32 raw[0];
|
2007-10-22 06:42:03 +07:00
|
|
|
};
|
|
|
|
};
|
2007-07-17 18:04:28 +07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* struct export_operations - for nfsd to communicate with file systems
|
|
|
|
* @encode_fh: encode a file handle fragment from a dentry
|
2008-03-14 20:11:29 +07:00
|
|
|
* @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
|
2007-07-17 18:04:28 +07:00
|
|
|
* @get_name: find the name for a given inode in a given directory
|
|
|
|
* @get_parent: find the parent of a given directory
|
2010-02-18 03:05:11 +07:00
|
|
|
* @commit_metadata: commit metadata changes to stable storage
|
2007-07-17 18:04:28 +07:00
|
|
|
*
|
2009-10-28 01:41:35 +07:00
|
|
|
* See Documentation/filesystems/nfs/Exporting for details on how to use
|
2007-10-22 06:42:19 +07:00
|
|
|
* this interface correctly.
|
2007-07-17 18:04:28 +07:00
|
|
|
*
|
|
|
|
* 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
|
2011-03-31 08:57:33 +07:00
|
|
|
* file referred to by the &struct dentry @de. If the @connectable flag is
|
2007-07-17 18:04:28 +07:00
|
|
|
* 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
|
2011-01-29 20:13:25 +07:00
|
|
|
* the filehandle fragment. encode_fh() should return the fileid_type on
|
|
|
|
* success and on error returns 255 (if the space needed to encode fh is
|
|
|
|
* greater than @max_len*4 bytes). On error @max_len contains the minimum
|
|
|
|
* size(in 4 byte unit) needed to encode the file handle.
|
2007-07-17 18:04:28 +07:00
|
|
|
*
|
2007-10-22 06:42:05 +07:00
|
|
|
* 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.
|
|
|
|
*
|
2007-07-17 18:04:28 +07:00
|
|
|
* 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.
|
|
|
|
*
|
2010-02-18 03:05:11 +07:00
|
|
|
* commit_metadata:
|
|
|
|
* @commit_metadata should commit metadata changes to stable storage.
|
|
|
|
*
|
2007-07-17 18:04:28 +07:00
|
|
|
* Locking rules:
|
|
|
|
* get_parent is called with child->d_inode->i_mutex down
|
|
|
|
* get_name is not (which is possibly inconsistent)
|
|
|
|
*/
|
|
|
|
|
2013-10-28 16:32:35 +07:00
|
|
|
/* types of block ranges for multipage write mappings. */
|
|
|
|
#define IOMAP_HOLE 0x01 /* no blocks allocated, need allocation */
|
|
|
|
#define IOMAP_DELALLOC 0x02 /* delayed allocation blocks */
|
|
|
|
#define IOMAP_MAPPED 0x03 /* blocks allocated @blkno */
|
|
|
|
#define IOMAP_UNWRITTEN 0x04 /* blocks allocated @blkno in unwritten state */
|
|
|
|
|
|
|
|
#define IOMAP_NULL_BLOCK -1LL /* blkno is not valid */
|
|
|
|
|
|
|
|
struct iomap {
|
|
|
|
sector_t blkno; /* first sector of mapping */
|
|
|
|
loff_t offset; /* file offset of mapping, bytes */
|
|
|
|
u64 length; /* length of mapping, bytes */
|
|
|
|
int type; /* type of mapping */
|
|
|
|
};
|
|
|
|
|
2007-07-17 18:04:28 +07:00
|
|
|
struct export_operations {
|
2012-04-03 01:34:06 +07:00
|
|
|
int (*encode_fh)(struct inode *inode, __u32 *fh, int *max_len,
|
|
|
|
struct inode *parent);
|
2007-10-22 06:42:05 +07:00
|
|
|
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);
|
2007-07-17 18:04:28 +07:00
|
|
|
int (*get_name)(struct dentry *parent, char *name,
|
|
|
|
struct dentry *child);
|
|
|
|
struct dentry * (*get_parent)(struct dentry *child);
|
2010-02-18 03:05:11 +07:00
|
|
|
int (*commit_metadata)(struct inode *inode);
|
2013-10-28 16:32:35 +07:00
|
|
|
|
|
|
|
int (*get_uuid)(struct super_block *sb, u8 *buf, u32 *len, u64 *offset);
|
|
|
|
int (*map_blocks)(struct inode *inode, loff_t offset,
|
|
|
|
u64 len, struct iomap *iomap,
|
|
|
|
bool write, u32 *device_generation);
|
|
|
|
int (*commit_blocks)(struct inode *inode, struct iomap *iomaps,
|
|
|
|
int nr_iomaps, struct iattr *iattr);
|
2007-07-17 18:04:28 +07:00
|
|
|
};
|
|
|
|
|
2012-12-18 07:05:08 +07:00
|
|
|
extern int exportfs_encode_inode_fh(struct inode *inode, struct fid *fid,
|
|
|
|
int *max_len, struct inode *parent);
|
2007-10-22 06:42:03 +07:00
|
|
|
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,
|
2007-07-17 18:04:30 +07:00
|
|
|
int fh_len, int fileid_type, int (*acceptable)(void *, struct dentry *),
|
|
|
|
void *context);
|
|
|
|
|
2007-10-22 06:42:05 +07:00
|
|
|
/*
|
|
|
|
* 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));
|
|
|
|
|
2007-07-17 18:04:28 +07:00
|
|
|
#endif /* LINUX_EXPORTFS_H */
|