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