]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man4/fuse.4
fuse.4: srcfix: FIXME
[thirdparty/man-pages.git] / man4 / fuse.4
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.
24 .\" %%%LICENSE_END
25 .\"
26 .TH FUSE 4 2016-12-10 "Linux" "Linux Programmer's Manual"
27 .SH NAME
28 /dev/fuse \- Filesystem in Userspace (FUSE) device
29 .SH SYNOPSIS
30 .nf
31 .B #include <linux/fuse.h>
32 .nf
33 .SH DESCRIPTION
34
35 This device is the primary interface between the FUSE filesystem driver
36 and a user-space process wishing to provide the filesystem (referred to
37 in the rest of this manual page as the
38 .IR "filesystem daemon" ).
39 This manual page is intended for those
40 interested in understanding the kernel interface itself.
41 Those implementing a FUSE filesystem may wish to make use of
42 a user-space library such as
43 .I libfuse
44 that abstracts away the low-level interface.
45
46 At its core, FUSE is a simple client-server protocol, in which the Linux
47 kernel is the client and the daemon is the server.
48 After obtaining a file descriptor for this device, the daemon may
49 .BR read (2)
50 requests from that file descriptor and is expected to
51 .BR write (2)
52 back its replies.
53 It is important to note that a file descriptor is
54 associated with a unique FUSE filesystem.
55 In particular, opening a second copy of this device,
56 will not allow access to resources created
57 through the first file descriptor (and vice versa).
58 .\"
59 .SS The basic protocol
60 Every message that is read by the daemon begins with a header described by
61 the following structure:
62
63 .in +4n
64 .nf
65 struct fuse_in_header {
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;
76 };
77 .fi
78 .in
79
80 The header is followed by a variable-length data portion
81 (which may be empty) specific to the requested operation
82 (the requested operation is indicated by
83 .IR opcode ).
84
85 The daemon should then process the request and if applicable send
86 a reply (almost all operations require a reply; if they do not,
87 this is documented below), by performing a
88 .BR write (2)
89 to the file descriptor.
90 All replies must start with the following header:
91
92 .in +4n
93 .nf
94 struct 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 };
101 .fi
102 .in
103
104 This header is also followed by (potentially empty) variable-sized
105 data depending on the executed request.
106 However, if the reply is an error reply (i.e.,
107 .I error
108 is set),
109 then no further payload data should be sent, independent of the request.
110 .\"
111 .SS Exchanged messages
112 This section should contain documentation for each of the messages
113 in the protocol.
114 This manual page is currently incomplete,
115 so not all messages are documented.
116 For each message, first the struct sent by the kernel is given,
117 followed by a description of the semantics of the message.
118 .TP
119 .BR FUSE_INIT " ( 25 )"
120
121 .in +4n
122 .nf
123 struct fuse_init_in {
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 */
128 };
129 .fi
130 .in
131
132 This is the first request sent by the kernel to the daemon.
133 It is used to negotiate the protocol version and other filesystem parameters.
134 Note that the protocol version may affect the layout of any structure
135 in the protocol (including this structure).
136 The daemon must thus remember the negotiated version
137 and flags for each session.
138 As of the writing of this man page,
139 the highest supported kernel protocol version is
140 .IR 7.26 .
141
142 Users should be aware that the descriptions in this manual page
143 may be incomplete or incorrect for older or more recent protocol versions.
144
145 The reply for this request has the following format:
146
147 .in +4n
148 .nf
149 struct fuse_init_out {
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];
160 };
161 .fi
162 .in
163
164 If the major version supported by the kernel is larger than that supported
165 by the daemon, the reply shall consist of only
166 .I uint32_t major
167 (following the usual header),
168 indicating the largest major version supported by the daemon.
169 The kernel will then issue a new
170 .B FUSE_INIT
171 request conforming to the older version.
172 In the reverse case, the daemon should
173 quietly fall back to the kernel's major version.
174
175 The negotiated minor version is considered to be the minimum
176 of the minor versions provided by the daemon and the kernel and
177 both parties should use the protocol corresponding to said minor version.
178 .TP
179 .BR FUSE_GETATTR " ( 3 )"
180 .\" FIXME It looks like this is for implementing a stat(2) type of
181 .\" operation. There needs to be a sentence here describing what
182 .\" this option does.
183
184 .in +4n
185 .nf
186 struct fuse_getattr_in {
187 uint32_t getattr_flags;
188 uint32_t dummy;
189 uint64_t fh; /* Set only if
190 (getattr_flags & FUSE_GETATTR_FH)
191 };
192 .fi
193 .in
194
195 As usual, the filesystem object operated on is indicated by
196 .IR header\->nodeid .
197 The daemon should compute the attributes
198 of this object and reply with the following message:
199 .in +4n
200
201 .nf
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 };
220
221 struct fuse_attr_out {
222 /* Attribute cache duration (seconds + nanoseconds) */
223 uint64_t attr_valid;
224 uint32_t attr_valid_nsec;
225 uint32_t dummy;
226 struct fuse_attr attr;
227 };
228 .fi
229 .in
230
231 The fields of
232 .I struct fuse_attr
233 describe the attributes of the required file.
234 For the interpretation of these fields, see
235 .BR stat (2).
236 .TP
237 .BR FUSE_ACCESS " ( 34 )"
238
239 .in +4n
240 .nf
241 struct fuse_access_in {
242 uint32_t mask;
243 uint32_t padding;
244 };
245 .fi
246 .in
247
248 If the
249 .I default_permissions
250 mount options is not used, this request may be used for permissions checking.
251 No reply data is expected, but errors may be indicated
252 as usual in the reply header (in particular, access denied errors
253 may be indicated, by setting such field to
254 .\" FIXME What does "such field" mean? The 'error' field?
255 .BR \-EACCES ).
256 .TP
257 .BR FUSE_OPEN " ( 14 ) and " FUSE_OPENDIR " ( 34 )"
258 .in +4n
259 .nf
260 struct fuse_open_in {
261 uint32_t flags; /* The flags that were passed
262 to the open(2) */
263 uint32_t unused;
264 };
265 .fi
266 .in
267
268 The requested operation is to open the node indicated by
269 .IR header\->nodeid .
270 The exact semantics of what this means will depend on the
271 filesystem being implemented.
272 However, at the very least the
273 filesystem should validate that the requested
274 .I flags
275 are valid for the indicated resource and then send a reply with the
276 following format:
277
278 .in +4n
279 .nf
280
281 struct fuse_open_out {
282 uint64_t fh;
283 uint32_t open_flags;
284 uint32_t padding;
285 };
286
287 .fi
288 .in
289
290 The
291 .I fh
292 field is an opaque identifier that the kernel will use to refer
293 to this resource
294 The
295 .I open_flags
296 field is a bit mask of any number of
297 .B FOPEN_*
298 flags, which indicate properties of this file handle to the kernel.
299 .TP
300 .BR FUSE_READ " ( 15 ) and " FUSE_READDIR " ( 28 )"
301 .in +4n
302 .nf
303
304 struct fuse_read_in {
305 uint64_t fh;
306 uint64_t offset;
307 uint32_t size;
308 uint32_t read_flags;
309 uint64_t lock_owner;
310 uint32_t flags;
311 uint32_t padding;
312 };
313
314 .fi
315 .in
316
317 The requested action is to read up to
318 .I size
319 bytes of the file or directory, starting at
320 .IR offset .
321 .\" FIXME
322 .\" In the following, what are "out header" and "out structure"?
323 The bytes should be returned directly following the out header,
324 with no further special out structure.
325 .TP
326 .BR FUSE_INTERRUPT " ( 36 )"
327 .in +4n
328 .nf
329 struct fuse_interrupt_in {
330 uint64_t unique;
331 };
332 .fi
333 .in
334
335 The requested action is to cancel the pending operation indicated by
336 .IR unique .
337 This request requires no response.
338 However, receipt of this message does
339 not by itself cancel the indicated operation.
340 The kernel will still expect a reply to said operation (e.g., an
341 .I EINTR
342 error or a short read).
343 At most one
344 .B FUSE_INTERRUPT
345 request will be issued for a given operation.
346 After issuing said operation,
347 the kernel will wait uninterruptibly for completion of the indicated request.
348 .TP
349 .BR FUSE_LOOKUP " ( 1 )"
350 Directly following the header is a filename to be looked up in the directory
351 indicated by
352 .IR header\->nodeid .
353 The expected reply is of the form:
354
355 .in +4n
356 .nf
357 struct fuse_entry_out {
358 uint64_t nodeid; /* Inode ID */
359 uint64_t generation; /* Inode generation */
360 uint64_t entry_valid;
361 uint64_t attr_valid;
362 uint32_t entry_valid_nsec;
363 uint32_t attr_valid_nsec;
364 struct fuse_attr attr;
365 };
366 .fi
367 .in
368
369 The combination of
370 .I nodeid
371 and
372 .I generation
373 must be unique for the filesystem's lifetime.
374
375 The interpretation of timeouts and
376 .I attr
377 is as for
378 .BR FUSE_GETATTR .
379 .TP
380 .BR FUSE_FLUSH " ( 36 )"
381 .in +4n
382 .nf
383 struct fuse_flush_in {
384 uint64_t fh;
385 uint32_t unused;
386 uint32_t padding;
387 uint64_t lock_owner;
388 };
389 .fi
390 .in
391
392 The requested action is to flush any pending changes to the indicated
393 file handle.
394 No reply data is expected.
395 However, an empty reply message
396 still needs to be issued once the flush operation is complete.
397 .TP
398 .BR FUSE_RELEASE " ( 18 ) and " FUSE_RELEASEDIR " ( 29 )"
399 .in +4n
400 .nf
401 struct fuse_release_in {
402 uint64_t fh;
403 uint32_t flags;
404 uint32_t release_flags;
405 uint64_t lock_owner;
406 };
407 .fi
408 .in
409
410 These are the converse of
411 .BR FUSE_OPEN
412 and
413 .BR FUSE_OPENDIR
414 respectively.
415 The daemon may now free any resources associated with the
416 file handle
417 .I fh
418 as the kernel will no longer refer to it.
419 There is no reply data associated with this request,
420 but a reply still needs to be issued once the request has
421 been completely processed.
422 .TP
423 .BR FUSE_STATFS " ( 17 )"
424 This operation implements
425 .BR statfs (2)
426 for this filesystem.
427 There is no input data associated with this request.
428 The expected reply data has the following structure:
429
430 .in +4n
431 .nf
432 struct fuse_kstatfs {
433 uint64_t blocks;
434 uint64_t bfree;
435 uint64_t bavail;
436 uint64_t files;
437 uint64_t ffree;
438 uint32_t bsize;
439 uint32_t namelen;
440 uint32_t frsize;
441 uint32_t padding;
442 uint32_t spare[6];
443 };
444
445 struct fuse_statfs_out {
446 struct fuse_kstatfs st;
447 };
448 .fi
449 .in
450
451 For the interpretation of these fields, see
452 .BR statfs (2).
453 .SH ERRORS
454 .TP
455 .B EPERM
456 Returned from operations on a
457 .I /dev/fuse
458 file descriptor that has not been mounted.
459 .TP
460 .B EIO
461 Returned from
462 .BR read (2)
463 operations when the kernel's request is too large for the provided buffer.
464
465 .IR Note :
466 There are various ways in which incorrect use of these interfaces can cause
467 operations on the provided filesystem's files and directories to fail with
468 .BR EIO .
469 Among the possible incorrect uses are
470 .IP * 3
471 changing
472 .I mode & S_IFMT
473 for an inode that has previously been reported to the kernel; or
474 .IP *
475 giving replies to the kernel that are shorter than what the kernel expected.
476 .TP
477 .B EINVAL
478 Returned from
479 .BR write (2)
480 if validation of the reply failed.
481 Not all mistakes in replies will be caught by this validation.
482 However, basic mistakes, such as short replies or an incorrect
483 .I unique
484 value, are detected.
485 .TP
486 .B E2BIG
487 Returned from
488 .BR read (2)
489 operations when the kernel's request is too large for the provided buffer
490 and the request was
491 .BR FUSE_SETXATTR .
492 .TP
493 .B ENODEV
494 Returned from
495 .BR read (2)
496 and
497 .BR write (2)
498 if the FUSE filesystem was unmounted.
499 .SH CONFORMING TO
500 The FUSE filesystem is Linux-specific.
501 .SH SEE ALSO
502 .BR fusermount (1),
503 .BR mount.fuse (8)