📄 faq
字号:
This was generated on 2006/01/09 from http://fuse.sourceforge.net/wiki/index.php/FAQFor an up to date version please see the above page. You can also addnew entries there.General=======How can I umount a filesystem?------------------------------Filesystems mounted without sysadmin privileges can be umounted withthe command fusermount -u mountpointWhat's the difference between FUSE and LUFS?--------------------------------------------The main difference between them is that in LUFS the filesystem is ashared object (.so) which is loaded by lufsmount, and in FUSE thefilesystem is a separate executable, which uses the fuse library. Theactual API is very similar, and there's a translator, that can loadLUFS modules and run them using the FUSE kernel module (see the lufispackage on the FUSE page).Another difference is that LUFS does some caching of directories andfile attributes. FUSE does not do this, so it provides a 'thinner'interface.By now LUFS development seems to have completely ceased.Why is it called FUSE? There's a ZX Spectrum emulator called Fuse too.----------------------------------------------------------------------At the time of christening it, the author of FUSE (the filesystem)hadn't heard of Fuse (the Speccy emulator). Which is ironic, since heknew Philip Kendall, the author of that other Fuse from earlier times.Btw. the author of FUSE (the filesystem) also created a Speccyemulator called Spectemu.The name wanted to be a clever acronym for "Filesystem in USErspace",but it turned out to be an unfortunate choice. The author has sincevowed never to name a project after a common term, not even anythingfound more than a handful of times on Google.Is it possible to mount a fuse filesystem from fstab?-----------------------------------------------------Yes, from version 2.4.0 this is possible. The filesystem must adhereto some rules about command line options to be able to work thisway. Here's an example of mounting an sshfs filesystem:sshfs#user@host:/ /mnt/host fuse defaults 0 0The mounting is performed by the /sbin/mount.fuse helper script.Licensing issues~~~~~~~~~~~~~~~~Under what license is FUSE released?------------------------------------The kernel part is released under the GNU GPL.Libfuse is released under the GNU LGPL.All other parts (examples, fusermount, etc) are released under the GNU GPL.Under what conditions may I modify or distribute FUSE?------------------------------------------------------See the files COPYING and COPYING.LIB in the distribution.More information can be found at http://www.gnu.org/licenses/Under what conditions may I distribute a filesystem which uses libfuse?-----------------------------------------------------------------------See COPYING.LIB in the distribution.In simple terms as long as you are linking dynamically (the default)there are no limitations on linking with libfuse. For example you maydistribute the filesystem itself in binary form, without source code,under any propriatery license.Under what conditions may I distribute a filesystem that uses the raw---------------------------------------------------------------------kernel interface of FUSE?-------------------------There are no restrictions whatsoever for using the raw kernel interface.API===Which method is called on the close() system call?--------------------------------------------------flush() and possibly release(). For details see the documentation ofthese methods in <fuse.h>Wouldn't it be simpler if there were a single close() method?-------------------------------------------------------------No, because the relationship between the close() system call and therelease of the file (the opposite of open) is not as simple as peopletend to imagine. UNIX allows open files to acquire multiplereferences * after fork() two processes refer to the same open file * dup() and dup2() make another file descriptor refer to the same file * mmap() makes a memory mapping refer to an open fileThis means, that for a single open() system call, there could be morethan one close() and possibly munmap() calls until the open file isfinally released.Can I return an error from release()?-------------------------------------No, it's not possible.If you need to return errors on close, you must do that from flush().How do I know which is the last flush() before release()?---------------------------------------------------------You can't. All flush() calls should be treated equally. Anyway itwouldn't be worth optimizing away non-final flushes, since it's fairlyrare to have multiple write-flush sequences on an open file.Why doesn't FUSE forward ioctl() calls to the filesystem?---------------------------------------------------------Because it's not possible: data passed to ioctl() doesn't have a welldefined length and structure like read() and write(). Consider usinggetxattr() and setxattr() instead.Is there a way to know the uid, gid or pid of the process performing--------------------------------------------------------------------the operation?--------------Yes: fuse_get_context()->uid, etc.How should threads be started?------------------------------Miscellaneous threads should be started from the init() method.Threads started before fuse_main() will exit when the process goesinto the background.Is it possible to store a pointer to private data in the--------------------------------------------------------fuse_file_info structure?-------------------------Yes, the 'fh' filed is for this purpose. This filed may be set in theopen() and create() methods, and is available in all other methodshaving a struct fuse_file_info parameter. Note, that changing thevalue of 'fh' in any other method as open() or create() will have noaffect.Since the type of 'fh' is unsigned long, you need to use casts whenstoring and retrieving a pointer. Under Linux (and most otherarchitectures) an unsigned long will be able to hold a pointer.This could have been done with a union of 'void *' and 'unsigned long'but that would not have been any more type safe as having to useexplicit casts. The recommended type safe solution is to write asmall inline function that retrieves the pointer from thefuse_file_info structure.Problems========Version problems~~~~~~~~~~~~~~~~Why do I get Connection Refused after mounting?-----------------------------------------------Library is too old (< 2.3.0)You can check which version of the library is being used by foofs bydoing 'ldd path_to_foofs'. It will return something like this libfuse.so.2 => /usr/local/lib/libfuse.so.2 (0xb7fc9000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0xb7fb9000) libglib-2.0.so.0 => /usr/lib/libglib-2.0.so.0 (0xb7f39000) libc.so.6 => /lib/tls/libc.so.6 (0xb7e04000)Then do 'ls -l path_to_libfuse'> ls -l /usr/local/lib/libfuse.so.2lrwxrwxrwx 1 root root 16 Sep 26 13:41 /usr/local/lib/libfuse.so.2 -> libfuse.so.2.2.1Why does fusermount fail with an Unknown option error?------------------------------------------------------Errors like 'fusermount: Unknown option -o' or 'fusermount: Unknownoption --' mean, that an old version of fusermount is being used. Youcan check by doing 'which fusermount'.If you installed FUSE from source, then this is probably because thereexists a binary package on your system which also contains afusermount program, and is found first in the path, e.g. in/usr/bin/fusermount.The solution is to remove the binary package.Installation problems~~~~~~~~~~~~~~~~~~~~~Why is there an error loading shared libraries?-----------------------------------------------If you get the following error when starting a FUSE-based filesystem: foofs: error while loading shared libraries: libfuse.so.2: cannot open shared object file: No such file or directorycheck /etc/ld.so.conf for a line containing '/usr/local/lib'. If it'smissing, add it, and run ldconfig afterwards.Why doesn't mounting as user work if installing FUSE from a package?--------------------------------------------------------------------Distributions often package 'fusermount' without the suid bit, or onlyexecutable to the 'fuse' group.This results in the following message, when trying to mount afilesystem as an unprivileged user: fusermount: mount failed: Operation not permittedThe simplest solution is to change the mode of 'fusermount': chmod 4755 /usr/bin/fusermountNote, you may have to do this after each upgrade.Other problems~~~~~~~~~~~~~~Why are some bytes zeroed when reading a file?----------------------------------------------This happens if the filesystem returns a short count from the read()method. If the file wasn't opened in direct I/O mode, the read()method must return exactly the requested number of bytes, unless it'sthe end of the file.If the file was opened in direct I/O mode (with direct_io mountoption, or by setting the direct_io field of fuse_file_info at open)the read can return a smaller value than requested. In this case theend of file can be signalled by returning zero.Why does cp return operation not permitted when copying a file with no----------------------------------------------------------------------write permissions for the owner?--------------------------------"cp" calls open(2) with read-only permissions and O_CREAT, the purposebeing to atomically obtain a read/write file handle and make the fileread-only. Unfortunately, this does not work very well in fuse, sinceyou first get a mknod, and then an open call. At the time of open, youcan't distinguish easily wether this is the first open issued by cp,or another process trying to write a read-only file.Defining the 'create' method solves this problem, however thisrequires a Linux kernel version of at least 2.6.15 and libfuse version2.5 or greater.There can be other workarounds, however the easy one is to use the"default_permissions" mount option, and to avoid checking permissionson open. If you store files on a filesystem, this can get trickybecause you will have to change the file mode to allow writing. Usingthe stateful API (i.e. returning an handle on open) will simplifythings. In this case, and using "-o default_permissions", whenimplementing the open call you have to:1. check if the open is in write mode (i.e. mode has O_RDWR or O_WRONLY)2. in that case (in mutual exclusion with other open, getattr etc. calls on the same file) change the mode from "M" to "M OR 0o200"3. open the file, change back the mode even in case of errors, and return the obtained handleWhy doesn't find work on my filesystem?---------------------------------------The st_nlink member must be set correctly for directories to make findwork. If it's not set correctly the -noleaf option of find can beused to make it ignore the hard link count (see man find).The correct value of st_nlink for directories is NSUB + 2. Where NSUBis the number of subdirectories. NOTE: regular-file/symlink/etcentries do not count into NSUB, only directories.If calculating NSUB is hard, the filesystem can set st_nlink ofdirectories to 1, and find will still work. This is not documentedbehavior of find, and it's not clear whether this is intended or justby accident. But for example the NTFS filesysem relies on this, soit's unlikely that this "feature" will go away.What is the reason for IO errors?---------------------------------The kernel part of FUSE returns the EIO error value, whenever theuserspace filesystem sends a "bad" reply. Sometimes these areunavoidable, and not necessarily a fault of the filesystem. Possiblecauses of this are (non-exhaustive) * the filesystem returned a short count on write() * the type of the file has changed (e.g. a directory suddenly became a symlink) * a directory entry contained a filename that was too long (no, ENAMETOOLONG is not the right error here) * the same node ID value was used for two different directories (i.e. hard-linked directories are not allowed)Misc====Can the filesystem ask a question on the terminal of the user?--------------------------------------------------------------It would not be possible generally speaking, since it might not be aninteractive program but rather a daemon, or a GUI program doing theoperation. However you should be able to get the PID for the caller,and by looking in /proc you should be able to find the process tty orsomething similar.But this is not recommended. You should rather think about solvingthis another way.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -