| [Top] | [Contents] | [Index] | [ ? ] |
| 1. FUSE Protocol | FOO |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This chapter describes the procotol used between the FUSE kernel module and the program providing a file system. All comminication is done through a special file descriptor.
[FIXME: add more here about stuffs]
In the rest of this chapter, the term `node' refers to either a file or directory.
The version of the FUSE protocol described in this document is version 3.1.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The kernel sends requests by writing a special structure to the communication file descriptor. The structure contains an unique identifier that is used to seprate the requests from other parallel requests taking place around the same time. In full, the structure contains the following members:
uint32_t unique
uint32_t opcode
uint32_t ino
uint32_t uid
uint32_t gid
uint32_t pid
The structure is mandatory for all requests. Following the structure data is any optional data.
Request opcodes initiated by the kernel:
| Request | Opcode |
| FUSE_LOOKUP | 1 |
| FUSE_FORGET | 2 |
| FUSE_GETATTR | 3 |
| FUSE_SETATTR | 4 |
| FUSE_READLINK | 5 |
| FUSE_SYMLINK | 6 |
| FUSE_GETDIR | 7 |
| FUSE_MKNOD | 8 |
| FUSE_MKDIR | 9 |
| FUSE_UNLINK | 10 |
| FUSE_RMDIR | 11 |
| FUSE_RENAME | 12 |
| FUSE_LINK | 13 |
| FUSE_OPEN | 14 |
| FUSE_READ | 15 |
| FUSE_WRITE | 16 |
| FUSE_STATFS | 17 |
| FUSE_RELEASE | 18 |
| FUSE_FSYNC | 20 |
| FUSE_SETXATTR | 21 |
| FUSE_GETXATTR | 22 |
| FUSE_LISTXATTR | 23 |
| FUSE_REMOVEXATTR | 24 |
| FUSE_FLUSH | 25 |
Replies simply contain the unique request identifier, an error code (zero means success) and any optional data. Error codes are standard POSIX errno values, but negative (e.g., -ENOMEM.) Reply header:
uint32_t unique
uint32_t error
One common data structure for an reply is the `entry' structure. This structure describes a node in the file system. The kernel do not have to have any previous knowledge about the node. For the kernel to ever make an request to a node, it must have first been told about it through a `entry' structure (or a directory entry.) With the exception of the root node.
uint32_t ino
uint32_t generation
uint32_t entry_valid_sec, entry_valid_usec
uint32_t attr_valid_sec, attr_valid_usec
getattr request.
attr
stat. The following members are available:
uint32_t mode
uint32_t nlink
uint32_t uid
uint32_t gid
uint32_t rdev
uint64_t size
uint32_t blocks
uint32_t atime_sec, atime_usec
uint32_t mtime_sec, mtime_usec
uint32_t ctime_sec, ctime_usec
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Following the request structure is the name, name, of an node that the kernel wants to retrieve information about. The node should live in the directory specified by ino in the request.
If the directory do not have node with the name given in name it should return ENOENT.
If the lookup were successful a full `entry' structure should be returned, describing the node.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The kernel tells the file system that there is no longer any need to keep information in memory about the node specified by ino.
The file system should not send any reply to this request.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The file system should return attribute information about the node specified by ino, in the form of an attribute structure.
If for some reason ino is no longer valid, ENOENT should
be returned.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This request is the direct opposite to GETATTR. Following the
request structure is an attribute structure that defines the new
attributes of the node.
The file system may choose to reject the changes by returning
ENOENT, EPERM or any other error code.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The file system should return the value of the symbolic link specified by INO. The reply should contain a null-terminated string, which represents the value of the link. If the node is not a symbolic link, or in the case of some other error, the file system is free to reply with an error code and no value.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This request is one of the more complex ones of the FUSE protocol.
The file system should reply with a file descriptor holding directory
entries for the directory given by INO. The directory entry
structure maps relatively well to the POSIX dirent structure.
Each directory entry contains the following members:
ino_t ino
uint16_t namelen
uint8_t type
char name[256]
The file system can cache the file used for storing the directory entries, and do lazy-updates of it is known that the state of the under-laying directory has changed.
If node given by ino is not a directory, or the file system encounters any other problem while retrieving the directory entries, it is free to reply with an error code.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The mknod request is used to create files that are not
directories (which is created with the mkdir request.)
Following the request header is three arguments:
uint32_t mode
uint32_t rdev
char name[]
If pathname already exists, or is a symbolic link, this call fails
with an EEXIST error.
The newly created node should be owned by the credentials information provided by uid and gid.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Request file system to create a new directory in the under-laying directory specified by ino. Directly following the request header is a 32-bit value specifying the `mode' of the directory that should be created. Back-to-back with mode is the name of the directory, which is represented using a null-terminated string.
The file system should either return with an error code, or a `entry' structure describing the newly created directory.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Delete the node specified by ino from the file system. The file system should simply acknowledge the request, or reply with an error code.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The kernel requests that the file system should remove the directory given by ino. The file system should simply acknowledge the request, or reply with an error code.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Following the request structure is a null-terminated string that be the target of the symbolic link. The file system should respond either with an error code or an `entry' structure describing the new symbolic link node.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The rename request renames a file, moving it between
directories if required. ino corresponds to the directory where
node is currently living in. The request takes the following
arguments:
ino_t newdir
ENOTDIR error code.
char oldname[]
char newname[]
Both oldname and newname are null-terminated strings.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[FIXME!]
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Open file specified by ino. Creation or truncation flags (i.e.,
O_CREAT, O_EXCL, O_TRUNC) will not be passed with
this request. The file system should only check if the operation is
permitted given the user credentials and mode (following directly
after the request structure.) The file system should respond with an
error code (zero on success) and a file handle that will be used to
hold per-open information. The file handle is a 32-bit counter that
will be passed to corresponding read, write,
release and flush requests.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The file system is provided the per-open handler returned from a
previous open request. ino is used to identify the node.
This request informs the file system that any dirty data should be written to disk.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The kernel releases a reference to a per-open handler returned from a
previous open request. Following the file handle is a 32-bit
word flag word, describing the mode of the file. This mode is the
same mode as the file were opened.
A release request is sent when an open file has:
The file system should not send any replies to a release
request.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The file system should return data from file identifier by ino and the provided file handle. The file system is not forced to return the specified amount of data.
uint32_t file_handle
open
request.
uint64_t offset
uint32_t size
The file system should reply with a normal reply header, following the read data. The length of the reply specifies the total number of bytes read from the file.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The kernel provides data that should be written to a file. The request contains the following members:
uint32_t write_page
uint32_t file_handle
open
request.
uint64_t offset
uint32_t size
data[]
The file system should respond with reply with an error code and the amount of data that were written.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The file system should reply with a structure containing status, statistics and parameters of the file system. The structure has the following members:
uint32_t bsize
uint64_t blocks
uint64_t bfree
uint64_t bavail
uint64_t files
uint64_t ffree
uint32_t namelen
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Sync the contents of node that the per-open provided file handler corresponds to. The node is also identified by ino. The kernel provides an extra flag: datasync. If datasync is nonzero, the file system should only flush user data, not the meta data such as `mtime' and `atime'.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
| [Top] | [Contents] | [Index] | [ ? ] |
1. FUSE Protocol
1.1 Kernel requests
1.2 LOOKUP: Find node in directory
1.3 FORGET: Flush information about a node
1.4 GETATTR: Get a node's attributes
1.5 SETATTR: Update a node's attributes
1.6 READLINK: Read value of a symbolic link
1.7 GETDIR: Get directory contents
1.8 MKNOD: Create a file
1.9 MKDIR: Create a directory
1.10 UNLINK: Delete a name and possible the file it refers to
1.11 RMDIR: Delete a directory
1.12 SYMLINK: Make a new name for a node
1.13 RENAME: Change the name of a node
1.14 LINK: Make a new name for a node
1.15 OPEN: Open a file
1.16 FLUSH: Flush contents of file
1.17 RELEASE: Release a file handle
1.18 READ: Read data from a file
1.19 WRITE: Write data to a file
1.20 STATFS: Get file system status
1.21 FSYNC: Synchronize a node's in-core state with disk
1.22 SETXATTR
1.23 GETXATTR
1.24 LISTXATTR,
1.25 REMOVEXATTR,
| [Top] | [Contents] | [Index] | [ ? ] |
1. FUSE Protocol
| [Top] | [Contents] | [Index] | [ ? ] |
| Button | Name | Go to | From 1.2.3 go to |
|---|---|---|---|
| [ < ] | Back | previous section in reading order | 1.2.2 |
| [ > ] | Forward | next section in reading order | 1.2.4 |
| [ << ] | FastBack | beginning of this chapter or previous chapter | 1 |
| [ Up ] | Up | up section | 1.2 |
| [ >> ] | FastForward | next chapter | 2 |
| [Top] | Top | cover (top) of document | |
| [Contents] | Contents | table of contents | |
| [Index] | Index | concept index | |
| [ ? ] | About | this page |
where the Example assumes that the current position is at Subsubsection One-Two-Three of a document of the following structure: