]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man/man4/fuse.4
man/, share/mk/: Move man*/ to man/
[thirdparty/man-pages.git] / man / man4 / fuse.4
CommitLineData
5963519c
KF
1.\" Copyright (c) 2016 Julia Computing Inc, Keno Fischer
2.\" Description based on include/uapi/fuse.h and code in fs/fuse
3.\"
5fbde956 4.\" SPDX-License-Identifier: Linux-man-pages-copyleft
5963519c 5.\"
4c1c5274 6.TH fuse 4 (date) "Linux man-pages (unreleased)"
5963519c 7.SH NAME
218081bf 8fuse \- Filesystem in Userspace (FUSE) device
5963519c
KF
9.SH SYNOPSIS
10.nf
11.B #include <linux/fuse.h>
a2b7a144 12.fi
5963519c 13.SH DESCRIPTION
5963519c 14This device is the primary interface between the FUSE filesystem driver
7260a6e1 15and a user-space process wishing to provide the filesystem (referred to
5963519c 16in the rest of this manual page as the
7260a6e1 17.IR "filesystem daemon" ).
5963519c 18This manual page is intended for those
72e830cc
MK
19interested in understanding the kernel interface itself.
20Those implementing a FUSE filesystem may wish to make use of
7260a6e1
MK
21a user-space library such as
22.I libfuse
23that abstracts away the low-level interface.
c6d039a3 24.P
5963519c 25At its core, FUSE is a simple client-server protocol, in which the Linux
72e830cc 26kernel is the client and the daemon is the server.
7260a6e1 27After obtaining a file descriptor for this device, the daemon may
5963519c
KF
28.BR read (2)
29requests from that file descriptor and is expected to
30.BR write (2)
7260a6e1
MK
31back its replies.
32It is important to note that a file descriptor is
33associated with a unique FUSE filesystem.
72e830cc
MK
34In particular, opening a second copy of this device,
35will not allow access to resources created
5963519c 36through the first file descriptor (and vice versa).
7260a6e1 37.\"
5963519c
KF
38.SS The basic protocol
39Every message that is read by the daemon begins with a header described by
7260a6e1 40the following structure:
c6d039a3 41.P
5963519c 42.in +4n
b8302363 43.EX
5963519c 44struct fuse_in_header {
7260a6e1
MK
45 uint32_t len; /* Total length of the data,
46 including this header */
47 uint32_t opcode; /* The kind of operation (see below) */
48 uint64_t unique; /* A unique identifier for this request */
49 uint64_t nodeid; /* ID of the filesystem object
50 being operated on */
51 uint32_t uid; /* UID of the requesting process */
52 uint32_t gid; /* GID of the requesting process */
53 uint32_t pid; /* PID of the requesting process */
54 uint32_t padding;
5963519c 55};
b8302363 56.EE
5963519c 57.in
c6d039a3 58.P
7260a6e1
MK
59The header is followed by a variable-length data portion
60(which may be empty) specific to the requested operation
5963519c 61(the requested operation is indicated by
7260a6e1 62.IR opcode ).
c6d039a3 63.P
72e830cc 64The daemon should then process the request and if applicable send
7260a6e1 65a reply (almost all operations require a reply; if they do not,
72e830cc 66this is documented below), by performing a
7260a6e1 67.BR write (2)
72e830cc
MK
68to the file descriptor.
69All replies must start with the following header:
c6d039a3 70.P
5963519c 71.in +4n
b8302363 72.EX
7260a6e1
MK
73struct fuse_out_header {
74 uint32_t len; /* Total length of data written to
75 the file descriptor */
76 int32_t error; /* Any error that occurred (0 if none) */
77 uint64_t unique; /* The value from the
78 corresponding request */
79};
b8302363 80.EE
5963519c 81.in
c6d039a3 82.P
7260a6e1
MK
83This header is also followed by (potentially empty) variable-sized
84data depending on the executed request.
85However, if the reply is an error reply (i.e.,
86.I error
87is set),
5963519c 88then no further payload data should be sent, independent of the request.
7260a6e1 89.\"
5963519c 90.SS Exchanged messages
72e830cc
MK
91This section should contain documentation for each of the messages
92in the protocol.
93This manual page is currently incomplete,
94so not all messages are documented.
95For each message, first the struct sent by the kernel is given,
96followed by a description of the semantics of the message.
5963519c 97.TP
1ae6b2c7 98.B FUSE_INIT
5b539973 99.IP
5963519c 100.in +4n
b8302363 101.EX
5963519c 102struct fuse_init_in {
7260a6e1
MK
103 uint32_t major;
104 uint32_t minor;
105 uint32_t max_readahead; /* Since protocol v7.6 */
106 uint32_t flags; /* Since protocol v7.6 */
5963519c 107};
b8302363 108.EE
5963519c 109.in
5b539973 110.IP
72e830cc 111This is the first request sent by the kernel to the daemon.
7260a6e1 112It is used to negotiate the protocol version and other filesystem parameters.
72e830cc 113Note that the protocol version may affect the layout of any structure
83b87d65 114in the protocol (including this structure).
72e830cc
MK
115The daemon must thus remember the negotiated version
116and flags for each session.
117As of the writing of this man page,
118the highest supported kernel protocol version is
7260a6e1 119.IR 7.26 .
5b539973 120.IP
5963519c
KF
121Users should be aware that the descriptions in this manual page
122may be incomplete or incorrect for older or more recent protocol versions.
5b539973 123.IP
7260a6e1 124The reply for this request has the following format:
5b539973 125.IP
5963519c 126.in +4n
b8302363 127.EX
5963519c 128struct fuse_init_out {
7260a6e1
MK
129 uint32_t major;
130 uint32_t minor;
131 uint32_t max_readahead; /* Since v7.6 */
132 uint32_t flags; /* Since v7.6; some flags bits
133 were introduced later */
134 uint16_t max_background; /* Since v7.13 */
135 uint16_t congestion_threshold; /* Since v7.13 */
136 uint32_t max_write; /* Since v7.5 */
137 uint32_t time_gran; /* Since v7.6 */
138 uint32_t unused[9];
5963519c 139};
b8302363 140.EE
5963519c 141.in
5b539973 142.IP
7260a6e1 143If the major version supported by the kernel is larger than that supported
5963519c
KF
144by the daemon, the reply shall consist of only
145.I uint32_t major
72e830cc
MK
146(following the usual header),
147indicating the largest major version supported by the daemon.
148The kernel will then issue a new
7260a6e1 149.B FUSE_INIT
72e830cc
MK
150request conforming to the older version.
151In the reverse case, the daemon should
5963519c 152quietly fall back to the kernel's major version.
5b539973 153.IP
72e830cc
MK
154The negotiated minor version is considered to be the minimum
155of the minor versions provided by the daemon and the kernel and
156both parties should use the protocol corresponding to said minor version.
5963519c 157.TP
1ae6b2c7 158.B FUSE_GETATTR
5b539973 159.IP
5963519c 160.in +4n
b8302363 161.EX
5963519c 162struct fuse_getattr_in {
7260a6e1
MK
163 uint32_t getattr_flags;
164 uint32_t dummy;
165 uint64_t fh; /* Set only if
166 (getattr_flags & FUSE_GETATTR_FH)
5963519c 167};
b8302363 168.EE
5963519c 169.in
5b539973 170.IP
4085d7ab
KF
171The requested operation is to compute the attributes to be returned
172by
660bc76c 173.BR stat (2)
f83eb6bf 174and similar operations for the given filesystem object.
4085d7ab
KF
175The object for which the attributes should be computed is indicated
176either by
1ae6b2c7 177.I header\->nodeid
4085d7ab 178or, if the
1ae6b2c7 179.B FUSE_GETATTR_FH
4085d7ab 180flag is set, by the file handle
8b5a3d2c 181.IR fh .
4085d7ab 182The latter case of operation is analogous to
660bc76c 183.BR fstat (2).
5b539973 184.IP
4085d7ab 185For performance reasons, these attributes may be cached in the kernel for
660bc76c
MK
186a specified duration of time.
187While the cache timeout has not been exceeded,
4085d7ab
KF
188the attributes will be served from the cache and will not cause additional
189.B FUSE_GETATTR
190requests.
5b539973 191.IP
4085d7ab
KF
192The computed attributes and the requested
193cache timeout should then be returned in the following structure:
5b539973 194.IP
4085d7ab 195.in +4n
b8302363 196.EX
5963519c
KF
197struct fuse_attr_out {
198 /* Attribute cache duration (seconds + nanoseconds) */
7260a6e1
MK
199 uint64_t attr_valid;
200 uint32_t attr_valid_nsec;
201 uint32_t dummy;
4085d7ab
KF
202 struct fuse_attr {
203 uint64_t ino;
204 uint64_t size;
205 uint64_t blocks;
206 uint64_t atime;
207 uint64_t mtime;
208 uint64_t ctime;
209 uint32_t atimensec;
210 uint32_t mtimensec;
211 uint32_t ctimensec;
212 uint32_t mode;
213 uint32_t nlink;
214 uint32_t uid;
215 uint32_t gid;
216 uint32_t rdev;
217 uint32_t blksize;
218 uint32_t padding;
219 } attr;
5963519c 220};
b8302363 221.EE
5963519c 222.in
5963519c 223.TP
1ae6b2c7 224.B FUSE_ACCESS
5b539973 225.IP
5963519c 226.in +4n
b8302363 227.EX
5963519c 228struct fuse_access_in {
7260a6e1
MK
229 uint32_t mask;
230 uint32_t padding;
5963519c 231};
b8302363 232.EE
5963519c 233.in
5b539973 234.IP
5963519c
KF
235If the
236.I default_permissions
72e830cc
MK
237mount options is not used, this request may be used for permissions checking.
238No reply data is expected, but errors may be indicated
4085d7ab
KF
239as usual by setting the
240.I error
241field in the reply header (in particular, access denied errors
242may be indicated by returning
7260a6e1 243.BR \-EACCES ).
5963519c 244.TP
ac3c78bd 245.BR FUSE_OPEN " and " FUSE_OPENDIR
5963519c 246.in +4n
b8302363 247.EX
5963519c 248struct fuse_open_in {
7260a6e1
MK
249 uint32_t flags; /* The flags that were passed
250 to the open(2) */
251 uint32_t unused;
5963519c 252};
b8302363 253.EE
5963519c 254.in
5b539973 255.IP
5963519c 256The requested operation is to open the node indicated by
7260a6e1
MK
257.IR header\->nodeid .
258The exact semantics of what this means will depend on the
72e830cc
MK
259filesystem being implemented.
260However, at the very least the
7260a6e1 261filesystem should validate that the requested
5963519c 262.I flags
7260a6e1
MK
263are valid for the indicated resource and then send a reply with the
264following format:
5b539973 265.IP
5963519c 266.in +4n
e646a1ba 267.EX
5963519c 268struct fuse_open_out {
7260a6e1
MK
269 uint64_t fh;
270 uint32_t open_flags;
271 uint32_t padding;
5963519c 272};
e646a1ba 273.EE
5963519c 274.in
5b539973 275.IP
7260a6e1 276The
5963519c 277.I fh
7260a6e1
MK
278field is an opaque identifier that the kernel will use to refer
279to this resource
280The
281.I open_flags
0bc65f95
MK
282field is a bit mask of any number of the flags
283that indicate properties of this file handle to the kernel:
284.RS 7
285.TP 18
1ae6b2c7 286.B FOPEN_DIRECT_IO
0bc65f95
MK
287Bypass page cache for this open file.
288.TP
1ae6b2c7 289.B FOPEN_KEEP_CACHE
0bc65f95
MK
290Don't invalidate the data cache on open.
291.TP
1ae6b2c7 292.B FOPEN_NONSEEKABLE
0bc65f95
MK
293The file is not seekable.
294.RE
5963519c 295.TP
ac3c78bd 296.BR FUSE_READ " and " FUSE_READDIR
e646a1ba 297.IP
5963519c 298.in +4n
e646a1ba 299.EX
5963519c 300struct fuse_read_in {
7260a6e1
MK
301 uint64_t fh;
302 uint64_t offset;
303 uint32_t size;
304 uint32_t read_flags;
305 uint64_t lock_owner;
306 uint32_t flags;
307 uint32_t padding;
5963519c 308};
e646a1ba 309.EE
5963519c 310.in
5b539973 311.IP
7260a6e1 312The requested action is to read up to
5963519c
KF
313.I size
314bytes of the file or directory, starting at
7260a6e1 315.IR offset .
4085d7ab 316The bytes should be returned directly following the usual reply header.
5963519c 317.TP
1ae6b2c7 318.B FUSE_INTERRUPT
5963519c 319.in +4n
b8302363 320.EX
5963519c 321struct fuse_interrupt_in {
7260a6e1 322 uint64_t unique;
5963519c 323};
b8302363 324.EE
5963519c 325.in
5b539973 326.IP
5963519c 327The requested action is to cancel the pending operation indicated by
7260a6e1 328.IR unique .
72e830cc
MK
329This request requires no response.
330However, receipt of this message does
331not by itself cancel the indicated operation.
7260a6e1
MK
332The kernel will still expect a reply to said operation (e.g., an
333.I EINTR
334error or a short read).
72e830cc 335At most one
5963519c 336.B FUSE_INTERRUPT
72e830cc
MK
337request will be issued for a given operation.
338After issuing said operation,
7260a6e1 339the kernel will wait uninterruptibly for completion of the indicated request.
5963519c 340.TP
1ae6b2c7 341.B FUSE_LOOKUP
5963519c
KF
342Directly following the header is a filename to be looked up in the directory
343indicated by
7260a6e1
MK
344.IR header\->nodeid .
345The expected reply is of the form:
5b539973 346.IP
5963519c 347.in +4n
b8302363 348.EX
5963519c 349struct fuse_entry_out {
3280cb6b
MK
350 uint64_t nodeid; /* Inode ID */
351 uint64_t generation; /* Inode generation */
7260a6e1
MK
352 uint64_t entry_valid;
353 uint64_t attr_valid;
354 uint32_t entry_valid_nsec;
355 uint32_t attr_valid_nsec;
5963519c
KF
356 struct fuse_attr attr;
357};
b8302363 358.EE
5963519c 359.in
5b539973 360.IP
5d69a98a
MK
361The combination of
362.I nodeid
363and
364.I generation
365must be unique for the filesystem's lifetime.
5b539973 366.IP
5963519c
KF
367The interpretation of timeouts and
368.I attr
7260a6e1
MK
369is as for
370.BR FUSE_GETATTR .
5963519c 371.TP
1ae6b2c7 372.B FUSE_FLUSH
5963519c 373.in +4n
b8302363 374.EX
5963519c 375struct fuse_flush_in {
7260a6e1
MK
376 uint64_t fh;
377 uint32_t unused;
378 uint32_t padding;
379 uint64_t lock_owner;
5963519c 380};
b8302363 381.EE
5963519c 382.in
5b539973 383.IP
5963519c 384The requested action is to flush any pending changes to the indicated
72e830cc
MK
385file handle.
386No reply data is expected.
387However, an empty reply message
5963519c 388still needs to be issued once the flush operation is complete.
5963519c 389.TP
ac3c78bd 390.BR FUSE_RELEASE " and " FUSE_RELEASEDIR
5963519c 391.in +4n
b8302363 392.EX
5963519c 393struct fuse_release_in {
7260a6e1
MK
394 uint64_t fh;
395 uint32_t flags;
396 uint32_t release_flags;
397 uint64_t lock_owner;
5963519c 398};
b8302363 399.EE
5963519c 400.in
5b539973 401.IP
7260a6e1 402These are the converse of
1ae6b2c7 403.B FUSE_OPEN
7260a6e1 404and
1ae6b2c7 405.B FUSE_OPENDIR
72e830cc
MK
406respectively.
407The daemon may now free any resources associated with the
5963519c
KF
408file handle
409.I fh
72e830cc 410as the kernel will no longer refer to it.
7260a6e1 411There is no reply data associated with this request,
72e830cc 412but a reply still needs to be issued once the request has
5963519c 413been completely processed.
5963519c 414.TP
1ae6b2c7 415.B FUSE_STATFS
5963519c 416This operation implements
7260a6e1
MK
417.BR statfs (2)
418for this filesystem.
72e830cc 419There is no input data associated with this request.
5963519c 420The expected reply data has the following structure:
5b539973 421.IP
5963519c 422.in +4n
b8302363 423.EX
5963519c 424struct fuse_kstatfs {
7260a6e1
MK
425 uint64_t blocks;
426 uint64_t bfree;
427 uint64_t bavail;
428 uint64_t files;
429 uint64_t ffree;
430 uint32_t bsize;
431 uint32_t namelen;
432 uint32_t frsize;
433 uint32_t padding;
434 uint32_t spare[6];
5963519c 435};
fe5dba13 436\&
5963519c
KF
437struct fuse_statfs_out {
438 struct fuse_kstatfs st;
439};
b8302363 440.EE
5963519c 441.in
5b539973 442.IP
5963519c 443For the interpretation of these fields, see
7260a6e1 444.BR statfs (2).
5963519c 445.SH ERRORS
7260a6e1 446.TP
cd146652
MK
447.B E2BIG
448Returned from
449.BR read (2)
450operations when the kernel's request is too large for the provided buffer
451and the request was
452.BR FUSE_SETXATTR .
453.TP
454.B EINVAL
455Returned from
456.BR write (2)
457if validation of the reply failed.
458Not all mistakes in replies will be caught by this validation.
459However, basic mistakes, such as short replies or an incorrect
460.I unique
461value, are detected.
7260a6e1 462.TP
5963519c
KF
463.B EIO
464Returned from
7260a6e1 465.BR read (2)
5963519c 466operations when the kernel's request is too large for the provided buffer.
5b539973 467.IP
5963519c
KF
468.IR Note :
469There are various ways in which incorrect use of these interfaces can cause
470operations on the provided filesystem's files and directories to fail with
7260a6e1 471.BR EIO .
faaf38b6
MK
472Among the possible incorrect uses are:
473.RS
cdede5cd 474.IP \[bu] 3
7260a6e1 475changing
5963519c 476.I mode & S_IFMT
7260a6e1 477for an inode that has previously been reported to the kernel; or
cdede5cd 478.IP \[bu]
7260a6e1 479giving replies to the kernel that are shorter than what the kernel expected.
faaf38b6 480.RE
7260a6e1 481.TP
5963519c 482.B ENODEV
996925d5
MK
483Returned from
484.BR read (2)
485and
486.BR write (2)
487if the FUSE filesystem was unmounted.
cd146652
MK
488.TP
489.B EPERM
490Returned from operations on a
491.I /dev/fuse
492file descriptor that has not been mounted.
3113c7f3 493.SH STANDARDS
4131356c 494Linux.
2949f098
MK
495.SH NOTES
496The following messages are not yet documented in this manual page:
c6d039a3 497.P
39902fbb 498.\" FIXME: Document the following.
11740568 499.in +4n
b9c93deb 500.EX
1ae6b2c7
AC
501.B FUSE_BATCH_FORGET
502.B FUSE_BMAP
503.B FUSE_CREATE
504.B FUSE_DESTROY
505.B FUSE_FALLOCATE
506.B FUSE_FORGET
507.B FUSE_FSYNC
508.B FUSE_FSYNCDIR
509.B FUSE_GETLK
510.B FUSE_GETXATTR
511.B FUSE_IOCTL
512.B FUSE_LINK
513.B FUSE_LISTXATTR
514.B FUSE_LSEEK
515.B FUSE_MKDIR
516.B FUSE_MKNOD
517.B FUSE_NOTIFY_REPLY
518.B FUSE_POLL
519.B FUSE_READDIRPLUS
520.B FUSE_READLINK
521.B FUSE_REMOVEXATTR
522.B FUSE_RENAME
523.B FUSE_RENAME2
524.B FUSE_RMDIR
525.B FUSE_SETATTR
526.B FUSE_SETLK
527.B FUSE_SETLKW
528.B FUSE_SYMLINK
529.B FUSE_UNLINK
530.B FUSE_WRITE
b8302363 531.EE
2949f098 532.in
70992218
MK
533.SH SEE ALSO
534.BR fusermount (1),
535.BR mount.fuse (8)