blob: 5a79d8c604995e8d2ef73a1a3b77e1303926a658 [file] [log] [blame]
Miklos Szeredib5a3c9b2006-01-09 14:31:25 +00001This was generated on 2006/01/09 from
Miklos Szeredia2c5e562004-10-19 22:01:21 +00002
Miklos Szeredi4cecc252005-09-27 15:42:22 +00003 http://fuse.sourceforge.net/wiki/index.php/FAQ
Miklos Szeredia2c5e562004-10-19 22:01:21 +00004
Miklos Szeredi4cecc252005-09-27 15:42:22 +00005For an up to date version please see the above page. You can also add
6new entries there.
Miklos Szeredia2c5e562004-10-19 22:01:21 +00007
Miklos Szeredi4cecc252005-09-27 15:42:22 +00008General
9=======
Miklos Szeredia2c5e562004-10-19 22:01:21 +000010
Miklos Szeredib5a3c9b2006-01-09 14:31:25 +000011How can I umount a filesystem?
12------------------------------
Miklos Szeredi4cecc252005-09-27 15:42:22 +000013
14Filesystems mounted without sysadmin privileges can be umounted with
15the command
16
17 fusermount -u mountpoint
18
19What's the difference between FUSE and LUFS?
20--------------------------------------------
Miklos Szeredia2c5e562004-10-19 22:01:21 +000021
22The main difference between them is that in LUFS the filesystem is a
23shared object (.so) which is loaded by lufsmount, and in FUSE the
24filesystem is a separate executable, which uses the fuse library. The
Miklos Szeredi4cecc252005-09-27 15:42:22 +000025actual API is very similar, and there's a translator, that can load
26LUFS modules and run them using the FUSE kernel module (see the lufis
27package on the FUSE page).
Miklos Szeredia2c5e562004-10-19 22:01:21 +000028
29Another difference is that LUFS does some caching of directories and
30file attributes. FUSE does not do this, so it provides a 'thinner'
31interface.
32
Miklos Szeredi4cecc252005-09-27 15:42:22 +000033By now LUFS development seems to have completely ceased.
Miklos Szeredia2c5e562004-10-19 22:01:21 +000034
Miklos Szeredi4cecc252005-09-27 15:42:22 +000035Why is it called FUSE? There's a ZX Spectrum emulator called Fuse too.
36----------------------------------------------------------------------
Miklos Szeredia2c5e562004-10-19 22:01:21 +000037
Miklos Szeredi4cecc252005-09-27 15:42:22 +000038At the time of christening it, the author of FUSE (the filesystem)
39hadn't heard of Fuse (the Speccy emulator). Which is ironic, since he
40knew Philip Kendall, the author of that other Fuse from earlier times.
41Btw. the author of FUSE (the filesystem) also created a Speccy
42emulator called Spectemu.
Miklos Szeredie5183742005-02-02 11:14:04 +000043
Miklos Szeredi4cecc252005-09-27 15:42:22 +000044The name wanted to be a clever acronym for "Filesystem in USErspace",
45but it turned out to be an unfortunate choice. The author has since
46vowed never to name a project after a common term, not even anything
47found more than a handful of times on Google.
Miklos Szeredie5183742005-02-02 11:14:04 +000048
Miklos Szeredib5a3c9b2006-01-09 14:31:25 +000049Is it possible to mount a fuse filesystem from fstab?
50-----------------------------------------------------
51
52Yes, from version 2.4.0 this is possible. The filesystem must adhere
53to some rules about command line options to be able to work this
54way. Here's an example of mounting an sshfs filesystem:
55
56sshfs#user@host:/ /mnt/host fuse defaults 0 0
57
58The mounting is performed by the /sbin/mount.fuse helper script.
59
60Licensing issues
61~~~~~~~~~~~~~~~~
62
63Under what license is FUSE released?
64------------------------------------
65
66The kernel part is released under the GNU GPL.
67
68Libfuse is released under the GNU LGPL.
69
70All other parts (examples, fusermount, etc) are released under the GNU GPL.
71
72Under what conditions may I modify or distribute FUSE?
73------------------------------------------------------
74
75See the files COPYING and COPYING.LIB in the distribution.
76
77More information can be found at http://www.gnu.org/licenses/
78
79Under what conditions may I distribute a filesystem which uses libfuse?
80-----------------------------------------------------------------------
81
82See COPYING.LIB in the distribution.
83
84In simple terms as long as you are linking dynamically (the default)
85there are no limitations on linking with libfuse. For example you may
86distribute the filesystem itself in binary form, without source code,
87under any propriatery license.
88
89Under what conditions may I distribute a filesystem that uses the raw
90---------------------------------------------------------------------
91kernel interface of FUSE?
92-------------------------
93
94There are no restrictions whatsoever for using the raw kernel interface.
95
Miklos Szeredi4cecc252005-09-27 15:42:22 +000096API
97===
Miklos Szeredia2c5e562004-10-19 22:01:21 +000098
Miklos Szeredi4cecc252005-09-27 15:42:22 +000099Which method is called on the close() system call?
100--------------------------------------------------
Miklos Szeredia2c5e562004-10-19 22:01:21 +0000101
Miklos Szeredi4cecc252005-09-27 15:42:22 +0000102flush() and possibly release(). For details see the documentation of
103these methods in <fuse.h>
Miklos Szeredia2c5e562004-10-19 22:01:21 +0000104
Miklos Szeredi4cecc252005-09-27 15:42:22 +0000105Wouldn't it be simpler if there were a single close() method?
106-------------------------------------------------------------
Miklos Szeredia2c5e562004-10-19 22:01:21 +0000107
Miklos Szeredi4cecc252005-09-27 15:42:22 +0000108No, because the relationship between the close() system call and the
109release of the file (the opposite of open) is not as simple as people
110tend to imagine. UNIX allows open files to acquire multiple
111references
Miklos Szeredia2c5e562004-10-19 22:01:21 +0000112
Miklos Szeredi4cecc252005-09-27 15:42:22 +0000113 * after fork() two processes refer to the same open file
Miklos Szeredia2c5e562004-10-19 22:01:21 +0000114
Miklos Szeredi4cecc252005-09-27 15:42:22 +0000115 * dup() and dup2() make another file descriptor refer to the same
116 file
Miklos Szeredia2c5e562004-10-19 22:01:21 +0000117
Miklos Szeredi4cecc252005-09-27 15:42:22 +0000118 * mmap() makes a memory mapping refer to an open file
Miklos Szeredia2c5e562004-10-19 22:01:21 +0000119
Miklos Szeredi4cecc252005-09-27 15:42:22 +0000120This means, that for a single open() system call, there could be more
121than one close() and possibly munmap() calls until the open file is
122finally released.
Miklos Szeredia2c5e562004-10-19 22:01:21 +0000123
Miklos Szeredi4cecc252005-09-27 15:42:22 +0000124Can I return an error from release()?
125-------------------------------------
Miklos Szeredia2c5e562004-10-19 22:01:21 +0000126
Miklos Szeredi4cecc252005-09-27 15:42:22 +0000127No, it's not possible.
Miklos Szeredia2c5e562004-10-19 22:01:21 +0000128
Miklos Szeredi4cecc252005-09-27 15:42:22 +0000129If you need to return errors on close, you must do that from flush().
Miklos Szeredia2c5e562004-10-19 22:01:21 +0000130
Miklos Szeredi4cecc252005-09-27 15:42:22 +0000131How do I know which is the last flush() before release()?
132---------------------------------------------------------
Miklos Szeredia2c5e562004-10-19 22:01:21 +0000133
Miklos Szeredi4cecc252005-09-27 15:42:22 +0000134You can't. All flush() calls should be treated equally. Anyway it
135wouldn't be worth optimizing away non-final flushes, since it's fairly
136rare to have multiple write-flush sequences on an open file.
Miklos Szeredia2c5e562004-10-19 22:01:21 +0000137
Miklos Szeredi4cecc252005-09-27 15:42:22 +0000138Why doesn't FUSE forward ioctl() calls to the filesystem?
139---------------------------------------------------------
Miklos Szeredia2c5e562004-10-19 22:01:21 +0000140
Miklos Szeredi4cecc252005-09-27 15:42:22 +0000141Because it's not possible: data passed to ioctl() doesn't have a well
142defined length and structure like read() and write(). Consider using
143getxattr() and setxattr() instead.
Miklos Szeredia2c5e562004-10-19 22:01:21 +0000144
Miklos Szeredi4cecc252005-09-27 15:42:22 +0000145Is there a way to know the uid, gid or pid of the process performing
146--------------------------------------------------------------------
147the operation?
148--------------
Miklos Szeredia2c5e562004-10-19 22:01:21 +0000149
Miklos Szeredi4cecc252005-09-27 15:42:22 +0000150Yes: fuse_get_context()->uid, etc.
Miklos Szeredia2c5e562004-10-19 22:01:21 +0000151
Miklos Szeredib5a3c9b2006-01-09 14:31:25 +0000152How should threads be started?
153------------------------------
154
155Miscellaneous threads should be started from the init() method.
156Threads started before fuse_main() will exit when the process goes
157into the background.
158
159Is it possible to store a pointer to private data in the
160--------------------------------------------------------
161fuse_file_info structure?
162-------------------------
163
164Yes, the 'fh' filed is for this purpose. This filed may be set in the
165open() and create() methods, and is available in all other methods
166having a struct fuse_file_info parameter. Note, that changing the
167value of 'fh' in any other method as open() or create() will have no
168affect.
169
170Since the type of 'fh' is unsigned long, you need to use casts when
171storing and retrieving a pointer. Under Linux (and most other
172architectures) an unsigned long will be able to hold a pointer.
173
174This could have been done with a union of 'void *' and 'unsigned long'
175but that would not have been any more type safe as having to use
176explicit casts. The recommended type safe solution is to write a
177small inline function that retrieves the pointer from the
178fuse_file_info structure.
179
Miklos Szeredi4cecc252005-09-27 15:42:22 +0000180Problems
181========
Miklos Szeredia2c5e562004-10-19 22:01:21 +0000182
Miklos Szeredib5a3c9b2006-01-09 14:31:25 +0000183Version problems
184~~~~~~~~~~~~~~~~
185
186Why do I get Connection Refused after mounting?
187-----------------------------------------------
188
189Library is too old (< 2.3.0)
190
191You can check which version of the library is being used by foofs by
192doing 'ldd path_to_foofs'. It will return something like this
193
194 libfuse.so.2 => /usr/local/lib/libfuse.so.2 (0xb7fc9000)
195 libpthread.so.0 => /lib/tls/libpthread.so.0 (0xb7fb9000)
196 libglib-2.0.so.0 => /usr/lib/libglib-2.0.so.0 (0xb7f39000)
197 libc.so.6 => /lib/tls/libc.so.6 (0xb7e04000)
198
199Then do 'ls -l path_to_libfuse'
200
201> ls -l /usr/local/lib/libfuse.so.2
202lrwxrwxrwx 1 root root 16 Sep 26 13:41 /usr/local/lib/libfuse.so.2 -> libfuse.so.2.2.1
203
204Why does fusermount fail with an Unknown option error?
205------------------------------------------------------
206
207Errors like 'fusermount: Unknown option -o' or 'fusermount: Unknown
208option --' mean, that an old version of fusermount is being used. You
209can check by doing 'which fusermount'.
210
211If you installed FUSE from source, then this is probably because there
212exists a binary package on your system which also contains a
213fusermount program, and is found first in the path, e.g. in
214/usr/bin/fusermount.
215
216The solution is to remove the binary package.
217
218Installation problems
219~~~~~~~~~~~~~~~~~~~~~
220
221Why is there an error loading shared libraries?
222-----------------------------------------------
223
224If you get the following error when starting a FUSE-based filesystem:
225
226 foofs: error while loading shared libraries: libfuse.so.2:
227 cannot open shared object file: No such file or directory
228
229check /etc/ld.so.conf for a line containing '/usr/local/lib'. If it's
230missing, add it, and run ldconfig afterwards.
231
232Why doesn't mounting as user work if installing FUSE from a package?
233--------------------------------------------------------------------
234
235Distributions often package 'fusermount' without the suid bit, or only
236executable to the 'fuse' group.
237
238This results in the following message, when trying to mount a
239filesystem as an unprivileged user:
240
241 fusermount: mount failed: Operation not permitted
242
243The simplest solution is to change the mode of 'fusermount':
244
245 chmod 4755 /usr/bin/fusermount
246
247Note, you may have to do this after each upgrade.
248
249Other problems
250~~~~~~~~~~~~~~
251
Miklos Szeredi4cecc252005-09-27 15:42:22 +0000252Why are some bytes zeroed when reading a file?
253----------------------------------------------
Miklos Szeredia2c5e562004-10-19 22:01:21 +0000254
Miklos Szeredi4cecc252005-09-27 15:42:22 +0000255This happens if the filesystem returns a short count from the read()
256method. If the file wasn't opened in direct I/O mode, the read()
257method must return exactly the requested number of bytes, unless it's
258the end of the file.
Miklos Szeredia2c5e562004-10-19 22:01:21 +0000259
Miklos Szeredi4cecc252005-09-27 15:42:22 +0000260If the file was opened in direct I/O mode (with direct_io mount
261option, or by setting the direct_io field of fuse_file_info at open)
262the read can return a smaller value than requested. In this case the
263end of file can be signalled by returning zero.
Miklos Szeredia2c5e562004-10-19 22:01:21 +0000264
Miklos Szeredib5a3c9b2006-01-09 14:31:25 +0000265Why does cp return operation not permitted when copying a file with no
266----------------------------------------------------------------------
267write permissions for the owner?
268--------------------------------
269
270"cp" calls open(2) with read-only permissions and O_CREAT, the purpose
271being to atomically obtain a read/write file handle and make the file
272read-only. Unfortunately, this does not work very well in fuse, since
273you first get a mknod, and then an open call. At the time of open, you
274can't distinguish easily wether this is the first open issued by cp,
275or another process trying to write a read-only file.
276
277Defining the 'create' method solves this problem, however this
278requires a Linux kernel version of at least 2.6.15 and libfuse version
2792.5 or greater.
280
281There can be other workarounds, however the easy one is to use the
282"default_permissions" mount option, and to avoid checking permissions
283on open. If you store files on a filesystem, this can get tricky
284because you will have to change the file mode to allow writing. Using
285the stateful API (i.e. returning an handle on open) will simplify
286things. In this case, and using "-o default_permissions", when
287implementing the open call you have to:
288
2891. check if the open is in write mode (i.e. mode has O_RDWR or O_WRONLY)
290
2912. in that case (in mutual exclusion with other open, getattr
292 etc. calls on the same file) change the mode from "M" to "M OR
293 0o200"
294
2953. open the file, change back the mode even in case of errors, and
296 return the obtained handle
297
Miklos Szeredi4cecc252005-09-27 15:42:22 +0000298Why doesn't find work on my filesystem?
299---------------------------------------
Miklos Szeredia2c5e562004-10-19 22:01:21 +0000300
Miklos Szeredi4cecc252005-09-27 15:42:22 +0000301The st_nlink member must be set correctly for directories to make find
302work. If it's not set correctly the -noleaf option of find can be
303used to make it ignore the hard link count (see man find).
Miklos Szeredia2c5e562004-10-19 22:01:21 +0000304
Miklos Szeredi4cecc252005-09-27 15:42:22 +0000305The correct value of st_nlink for directories is NSUB + 2. Where NSUB
306is the number of subdirectories. NOTE: regular-file/symlink/etc
307entries do not count into NSUB, only directories.
Miklos Szeredia2c5e562004-10-19 22:01:21 +0000308
Miklos Szeredi4cecc252005-09-27 15:42:22 +0000309If calculating NSUB is hard, the filesystem can set st_nlink of
310directories to 1, and find will still work. This is not documented
Miklos Szeredi4322e172005-08-02 09:53:51 +0000311behavior of find, and it's not clear whether this is intended or just
Miklos Szeredi4cecc252005-09-27 15:42:22 +0000312by accident. But for example the NTFS filesysem relies on this, so
313it's unlikely that this "feature" will go away.
Miklos Szeredia2c5e562004-10-19 22:01:21 +0000314
Miklos Szeredi4cecc252005-09-27 15:42:22 +0000315What is the reason for IO errors?
316---------------------------------
Miklos Szeredia2c5e562004-10-19 22:01:21 +0000317
Miklos Szeredi4cecc252005-09-27 15:42:22 +0000318The kernel part of FUSE returns the EIO error value, whenever the
319userspace filesystem sends a "bad" reply. Sometimes these are
320unavoidable, and not necessarily a fault of the filesystem. Possible
321causes of this are (non-exhaustive)
322
323 * the filesystem returned a short count on write()
324
325 * the type of the file has changed (e.g. a directory suddenly
326 became a symlink)
327
328 * a directory entry contained a filename that was too long (no,
329 ENAMETOOLONG is not the right error here)
330
331 * the same node ID value was used for two different directories
332 (i.e. hard-linked directories are not allowed)
333
334Misc
335====
336
337Can the filesystem ask a question on the terminal of the user?
338--------------------------------------------------------------
Miklos Szeredie5183742005-02-02 11:14:04 +0000339
Miklos Szeredia2c5e562004-10-19 22:01:21 +0000340It would not be possible generally speaking, since it might not be an
Miklos Szeredi4cecc252005-09-27 15:42:22 +0000341interactive program but rather a daemon, or a GUI program doing the
342operation. However you should be able to get the PID for the caller,
343and by looking in /proc you should be able to find the process tty or
344something similar.
Miklos Szeredie5183742005-02-02 11:14:04 +0000345
Miklos Szeredi4cecc252005-09-27 15:42:22 +0000346But this is not recommended. You should rather think about solving
347this another way.