xref: /aosp_15_r20/external/libfuse/README.md (revision 9e5649576b786774a32d7b0252c9cd8c6538fa49)
1*9e564957SAndroid Build Coastguard Workerlibfuse
2*9e564957SAndroid Build Coastguard Worker=======
3*9e564957SAndroid Build Coastguard Worker
4*9e564957SAndroid Build Coastguard WorkerAbout
5*9e564957SAndroid Build Coastguard Worker-----
6*9e564957SAndroid Build Coastguard Worker
7*9e564957SAndroid Build Coastguard WorkerFUSE (Filesystem in Userspace) is an interface for userspace programs
8*9e564957SAndroid Build Coastguard Workerto export a filesystem to the Linux kernel. The FUSE project consists
9*9e564957SAndroid Build Coastguard Workerof two components: the *fuse* kernel module (maintained in the regular
10*9e564957SAndroid Build Coastguard Workerkernel repositories) and the *libfuse* userspace library (maintained
11*9e564957SAndroid Build Coastguard Workerin this repository). libfuse provides the reference implementation
12*9e564957SAndroid Build Coastguard Workerfor communicating with the FUSE kernel module.
13*9e564957SAndroid Build Coastguard Worker
14*9e564957SAndroid Build Coastguard WorkerA FUSE file system is typically implemented as a standalone
15*9e564957SAndroid Build Coastguard Workerapplication that links with libfuse. libfuse provides functions to
16*9e564957SAndroid Build Coastguard Workermount the file system, unmount it, read requests from the kernel, and
17*9e564957SAndroid Build Coastguard Workersend responses back. libfuse offers two APIs: a "high-level",
18*9e564957SAndroid Build Coastguard Workersynchronous API, and a "low-level" asynchronous API. In both cases,
19*9e564957SAndroid Build Coastguard Workerincoming requests from the kernel are passed to the main program using
20*9e564957SAndroid Build Coastguard Workercallbacks. When using the high-level API, the callbacks may work with
21*9e564957SAndroid Build Coastguard Workerfile names and paths instead of inodes, and processing of a request
22*9e564957SAndroid Build Coastguard Workerfinishes when the callback function returns. When using the low-level
23*9e564957SAndroid Build Coastguard WorkerAPI, the callbacks must work with inodes and responses must be sent
24*9e564957SAndroid Build Coastguard Workerexplicitly using a separate set of API functions.
25*9e564957SAndroid Build Coastguard Worker
26*9e564957SAndroid Build Coastguard Worker
27*9e564957SAndroid Build Coastguard WorkerDevelopment Status
28*9e564957SAndroid Build Coastguard Worker------------------
29*9e564957SAndroid Build Coastguard Worker
30*9e564957SAndroid Build Coastguard Workerlibfuse is shipped by all major Linux distributions and has been in
31*9e564957SAndroid Build Coastguard Workerproduction use across a wide range of systems for many years. However,
32*9e564957SAndroid Build Coastguard Workerat present libfuse does not have any active, regular contributors. The
33*9e564957SAndroid Build Coastguard Workercurrent maintainer continues to apply pull requests and makes regular
34*9e564957SAndroid Build Coastguard Workerreleases, but unfortunately has no capacity to do any development
35*9e564957SAndroid Build Coastguard Workerbeyond addressing high-impact issues. When reporting bugs, please
36*9e564957SAndroid Build Coastguard Workerunderstand that unless you are including a pull request or are
37*9e564957SAndroid Build Coastguard Workerreporting a critical issue, you will probably not get a response. If
38*9e564957SAndroid Build Coastguard Workeryou are using libfuse, please consider contributing to the project.
39*9e564957SAndroid Build Coastguard Worker
40*9e564957SAndroid Build Coastguard Worker
41*9e564957SAndroid Build Coastguard WorkerSupported Platforms
42*9e564957SAndroid Build Coastguard Worker-------------------
43*9e564957SAndroid Build Coastguard Worker
44*9e564957SAndroid Build Coastguard Worker* Linux (fully)
45*9e564957SAndroid Build Coastguard Worker* BSD (mostly/best-effort)
46*9e564957SAndroid Build Coastguard Worker* For OS-X, please use [OSXFUSE](https://osxfuse.github.io/)
47*9e564957SAndroid Build Coastguard Worker
48*9e564957SAndroid Build Coastguard Worker
49*9e564957SAndroid Build Coastguard WorkerInstallation
50*9e564957SAndroid Build Coastguard Worker------------
51*9e564957SAndroid Build Coastguard Worker
52*9e564957SAndroid Build Coastguard WorkerYou can download libfuse from https://github.com/libfuse/libfuse/releases. To build and
53*9e564957SAndroid Build Coastguard Workerinstall, you must use [Meson](http://mesonbuild.com/) and
54*9e564957SAndroid Build Coastguard Worker[Ninja](https://ninja-build.org).  After downloading the tarball and `.sig` file, verify
55*9e564957SAndroid Build Coastguard Workerit using [signify](https://www.openbsd.org/papers/bsdcan-signify.html):
56*9e564957SAndroid Build Coastguard Worker
57*9e564957SAndroid Build Coastguard Worker    signify -V -m fuse-X.Y.Z.tar.gz -p fuse-X.Y.pub
58*9e564957SAndroid Build Coastguard Worker
59*9e564957SAndroid Build Coastguard WorkerThe `fuse-X.Y.pub` file contains the signing key and needs to be obtained from a
60*9e564957SAndroid Build Coastguard Workertrustworthy source. Each libfuse release contains the signing key for the release after it
61*9e564957SAndroid Build Coastguard Workerin the `signify` directory, so you only need to manually acquire this file once when you
62*9e564957SAndroid Build Coastguard Workerinstall libfuse for the first time.
63*9e564957SAndroid Build Coastguard Worker
64*9e564957SAndroid Build Coastguard WorkerAfter you have validated the tarball, extract it, create a (temporary) build directory and
65*9e564957SAndroid Build Coastguard Workerrun Meson:
66*9e564957SAndroid Build Coastguard Worker
67*9e564957SAndroid Build Coastguard Worker    $ tar xzf fuse-X.Y.Z.tar.gz; cd fuse-X.Y.Z
68*9e564957SAndroid Build Coastguard Worker    $ mkdir build; cd build
69*9e564957SAndroid Build Coastguard Worker    $ meson setup ..
70*9e564957SAndroid Build Coastguard Worker
71*9e564957SAndroid Build Coastguard WorkerNormally, the default build options will work fine. If you
72*9e564957SAndroid Build Coastguard Workernevertheless want to adjust them, you can do so with the
73*9e564957SAndroid Build Coastguard Worker*meson configure* command:
74*9e564957SAndroid Build Coastguard Worker
75*9e564957SAndroid Build Coastguard Worker    $ meson configure # list options
76*9e564957SAndroid Build Coastguard Worker    $ meson configure -D disable-mtab=true # set an optionq
77*9e564957SAndroid Build Coastguard Worker
78*9e564957SAndroid Build Coastguard Worker    $ # ensure all meson options are applied to the final build system
79*9e564957SAndroid Build Coastguard Worker    $ meson setup --reconfigure ../
80*9e564957SAndroid Build Coastguard Worker
81*9e564957SAndroid Build Coastguard WorkerTo build, test, and install libfuse, you then use Ninja:
82*9e564957SAndroid Build Coastguard Worker
83*9e564957SAndroid Build Coastguard Worker    $ ninja
84*9e564957SAndroid Build Coastguard Worker    $ sudo python3 -m pytest test/
85*9e564957SAndroid Build Coastguard Worker    $ sudo ninja install
86*9e564957SAndroid Build Coastguard Worker
87*9e564957SAndroid Build Coastguard WorkerRunning the tests requires the [py.test](http://www.pytest.org/)
88*9e564957SAndroid Build Coastguard WorkerPython module. Instead of running the tests as root, the majority of
89*9e564957SAndroid Build Coastguard Workertests can also be run as a regular user if *util/fusermount3* is made
90*9e564957SAndroid Build Coastguard Workersetuid root first:
91*9e564957SAndroid Build Coastguard Worker
92*9e564957SAndroid Build Coastguard Worker    $ sudo chown root:root util/fusermount3
93*9e564957SAndroid Build Coastguard Worker    $ sudo chmod 4755 util/fusermount3
94*9e564957SAndroid Build Coastguard Worker    $ python3 -m pytest test/
95*9e564957SAndroid Build Coastguard Worker
96*9e564957SAndroid Build Coastguard WorkerSecurity implications
97*9e564957SAndroid Build Coastguard Worker---------------------
98*9e564957SAndroid Build Coastguard Worker
99*9e564957SAndroid Build Coastguard WorkerThe *fusermount3* program is installed setuid root. This is done to
100*9e564957SAndroid Build Coastguard Workerallow normal users to mount their own filesystem implementations.
101*9e564957SAndroid Build Coastguard Worker
102*9e564957SAndroid Build Coastguard WorkerTo limit the harm that malicious users can do this way, *fusermount3*
103*9e564957SAndroid Build Coastguard Workerenforces the following limitations:
104*9e564957SAndroid Build Coastguard Worker
105*9e564957SAndroid Build Coastguard Worker  - The user can only mount on a mountpoint for which they have write
106*9e564957SAndroid Build Coastguard Worker    permission
107*9e564957SAndroid Build Coastguard Worker
108*9e564957SAndroid Build Coastguard Worker  - The mountpoint must not be a sticky directory which isn't owned by
109*9e564957SAndroid Build Coastguard Worker    the user (like /tmp usually is)
110*9e564957SAndroid Build Coastguard Worker
111*9e564957SAndroid Build Coastguard Worker  - No other user (including root) can access the contents of the
112*9e564957SAndroid Build Coastguard Worker    mounted filesystem (though this can be relaxed by allowing the use
113*9e564957SAndroid Build Coastguard Worker    of the *allow_other* and *allow_root* mount options in
114*9e564957SAndroid Build Coastguard Worker    */etc/fuse.conf*)
115*9e564957SAndroid Build Coastguard Worker
116*9e564957SAndroid Build Coastguard Worker
117*9e564957SAndroid Build Coastguard WorkerIf you intend to use the *allow_other* mount options, be aware that
118*9e564957SAndroid Build Coastguard WorkerFUSE has an unresolved [security
119*9e564957SAndroid Build Coastguard Workerbug](https://github.com/libfuse/libfuse/issues/15): if the
120*9e564957SAndroid Build Coastguard Worker*default_permissions* mount option is not used, the results of the
121*9e564957SAndroid Build Coastguard Workerfirst permission check performed by the file system for a directory
122*9e564957SAndroid Build Coastguard Workerentry will be re-used for subsequent accesses as long as the inode of
123*9e564957SAndroid Build Coastguard Workerthe accessed entry is present in the kernel cache - even if the
124*9e564957SAndroid Build Coastguard Workerpermissions have since changed, and even if the subsequent access is
125*9e564957SAndroid Build Coastguard Workermade by a different user. This is of little concern if the filesystem
126*9e564957SAndroid Build Coastguard Workeris accessible only to the mounting user (which has full access to the
127*9e564957SAndroid Build Coastguard Workerfilesystem anyway), but becomes a security issue when other users are
128*9e564957SAndroid Build Coastguard Workerallowed to access the filesystem (since they can exploit this to
129*9e564957SAndroid Build Coastguard Workerperform operations on the filesystem that they do not actually have
130*9e564957SAndroid Build Coastguard Workerpermissions for).
131*9e564957SAndroid Build Coastguard Worker
132*9e564957SAndroid Build Coastguard WorkerThis bug needs to be fixed in the Linux kernel and has been known
133*9e564957SAndroid Build Coastguard Workersince 2006 but unfortunately no fix has been applied yet. If you
134*9e564957SAndroid Build Coastguard Workerdepend on correct permission handling for FUSE file systems, the only
135*9e564957SAndroid Build Coastguard Workerworkaround is to use `default_permissions` (which does not currently
136*9e564957SAndroid Build Coastguard Workersupport ACLs), or to completely disable caching of directory entry
137*9e564957SAndroid Build Coastguard Workerattributes.
138*9e564957SAndroid Build Coastguard Worker
139*9e564957SAndroid Build Coastguard WorkerBuilding your own filesystem
140*9e564957SAndroid Build Coastguard Worker------------------------------
141*9e564957SAndroid Build Coastguard Worker
142*9e564957SAndroid Build Coastguard WorkerFUSE comes with several example file systems in the `example`
143*9e564957SAndroid Build Coastguard Workerdirectory. For example, the *passthrough* examples mirror the contents
144*9e564957SAndroid Build Coastguard Workerof the root directory under the mountpoint. Start from there and adapt
145*9e564957SAndroid Build Coastguard Workerthe code!
146*9e564957SAndroid Build Coastguard Worker
147*9e564957SAndroid Build Coastguard WorkerThe documentation of the API functions and necessary callbacks is
148*9e564957SAndroid Build Coastguard Workermostly contained in the files `include/fuse.h` (for the high-level
149*9e564957SAndroid Build Coastguard WorkerAPI) and `include/fuse_lowlevel.h` (for the low-level API). An
150*9e564957SAndroid Build Coastguard Workerautogenerated html version of the API is available in the `doc/html`
151*9e564957SAndroid Build Coastguard Workerdirectory and at http://libfuse.github.io/doxygen.
152*9e564957SAndroid Build Coastguard Worker
153*9e564957SAndroid Build Coastguard Worker
154*9e564957SAndroid Build Coastguard WorkerGetting Help
155*9e564957SAndroid Build Coastguard Worker------------
156*9e564957SAndroid Build Coastguard Worker
157*9e564957SAndroid Build Coastguard WorkerIf you need help, please ask on the <[email protected]>
158*9e564957SAndroid Build Coastguard Workermailing list (subscribe at
159*9e564957SAndroid Build Coastguard Workerhttps://lists.sourceforge.net/lists/listinfo/fuse-devel).
160*9e564957SAndroid Build Coastguard Worker
161*9e564957SAndroid Build Coastguard WorkerPlease report any bugs on the GitHub issue tracker at
162*9e564957SAndroid Build Coastguard Workerhttps://github.com/libfuse/libfuse/issues.
163