mirror of https://github.com/trapexit/mergerfs.git
Antonio SJ Musumeci
5 years ago
46 changed files with 9985 additions and 16429 deletions
-
3547libfuse/ChangeLog
-
9libfuse/Makefile
-
303libfuse/NEWS
-
33libfuse/README.NFS
-
108libfuse/README.md
-
11libfuse/fuse.pc.in
-
17libfuse/include/Makefile.am
-
87libfuse/include/cuse_lowlevel.h
-
121libfuse/include/fuse.h
-
22libfuse/include/fuse_chan.h
-
17libfuse/include/fuse_common.h
-
2libfuse/include/fuse_common_compat.h
-
196libfuse/include/fuse_compat.h
-
340libfuse/include/fuse_lowlevel.h
-
13libfuse/include/fuse_lowlevel_compat.h
-
42libfuse/lib/Makefile.am
-
371libfuse/lib/cuse_lowlevel.c
-
496libfuse/lib/fuse.c
-
248libfuse/lib/fuse_chan.c
-
56libfuse/lib/fuse_dev.c
-
40libfuse/lib/fuse_dev.h
-
48libfuse/lib/fuse_i.h
-
103libfuse/lib/fuse_kern_chan.c
-
46libfuse/lib/fuse_loop.c
-
117libfuse/lib/fuse_loop_mt.c
-
914libfuse/lib/fuse_lowlevel.c
-
92libfuse/lib/fuse_mt.c
-
185libfuse/lib/fuse_session.c
-
207libfuse/lib/fuse_versionscript
-
208libfuse/lib/helper.c
-
17libfuse/lib/mount_generic.c
-
17libfuse/lib/mount_util.c
-
1libfuse/lib/mount_util.h
-
48libfuse/lib/sys.c
-
4libfuse/lib/sys.h
-
27libfuse/util/fusermount.c
-
4libfuse/util/mount.mergerfs.c
-
17libfuse/util/mount_util.c
-
2src/config.cpp
-
2src/fuse_init.cpp
-
2src/option_parser.cpp
3547
libfuse/ChangeLog
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1,303 +0,0 @@ |
|||||
What is new in 2.9 |
|
||||
|
|
||||
- Add "zero copy" support for kernel 2.6.35 or newer |
|
||||
|
|
||||
- Make maximum background requests tunable on kernel 2.6.32 or newer |
|
||||
|
|
||||
- Require --no-canonicalize in (u)mount (util-linux version 2.18 or |
|
||||
newer) to fix security problems with fusermount |
|
||||
|
|
||||
- Use dynamically sized hash tables in high level library |
|
||||
|
|
||||
- Memory use of filesystem daemon can shrink more easily |
|
||||
|
|
||||
- Add "auto_unmount" option |
|
||||
|
|
||||
- Add "remember" option |
|
||||
|
|
||||
- Add man pages for fusermount, mount.fuse and ulockmgr_server |
|
||||
|
|
||||
- API changes: |
|
||||
|
|
||||
o Introduce "store" and "retrieve" for accessing kernel buffers on |
|
||||
kernel 2.6.36 or newer |
|
||||
|
|
||||
o Introduce abstract buffer for zero copy operations |
|
||||
|
|
||||
o Allow path calculation to be omitted on certain operations |
|
||||
|
|
||||
o Allow batching forget requests |
|
||||
|
|
||||
o Add "flock" method |
|
||||
|
|
||||
o Add support for ioctl on directories |
|
||||
|
|
||||
o Add delete notification |
|
||||
|
|
||||
o Add fallocate operation (linux kernel 3.5 or newer) |
|
||||
|
|
||||
- Bug fixes and small improvements |
|
||||
|
|
||||
============================================================================ |
|
||||
|
|
||||
What is new in 2.8 |
|
||||
|
|
||||
- More scalable directory tree locking |
|
||||
|
|
||||
- Atomic open(O_TRUNC) support |
|
||||
|
|
||||
- Support big write requests on kernels 2.6.26 and newer |
|
||||
|
|
||||
- Out-of-tree fuse module removed |
|
||||
|
|
||||
- Better NFS exporting support |
|
||||
|
|
||||
- New ioctl and poll requests |
|
||||
|
|
||||
- New CUSE (Character Device in Userspace) interface |
|
||||
|
|
||||
- Allow umask processing in userspace |
|
||||
|
|
||||
- Added cache invalidation notifications |
|
||||
|
|
||||
- Bugfixes and small improvements |
|
||||
|
|
||||
============================================================================ |
|
||||
|
|
||||
What is new in 2.7 |
|
||||
|
|
||||
- Stacking support for the high level API |
|
||||
|
|
||||
- Add filename charset conversion module |
|
||||
|
|
||||
- Improved mounting |
|
||||
|
|
||||
============================================================================ |
|
||||
|
|
||||
What is new in 2.6 |
|
||||
|
|
||||
- Improved read characteristics (asynchronous reads) |
|
||||
|
|
||||
- Support for aborting filesystem connection |
|
||||
|
|
||||
- POSIX file locking support |
|
||||
|
|
||||
- Request interruption support |
|
||||
|
|
||||
- Building module for Linux kernels earlier than 2.6.9 not supported |
|
||||
|
|
||||
- Allow block device based filesystems to support swap files |
|
||||
|
|
||||
- Several bugs fixed, including a rare system hang on SMP |
|
||||
|
|
||||
============================================================================ |
|
||||
|
|
||||
What is new in 2.5 |
|
||||
|
|
||||
- Merge library part of FreeBSD port |
|
||||
|
|
||||
- New atomic create+open, access and ftruncate operations |
|
||||
|
|
||||
- On filesystems implementing the new create+open operation, and |
|
||||
running on Linux kernels 2.6.15 or later, the 'cp' operation will |
|
||||
work correctly when copying read-only files. |
|
||||
|
|
||||
- New option parsing interface added to the library |
|
||||
|
|
||||
- Lots of minor improvements and fixes |
|
||||
|
|
||||
============================================================================ |
|
||||
|
|
||||
What is new in 2.4 |
|
||||
|
|
||||
- Simplify device opening. Now '/dev/fuse' is a requirement |
|
||||
|
|
||||
- Allow module auto-loading if user has access to '/dev/fuse' |
|
||||
|
|
||||
- Allow mounting over a regular file for unprivileged users |
|
||||
|
|
||||
- Allow mounting of arbitrary FUSE filesystems from /etc/fstab |
|
||||
|
|
||||
- New mount options: 'umask=M', 'uid=N', 'gid=N' |
|
||||
|
|
||||
- Check for non-empty mountpoint, and refuse mount by default. New |
|
||||
mount option: 'nonempty' |
|
||||
|
|
||||
- Low level (inode based) API added |
|
||||
|
|
||||
- Allow 'direct_io' and 'keep_cache' options to be set on a |
|
||||
case-by-case basis on open. |
|
||||
|
|
||||
- Add 'attr_timeout' and 'entry_timeout' mount options to the |
|
||||
high-level library. Until now these timeouts were fixed at 1 sec. |
|
||||
|
|
||||
- Some bugfixes |
|
||||
|
|
||||
============================================================================ |
|
||||
|
|
||||
What is new in 2.3 |
|
||||
|
|
||||
- Add new directory related operations: opendir(), readdir(), |
|
||||
releasedir() and fsyncdir() |
|
||||
|
|
||||
- Add init() and destroy() operations which are called before the |
|
||||
event loop is started and after it has exited |
|
||||
|
|
||||
- Update kernel ABI so that on dual architectures (e.g. AMD64) 32bit |
|
||||
binaries work under a 64bit kernel |
|
||||
|
|
||||
- Bugfixes |
|
||||
|
|
||||
============================================================================ |
|
||||
|
|
||||
What is new in 2.2 |
|
||||
|
|
||||
Userspace changes: |
|
||||
|
|
||||
- Add fuse_file_info structure to file operations, this allows the |
|
||||
filesystem to return a file handle in open() which is passed to |
|
||||
read(), write(), flush(), fsync() and release(). |
|
||||
|
|
||||
- Add source compatibility with 2.1 and 1.4 releases |
|
||||
|
|
||||
- Binary compatibility with 2.1 release is retained |
|
||||
|
|
||||
Kernel changes: |
|
||||
|
|
||||
- Make requests interruptible. This prevents the filesystem to go |
|
||||
into an unbreakable deadlock with itself. |
|
||||
|
|
||||
- Make readpages() synchronous. Asynchronous requests are deadlock |
|
||||
prone, since they cannot be interrupted (see above) |
|
||||
|
|
||||
- Remove shared-writeable mapping support, which could deadlock the |
|
||||
machine |
|
||||
|
|
||||
- Remove INVALIDATE userspace initiated request |
|
||||
|
|
||||
- Update ABI to be independent of sizeof(long), so dual-size archs |
|
||||
don't cause problems |
|
||||
|
|
||||
- Remove /sys/fs/fuse/version. Version checking is now done through |
|
||||
the fuse device |
|
||||
|
|
||||
- Replace directory reading method on the kernel interface. Instead |
|
||||
of passing an open file descriptor to the kernel, send data through |
|
||||
the FUSE device, like all other operations. |
|
||||
|
|
||||
============================================================================ |
|
||||
|
|
||||
What is new in 2.1 |
|
||||
|
|
||||
* Bug fixes |
|
||||
|
|
||||
* Improved support for filesystems implementing a custom event-loop |
|
||||
|
|
||||
* Add 'pkg-config' support |
|
||||
|
|
||||
* Kernel module can be compiled separately |
|
||||
|
|
||||
============================================================================ |
|
||||
|
|
||||
What is new in 1.9 |
|
||||
|
|
||||
* Lots of bugs fixed |
|
||||
|
|
||||
* Minor modifications to the library API |
|
||||
|
|
||||
* Improvements to the kernel/userspace interface |
|
||||
|
|
||||
* Mounting by non-root made more secure |
|
||||
|
|
||||
* Build shared library in addition to the static one |
|
||||
|
|
||||
* Consolidated mount options |
|
||||
|
|
||||
* Optimized reading under 2.6 kernels |
|
||||
|
|
||||
* Direct I/O support |
|
||||
|
|
||||
* Support file I/O on deleted files |
|
||||
|
|
||||
* Extended attributes support |
|
||||
|
|
||||
============================================================================ |
|
||||
|
|
||||
What is new in 1.3 |
|
||||
|
|
||||
* Thanks to user bugreports and stress testing with LTP and sfx-linux |
|
||||
a number of bugs were fixed, some quite serious. |
|
||||
|
|
||||
* Fix compile problems with recent SuSE kernles |
|
||||
|
|
||||
============================================================================ |
|
||||
|
|
||||
What is new in 1.2 |
|
||||
|
|
||||
* Fix mount problems on recent 2.6 kernels with SELinux enabled |
|
||||
|
|
||||
* Fixed writing files lager than 2GBytes |
|
||||
|
|
||||
* Other bugfixes |
|
||||
|
|
||||
============================================================================ |
|
||||
|
|
||||
What is new in 1.1 |
|
||||
|
|
||||
* Support for the 2.6 kernels |
|
||||
|
|
||||
* Support for exporting filesystem over NFS in 2.6 kernels |
|
||||
|
|
||||
* Read efficiency improvements: read in 64k blocks instead of 4k |
|
||||
(Michael Grigoriev). Can be turned on with '-l' option of fusermount |
|
||||
|
|
||||
* Lazy automatic unmount |
|
||||
|
|
||||
* Added 'fsync()' VFS call to the FUSE interface |
|
||||
|
|
||||
* Bugfixes |
|
||||
|
|
||||
============================================================================ |
|
||||
|
|
||||
What is new in 1.0 |
|
||||
|
|
||||
* Cleanups and bugfixes |
|
||||
|
|
||||
* Added 'release()' VFS call to the FUSE interface |
|
||||
|
|
||||
* 64 bit file offsets (handling of > 4 GByte files) |
|
||||
|
|
||||
* libfuse is now under LGPL |
|
||||
|
|
||||
* New 'statfs' call (Mark Glines) |
|
||||
|
|
||||
* Cleaned up mount procedure (mostly by Mark Glines) |
|
||||
|
|
||||
NOTE: Binaries linked with with a previous version of libavfs may |
|
||||
not work with the new version of the fusermount program. In such |
|
||||
case recompile the program after installing the new libavfs library. |
|
||||
|
|
||||
* Fix for problems under linux kernel 2.4.19 |
|
||||
|
|
||||
============================================================================ |
|
||||
|
|
||||
What is new in 0.95 |
|
||||
|
|
||||
* Optimized read/write operations. Raw throughput has increased to |
|
||||
about 60Mbyte/s on a Celeron/360 |
|
||||
|
|
||||
* Python bindings by Jeff Epler |
|
||||
|
|
||||
* Perl bindings by Mark Glines |
|
||||
|
|
||||
* Improved multithreaded operation |
|
||||
|
|
||||
* Simplified library interface |
|
||||
|
|
||||
* Bugfixes |
|
||||
|
|
||||
============================================================================ |
|
||||
|
|
||||
What is new in 0.9: |
|
||||
|
|
||||
* Everything |
|
@ -1,33 +0,0 @@ |
|||||
NFS exporting is supported in Linux kernels 2.6.27 or later. |
|
||||
|
|
||||
You need to add an fsid=NNN option to /etc/exports to make exporting a |
|
||||
FUSE directory work. |
|
||||
|
|
||||
Filesystem support |
|
||||
------------------ |
|
||||
|
|
||||
NFS exporting works to some extent on all fuse filesystems, but not |
|
||||
perfectly. This is due to the stateless nature of the protocol, the |
|
||||
server has no way of knowing whether the client is keeping a reference |
|
||||
to a file or not, and hence that file may be removed from the server's |
|
||||
cache. In that case there has to be a way to look up that object |
|
||||
using the inode number, otherwise an ESTALE error will be returned. |
|
||||
|
|
||||
1) low-level interface |
|
||||
|
|
||||
Filesystems need to implement special lookups for the names "." and |
|
||||
"..". The former may be requested on any inode, including |
|
||||
non-directories, while the latter is only requested for directories. |
|
||||
Otherwise these special lookups should behave identically to ordinary |
|
||||
lookups. |
|
||||
|
|
||||
2) high-level interface |
|
||||
|
|
||||
Because the high-level interface is path based, it is not possible to |
|
||||
delegate looking up by inode to the filesystem. |
|
||||
|
|
||||
To work around this, currently a "noforget" option is provided, which |
|
||||
makes the library remember nodes forever. This will make the NFS |
|
||||
server happy, but also results in an ever growing memory footprint for |
|
||||
the filesystem. For this reason if the filesystem is large (or the |
|
||||
memory is small), then this option is not recommended. |
|
@ -1,108 +0,0 @@ |
|||||
libfuse |
|
||||
======= |
|
||||
|
|
||||
Warning: unresolved security issue |
|
||||
---------------------------------- |
|
||||
|
|
||||
Be aware that FUSE has an unresolved security bug |
|
||||
([bug #15](https://github.com/libfuse/libfuse/issues/15)): the |
|
||||
permission check for accessing a cached directory is only done once |
|
||||
when the directory entry is first loaded into the cache. Subsequent |
|
||||
accesses will re-use the results of the first check, even if the |
|
||||
directory permissions have since changed, and even if the subsequent |
|
||||
access is made by a different user. |
|
||||
|
|
||||
This bug needs to be fixed in the Linux kernel and has been known |
|
||||
since 2006 but unfortunately no fix has been applied yet. If you |
|
||||
depend on correct permission handling for FUSE file systems, the only |
|
||||
workaround is to completely disable caching of directory |
|
||||
entries. Alternatively, the severity of the bug can be somewhat |
|
||||
reduced by not using the `allow_other` mount option. |
|
||||
|
|
||||
|
|
||||
About |
|
||||
----- |
|
||||
|
|
||||
FUSE (Filesystem in Userspace) is an interface for userspace programs |
|
||||
to export a filesystem to the Linux kernel. The FUSE project consists |
|
||||
of two components: the *fuse* kernel module (maintained in the regular |
|
||||
kernel repositories) and the *libfuse* userspace library (maintained |
|
||||
in this repository). libfuse provides the reference implementation |
|
||||
for communicating with the FUSE kernel module. |
|
||||
|
|
||||
A FUSE file system is typically implemented as a standalone |
|
||||
application that links with libfuse. libfuse provides functions to |
|
||||
mount the file system, unmount it, read requests from the kernel, and |
|
||||
send responses back. libfuse offers two APIs: a "high-level", |
|
||||
synchronous API, and a "low-level" asynchronous API. In both cases, |
|
||||
incoming requests from the kernel are passed to the main program using |
|
||||
callbacks. When using the high-level API, the callbacks may work with |
|
||||
file names and paths instead of inodes, and processing of a request |
|
||||
finishes when the callback function returns. When using the low-level |
|
||||
API, the callbacks must work with inodes and responses must be sent |
|
||||
explicitly using a separate set of API functions. |
|
||||
|
|
||||
|
|
||||
Installation |
|
||||
------------ |
|
||||
|
|
||||
./configure |
|
||||
make -j8 |
|
||||
make install |
|
||||
|
|
||||
You may also need to add `/usr/local/lib` to `/etc/ld.so.conf` and/or |
|
||||
run *ldconfig*. If you're building from the git repository (instead of |
|
||||
using a release tarball), you also need to run `./makeconf.sh` to |
|
||||
create the `configure` script. |
|
||||
|
|
||||
You'll also need a fuse kernel module (Linux kernels 2.6.14 or later |
|
||||
contain FUSE support). |
|
||||
|
|
||||
For more details see the file `INSTALL` |
|
||||
|
|
||||
Security implications |
|
||||
--------------------- |
|
||||
|
|
||||
If you run `make install`, the *fusermount* program is installed |
|
||||
set-user-id to root. This is done to allow normal users to mount |
|
||||
their own filesystem implementations. |
|
||||
|
|
||||
There must however be some limitations, in order to prevent Bad User from |
|
||||
doing nasty things. Currently those limitations are: |
|
||||
|
|
||||
- The user can only mount on a mountpoint, for which it has write |
|
||||
permission |
|
||||
|
|
||||
- The mountpoint is not a sticky directory which isn't owned by the |
|
||||
user (like /tmp usually is) |
|
||||
|
|
||||
- No other user (including root) can access the contents of the |
|
||||
mounted filesystem (though this can be relaxed by allowing the use |
|
||||
of the `allow_other` and `allow_root` mount options in `fuse.conf`) |
|
||||
|
|
||||
|
|
||||
Building your own filesystem |
|
||||
------------------------------ |
|
||||
|
|
||||
FUSE comes with several example file systems in the `examples` |
|
||||
directory. For example, the *fusexmp* example mirrors the contents of |
|
||||
the root directory under the mountpoint. Start from there and adapt |
|
||||
the code! |
|
||||
|
|
||||
The documentation of the API functions and necessary callbacks is |
|
||||
mostly contained in the files `include/fuse.h` (for the high-level |
|
||||
API) and `include/fuse_lowlevel.h` (for the low-level API). An |
|
||||
autogenerated html version of the API is available in the `doc/html` |
|
||||
directory and at http://libfuse.github.io/doxygen. |
|
||||
|
|
||||
|
|
||||
Getting Help |
|
||||
------------ |
|
||||
|
|
||||
If you need help, please ask on the <fuse-devel@lists.sourceforge.net> |
|
||||
mailing list (subscribe at |
|
||||
https://lists.sourceforge.net/lists/listinfo/fuse-devel). |
|
||||
|
|
||||
Please report any bugs on the GitHub issue tracker at |
|
||||
https://github.com/libfuse/main/issues. |
|
||||
|
|
@ -1,11 +0,0 @@ |
|||||
prefix=@prefix@ |
|
||||
exec_prefix=@exec_prefix@ |
|
||||
libdir=@libdir@ |
|
||||
includedir=@includedir@ |
|
||||
|
|
||||
Name: fuse |
|
||||
Description: Filesystem in Userspace |
|
||||
Version: @VERSION@ |
|
||||
Libs: -L${libdir} -lfuse -pthread |
|
||||
Libs.private: @libfuse_libs@ |
|
||||
Cflags: -I${includedir}/fuse -D_FILE_OFFSET_BITS=64 |
|
@ -1,17 +0,0 @@ |
|||||
## Process this file with automake to produce Makefile.in
|
|
||||
|
|
||||
fuseincludedir=$(includedir)/fuse |
|
||||
|
|
||||
fuseinclude_HEADERS = \
|
|
||||
fuse.h \
|
|
||||
fuse_compat.h \
|
|
||||
fuse_common.h \
|
|
||||
fuse_common_compat.h \
|
|
||||
fuse_lowlevel.h \
|
|
||||
fuse_lowlevel_compat.h \
|
|
||||
fuse_opt.h \
|
|
||||
cuse_lowlevel.h |
|
||||
|
|
||||
include_HEADERS = old/fuse.h ulockmgr.h |
|
||||
|
|
||||
noinst_HEADERS = fuse_kernel.h |
|
@ -1,87 +0,0 @@ |
|||||
/* |
|
||||
CUSE: Character device in Userspace |
|
||||
Copyright (C) 2008-2009 SUSE Linux Products GmbH |
|
||||
Copyright (C) 2008-2009 Tejun Heo <tj@kernel.org> |
|
||||
|
|
||||
This program can be distributed under the terms of the GNU LGPLv2. |
|
||||
See the file COPYING.LIB. |
|
||||
|
|
||||
Read example/cusexmp.c for usages. |
|
||||
*/ |
|
||||
|
|
||||
#ifndef _CUSE_LOWLEVEL_H_ |
|
||||
#define _CUSE_LOWLEVEL_H_ |
|
||||
|
|
||||
#ifndef FUSE_USE_VERSION |
|
||||
#define FUSE_USE_VERSION 29 |
|
||||
#endif |
|
||||
|
|
||||
#include "fuse_lowlevel.h" |
|
||||
|
|
||||
#include <fcntl.h> |
|
||||
#include <sys/types.h> |
|
||||
#include <sys/uio.h> |
|
||||
|
|
||||
#ifdef __cplusplus |
|
||||
extern "C" { |
|
||||
#endif |
|
||||
|
|
||||
#define CUSE_UNRESTRICTED_IOCTL (1 << 0) /* use unrestricted ioctl */ |
|
||||
|
|
||||
struct fuse_session; |
|
||||
|
|
||||
struct cuse_info { |
|
||||
unsigned dev_major; |
|
||||
unsigned dev_minor; |
|
||||
unsigned dev_info_argc; |
|
||||
const char **dev_info_argv; |
|
||||
unsigned flags; |
|
||||
}; |
|
||||
|
|
||||
/* |
|
||||
* Most ops behave almost identically to the matching fuse_lowlevel |
|
||||
* ops except that they don't take @ino. |
|
||||
* |
|
||||
* init_done : called after initialization is complete |
|
||||
* read/write : always direct IO, simultaneous operations allowed |
|
||||
* ioctl : might be in unrestricted mode depending on ci->flags |
|
||||
*/ |
|
||||
struct cuse_lowlevel_ops { |
|
||||
void (*init) (void *userdata, struct fuse_conn_info *conn); |
|
||||
void (*init_done) (void *userdata); |
|
||||
void (*destroy) (void *userdata); |
|
||||
void (*open) (fuse_req_t req, struct fuse_file_info *fi); |
|
||||
void (*read) (fuse_req_t req, size_t size, off_t off, |
|
||||
struct fuse_file_info *fi); |
|
||||
void (*write) (fuse_req_t req, const char *buf, size_t size, off_t off, |
|
||||
struct fuse_file_info *fi); |
|
||||
void (*flush) (fuse_req_t req, struct fuse_file_info *fi); |
|
||||
void (*release) (fuse_req_t req, struct fuse_file_info *fi); |
|
||||
void (*fsync) (fuse_req_t req, int datasync, struct fuse_file_info *fi); |
|
||||
void (*ioctl) (fuse_req_t req, int cmd, void *arg, |
|
||||
struct fuse_file_info *fi, unsigned int flags, |
|
||||
const void *in_buf, size_t in_bufsz, size_t out_bufsz); |
|
||||
void (*poll) (fuse_req_t req, struct fuse_file_info *fi, |
|
||||
struct fuse_pollhandle *ph); |
|
||||
}; |
|
||||
|
|
||||
struct fuse_session *cuse_lowlevel_new(struct fuse_args *args, |
|
||||
const struct cuse_info *ci, |
|
||||
const struct cuse_lowlevel_ops *clop, |
|
||||
void *userdata); |
|
||||
|
|
||||
struct fuse_session *cuse_lowlevel_setup(int argc, char *argv[], |
|
||||
const struct cuse_info *ci, |
|
||||
const struct cuse_lowlevel_ops *clop, |
|
||||
int *multithreaded, void *userdata); |
|
||||
|
|
||||
void cuse_lowlevel_teardown(struct fuse_session *se); |
|
||||
|
|
||||
int cuse_lowlevel_main(int argc, char *argv[], const struct cuse_info *ci, |
|
||||
const struct cuse_lowlevel_ops *clop, void *userdata); |
|
||||
|
|
||||
#ifdef __cplusplus |
|
||||
} |
|
||||
#endif |
|
||||
|
|
||||
#endif /* _CUSE_LOWLEVEL_H_ */ |
|
@ -0,0 +1,22 @@ |
|||||
|
#pragma once |
||||
|
|
||||
|
#include <stdint.h> |
||||
|
#include <sys/uio.h> |
||||
|
|
||||
|
#define FUSE_CHAN_SPLICE_READ (1<<0) |
||||
|
#define FUSE_CHAN_SPLICE_WRITE (1<<1) |
||||
|
|
||||
|
typedef struct fuse_chan_t fuse_chan_t; |
||||
|
struct fuse_chan_t |
||||
|
{ |
||||
|
void *buf; |
||||
|
uint64_t bufsize; |
||||
|
int32_t fd; |
||||
|
int32_t splice_pipe[2]; |
||||
|
uint32_t flags; |
||||
|
}; |
||||
|
|
||||
|
fuse_chan_t *fuse_chan_new(int32_t fd, uint32_t flags); |
||||
|
void fuse_chan_destroy(fuse_chan_t *ch); |
||||
|
int64_t fuse_chan_recv(fuse_chan_t *ch, char *buf, uint64_t size); |
||||
|
int64_t fuse_chan_send(fuse_chan_t *ch, const struct iovec iov[], uint64_t count); |
@ -1,196 +0,0 @@ |
|||||
/* |
|
||||
FUSE: Filesystem in Userspace |
|
||||
Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu> |
|
||||
|
|
||||
This program can be distributed under the terms of the GNU LGPLv2. |
|
||||
See the file COPYING.LIB. |
|
||||
*/ |
|
||||
|
|
||||
/* these definitions provide source compatibility to prior versions. |
|
||||
Do not include this file directly! */ |
|
||||
|
|
||||
struct fuse_operations_compat25 { |
|
||||
int (*getattr) (const char *, struct stat *); |
|
||||
int (*readlink) (const char *, char *, size_t); |
|
||||
int (*mknod) (const char *, mode_t, dev_t); |
|
||||
int (*mkdir) (const char *, mode_t); |
|
||||
int (*unlink) (const char *); |
|
||||
int (*rmdir) (const char *); |
|
||||
int (*symlink) (const char *, const char *); |
|
||||
int (*rename) (const char *, const char *); |
|
||||
int (*link) (const char *, const char *); |
|
||||
int (*chmod) (const char *, mode_t); |
|
||||
int (*chown) (const char *, uid_t, gid_t); |
|
||||
int (*truncate) (const char *, off_t); |
|
||||
int (*utime) (const char *, struct utimbuf *); |
|
||||
int (*open) (const char *, struct fuse_file_info *); |
|
||||
int (*read) (const char *, char *, size_t, off_t, |
|
||||
struct fuse_file_info *); |
|
||||
int (*write) (const char *, const char *, size_t, off_t, |
|
||||
struct fuse_file_info *); |
|
||||
int (*statfs) (const char *, struct statvfs *); |
|
||||
int (*flush) (const char *, struct fuse_file_info *); |
|
||||
int (*release) (const char *, struct fuse_file_info *); |
|
||||
int (*fsync) (const char *, int, struct fuse_file_info *); |
|
||||
int (*setxattr) (const char *, const char *, const char *, size_t, int); |
|
||||
int (*getxattr) (const char *, const char *, char *, size_t); |
|
||||
int (*listxattr) (const char *, char *, size_t); |
|
||||
int (*removexattr) (const char *, const char *); |
|
||||
int (*opendir) (const char *, struct fuse_file_info *); |
|
||||
int (*readdir) (const char *, void *, off_t, |
|
||||
struct fuse_file_info *); |
|
||||
int (*releasedir) (const char *, struct fuse_file_info *); |
|
||||
int (*fsyncdir) (const char *, int, struct fuse_file_info *); |
|
||||
void *(*init) (void); |
|
||||
void (*destroy) (void *); |
|
||||
int (*access) (const char *, int); |
|
||||
int (*create) (const char *, mode_t, struct fuse_file_info *); |
|
||||
int (*ftruncate) (const char *, off_t, struct fuse_file_info *); |
|
||||
int (*fgetattr) (const char *, struct stat *, struct fuse_file_info *); |
|
||||
}; |
|
||||
|
|
||||
struct fuse *fuse_new_compat25(int fd, struct fuse_args *args, |
|
||||
const struct fuse_operations_compat25 *op, |
|
||||
size_t op_size); |
|
||||
|
|
||||
int fuse_main_real_compat25(int argc, char *argv[], |
|
||||
const struct fuse_operations_compat25 *op, |
|
||||
size_t op_size); |
|
||||
|
|
||||
struct fuse *fuse_setup_compat25(int argc, char *argv[], |
|
||||
const struct fuse_operations_compat25 *op, |
|
||||
size_t op_size, char **mountpoint, |
|
||||
int *multithreaded, int *fd); |
|
||||
|
|
||||
void fuse_teardown_compat22(struct fuse *fuse, int fd, char *mountpoint); |
|
||||
|
|
||||
#if !defined(__FreeBSD__) && !defined(__NetBSD__) |
|
||||
#include <sys/statfs.h> |
|
||||
|
|
||||
struct fuse_operations_compat22 { |
|
||||
int (*getattr) (const char *, struct stat *); |
|
||||
int (*readlink) (const char *, char *, size_t); |
|
||||
int (*mknod) (const char *, mode_t, dev_t); |
|
||||
int (*mkdir) (const char *, mode_t); |
|
||||
int (*unlink) (const char *); |
|
||||
int (*rmdir) (const char *); |
|
||||
int (*symlink) (const char *, const char *); |
|
||||
int (*rename) (const char *, const char *); |
|
||||
int (*link) (const char *, const char *); |
|
||||
int (*chmod) (const char *, mode_t); |
|
||||
int (*chown) (const char *, uid_t, gid_t); |
|
||||
int (*truncate) (const char *, off_t); |
|
||||
int (*utime) (const char *, struct utimbuf *); |
|
||||
int (*open) (const char *, struct fuse_file_info_compat *); |
|
||||
int (*read) (const char *, char *, size_t, off_t, |
|
||||
struct fuse_file_info_compat *); |
|
||||
int (*write) (const char *, const char *, size_t, off_t, |
|
||||
struct fuse_file_info_compat *); |
|
||||
int (*statfs) (const char *, struct statfs *); |
|
||||
int (*flush) (const char *, struct fuse_file_info_compat *); |
|
||||
int (*release) (const char *, struct fuse_file_info_compat *); |
|
||||
int (*fsync) (const char *, int, struct fuse_file_info_compat *); |
|
||||
int (*setxattr) (const char *, const char *, const char *, size_t, int); |
|
||||
int (*getxattr) (const char *, const char *, char *, size_t); |
|
||||
int (*listxattr) (const char *, char *, size_t); |
|
||||
int (*removexattr) (const char *, const char *); |
|
||||
int (*opendir) (const char *, struct fuse_file_info_compat *); |
|
||||
int (*readdir) (const char *, void *, off_t, |
|
||||
struct fuse_file_info_compat *); |
|
||||
int (*releasedir) (const char *, struct fuse_file_info_compat *); |
|
||||
int (*fsyncdir) (const char *, int, struct fuse_file_info_compat *); |
|
||||
void *(*init) (void); |
|
||||
void (*destroy) (void *); |
|
||||
}; |
|
||||
|
|
||||
struct fuse *fuse_new_compat22(int fd, const char *opts, |
|
||||
const struct fuse_operations_compat22 *op, |
|
||||
size_t op_size); |
|
||||
|
|
||||
struct fuse *fuse_setup_compat22(int argc, char *argv[], |
|
||||
const struct fuse_operations_compat22 *op, |
|
||||
size_t op_size, char **mountpoint, |
|
||||
int *multithreaded, int *fd); |
|
||||
|
|
||||
int fuse_main_real_compat22(int argc, char *argv[], |
|
||||
const struct fuse_operations_compat22 *op, |
|
||||
size_t op_size); |
|
||||
|
|
||||
struct fuse_operations_compat2 { |
|
||||
int (*getattr) (const char *, struct stat *); |
|
||||
int (*readlink) (const char *, char *, size_t); |
|
||||
int (*mknod) (const char *, mode_t, dev_t); |
|
||||
int (*mkdir) (const char *, mode_t); |
|
||||
int (*unlink) (const char *); |
|
||||
int (*rmdir) (const char *); |
|
||||
int (*symlink) (const char *, const char *); |
|
||||
int (*rename) (const char *, const char *); |
|
||||
int (*link) (const char *, const char *); |
|
||||
int (*chmod) (const char *, mode_t); |
|
||||
int (*chown) (const char *, uid_t, gid_t); |
|
||||
int (*truncate) (const char *, off_t); |
|
||||
int (*utime) (const char *, struct utimbuf *); |
|
||||
int (*open) (const char *, int); |
|
||||
int (*read) (const char *, char *, size_t, off_t); |
|
||||
int (*write) (const char *, const char *, size_t, off_t); |
|
||||
int (*statfs) (const char *, struct statfs *); |
|
||||
int (*flush) (const char *); |
|
||||
int (*release) (const char *, int); |
|
||||
int (*fsync) (const char *, int); |
|
||||
int (*setxattr) (const char *, const char *, const char *, |
|
||||
size_t, int); |
|
||||
int (*getxattr) (const char *, const char *, char *, size_t); |
|
||||
int (*listxattr) (const char *, char *, size_t); |
|
||||
int (*removexattr) (const char *, const char *); |
|
||||
}; |
|
||||
|
|
||||
int fuse_main_compat2(int argc, char *argv[], |
|
||||
const struct fuse_operations_compat2 *op); |
|
||||
|
|
||||
struct fuse *fuse_new_compat2(int fd, const char *opts, |
|
||||
const struct fuse_operations_compat2 *op); |
|
||||
|
|
||||
struct fuse *fuse_setup_compat2(int argc, char *argv[], |
|
||||
const struct fuse_operations_compat2 *op, |
|
||||
char **mountpoint, int *multithreaded, int *fd); |
|
||||
|
|
||||
struct fuse_statfs_compat1 { |
|
||||
long block_size; |
|
||||
long blocks; |
|
||||
long blocks_free; |
|
||||
long files; |
|
||||
long files_free; |
|
||||
long namelen; |
|
||||
}; |
|
||||
|
|
||||
struct fuse_operations_compat1 { |
|
||||
int (*getattr) (const char *, struct stat *); |
|
||||
int (*readlink) (const char *, char *, size_t); |
|
||||
int (*mknod) (const char *, mode_t, dev_t); |
|
||||
int (*mkdir) (const char *, mode_t); |
|
||||
int (*unlink) (const char *); |
|
||||
int (*rmdir) (const char *); |
|
||||
int (*symlink) (const char *, const char *); |
|
||||
int (*rename) (const char *, const char *); |
|
||||
int (*link) (const char *, const char *); |
|
||||
int (*chmod) (const char *, mode_t); |
|
||||
int (*chown) (const char *, uid_t, gid_t); |
|
||||
int (*truncate) (const char *, off_t); |
|
||||
int (*utime) (const char *, struct utimbuf *); |
|
||||
int (*open) (const char *, int); |
|
||||
int (*read) (const char *, char *, size_t, off_t); |
|
||||
int (*write) (const char *, const char *, size_t, off_t); |
|
||||
int (*statfs) (struct fuse_statfs_compat1 *); |
|
||||
int (*release) (const char *, int); |
|
||||
int (*fsync) (const char *, int); |
|
||||
}; |
|
||||
|
|
||||
#define FUSE_DEBUG_COMPAT1 (1 << 1) |
|
||||
|
|
||||
struct fuse *fuse_new_compat1(int fd, int flags, |
|
||||
const struct fuse_operations_compat1 *op); |
|
||||
|
|
||||
void fuse_main_compat1(int argc, char *argv[], |
|
||||
const struct fuse_operations_compat1 *op); |
|
||||
|
|
||||
#endif /* __FreeBSD__ || __NetBSD__ */ |
|
@ -1,42 +0,0 @@ |
|||||
## Process this file with automake to produce Makefile.in
|
|
||||
|
|
||||
AUTOMAKE_OPTIONS = subdir-objects |
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/include -DFUSERMOUNT_DIR=\"$(bindir)\" \
|
|
||||
-D_FILE_OFFSET_BITS=64 -D_REENTRANT -DFUSE_USE_VERSION=26 |
|
||||
|
|
||||
lib_LTLIBRARIES = libfuse.la libulockmgr.la |
|
||||
|
|
||||
if BSD |
|
||||
mount_source = mount_bsd.c |
|
||||
else |
|
||||
mount_source = mount.c mount_util.c mount_util.h |
|
||||
endif |
|
||||
|
|
||||
libfuse_la_SOURCES = \
|
|
||||
fuse.c \
|
|
||||
fuse_i.h \
|
|
||||
fuse_kern_chan.c \
|
|
||||
fuse_loop.c \
|
|
||||
fuse_loop_mt.c \
|
|
||||
fuse_lowlevel.c \
|
|
||||
fuse_misc.h \
|
|
||||
fuse_mt.c \
|
|
||||
fuse_opt.c \
|
|
||||
fuse_session.c \
|
|
||||
fuse_signals.c \
|
|
||||
buffer.c \
|
|
||||
cuse_lowlevel.c \
|
|
||||
helper.c \
|
|
||||
$(mount_source) |
|
||||
|
|
||||
libfuse_la_LDFLAGS = -pthread @libfuse_libs@ -version-number 2:9:7 \
|
|
||||
-Wl,--version-script,$(srcdir)/fuse_versionscript |
|
||||
|
|
||||
if NETBSD |
|
||||
libfuse_la_LIBADD = -lperfuse -lpuffs |
|
||||
endif |
|
||||
|
|
||||
libulockmgr_la_SOURCES = ulockmgr.c |
|
||||
libulockmgr_la_LDFLAGS = -pthread -version-number 1:0:1 |
|
||||
|
|
||||
EXTRA_DIST = fuse_versionscript |
|
@ -1,371 +0,0 @@ |
|||||
/* |
|
||||
CUSE: Character device in Userspace |
|
||||
Copyright (C) 2008 SUSE Linux Products GmbH |
|
||||
Copyright (C) 2008 Tejun Heo <teheo@suse.de> |
|
||||
|
|
||||
This program can be distributed under the terms of the GNU LGPLv2. |
|
||||
See the file COPYING.LIB. |
|
||||
*/ |
|
||||
|
|
||||
#include "cuse_lowlevel.h" |
|
||||
#include "fuse_kernel.h" |
|
||||
#include "fuse_i.h" |
|
||||
#include "fuse_opt.h" |
|
||||
#include "fuse_misc.h" |
|
||||
|
|
||||
#include <stdio.h> |
|
||||
#include <string.h> |
|
||||
#include <stdlib.h> |
|
||||
#include <stddef.h> |
|
||||
#include <errno.h> |
|
||||
#include <unistd.h> |
|
||||
|
|
||||
struct cuse_data { |
|
||||
struct cuse_lowlevel_ops clop; |
|
||||
unsigned max_read; |
|
||||
unsigned dev_major; |
|
||||
unsigned dev_minor; |
|
||||
unsigned flags; |
|
||||
unsigned dev_info_len; |
|
||||
char dev_info[]; |
|
||||
}; |
|
||||
|
|
||||
static struct cuse_lowlevel_ops *req_clop(fuse_req_t req) |
|
||||
{ |
|
||||
return &req->f->cuse_data->clop; |
|
||||
} |
|
||||
|
|
||||
static void cuse_fll_open(fuse_req_t req, fuse_ino_t ino, |
|
||||
struct fuse_file_info *fi) |
|
||||
{ |
|
||||
(void)ino; |
|
||||
req_clop(req)->open(req, fi); |
|
||||
} |
|
||||
|
|
||||
static void cuse_fll_read(fuse_req_t req, fuse_ino_t ino, size_t size, |
|
||||
off_t off, struct fuse_file_info *fi) |
|
||||
{ |
|
||||
(void)ino; |
|
||||
req_clop(req)->read(req, size, off, fi); |
|
||||
} |
|
||||
|
|
||||
static void cuse_fll_write(fuse_req_t req, fuse_ino_t ino, const char *buf, |
|
||||
size_t size, off_t off, struct fuse_file_info *fi) |
|
||||
{ |
|
||||
(void)ino; |
|
||||
req_clop(req)->write(req, buf, size, off, fi); |
|
||||
} |
|
||||
|
|
||||
static void cuse_fll_flush(fuse_req_t req, fuse_ino_t ino, |
|
||||
struct fuse_file_info *fi) |
|
||||
{ |
|
||||
(void)ino; |
|
||||
req_clop(req)->flush(req, fi); |
|
||||
} |
|
||||
|
|
||||
static void cuse_fll_release(fuse_req_t req, fuse_ino_t ino, |
|
||||
struct fuse_file_info *fi) |
|
||||
{ |
|
||||
(void)ino; |
|
||||
req_clop(req)->release(req, fi); |
|
||||
} |
|
||||
|
|
||||
static void cuse_fll_fsync(fuse_req_t req, fuse_ino_t ino, int datasync, |
|
||||
struct fuse_file_info *fi) |
|
||||
{ |
|
||||
(void)ino; |
|
||||
req_clop(req)->fsync(req, datasync, fi); |
|
||||
} |
|
||||
|
|
||||
static void cuse_fll_ioctl(fuse_req_t req, fuse_ino_t ino, int cmd, void *arg, |
|
||||
struct fuse_file_info *fi, unsigned int flags, |
|
||||
const void *in_buf, size_t in_bufsz, size_t out_bufsz) |
|
||||
{ |
|
||||
(void)ino; |
|
||||
req_clop(req)->ioctl(req, cmd, arg, fi, flags, in_buf, in_bufsz, |
|
||||
out_bufsz); |
|
||||
} |
|
||||
|
|
||||
static void cuse_fll_poll(fuse_req_t req, fuse_ino_t ino, |
|
||||
struct fuse_file_info *fi, struct fuse_pollhandle *ph) |
|
||||
{ |
|
||||
(void)ino; |
|
||||
req_clop(req)->poll(req, fi, ph); |
|
||||
} |
|
||||
|
|
||||
static size_t cuse_pack_info(int argc, const char **argv, char *buf) |
|
||||
{ |
|
||||
size_t size = 0; |
|
||||
int i; |
|
||||
|
|
||||
for (i = 0; i < argc; i++) { |
|
||||
size_t len; |
|
||||
|
|
||||
len = strlen(argv[i]) + 1; |
|
||||
size += len; |
|
||||
if (buf) { |
|
||||
memcpy(buf, argv[i], len); |
|
||||
buf += len; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
return size; |
|
||||
} |
|
||||
|
|
||||
static struct cuse_data *cuse_prep_data(const struct cuse_info *ci, |
|
||||
const struct cuse_lowlevel_ops *clop) |
|
||||
{ |
|
||||
struct cuse_data *cd; |
|
||||
size_t dev_info_len; |
|
||||
|
|
||||
dev_info_len = cuse_pack_info(ci->dev_info_argc, ci->dev_info_argv, |
|
||||
NULL); |
|
||||
|
|
||||
if (dev_info_len > CUSE_INIT_INFO_MAX) { |
|
||||
fprintf(stderr, "cuse: dev_info (%zu) too large, limit=%u\n", |
|
||||
dev_info_len, CUSE_INIT_INFO_MAX); |
|
||||
return NULL; |
|
||||
} |
|
||||
|
|
||||
cd = calloc(1, sizeof(*cd) + dev_info_len); |
|
||||
if (!cd) { |
|
||||
fprintf(stderr, "cuse: failed to allocate cuse_data\n"); |
|
||||
return NULL; |
|
||||
} |
|
||||
|
|
||||
memcpy(&cd->clop, clop, sizeof(cd->clop)); |
|
||||
cd->max_read = 131072; |
|
||||
cd->dev_major = ci->dev_major; |
|
||||
cd->dev_minor = ci->dev_minor; |
|
||||
cd->dev_info_len = dev_info_len; |
|
||||
cd->flags = ci->flags; |
|
||||
cuse_pack_info(ci->dev_info_argc, ci->dev_info_argv, cd->dev_info); |
|
||||
|
|
||||
return cd; |
|
||||
} |
|
||||
|
|
||||
struct fuse_session *cuse_lowlevel_new(struct fuse_args *args, |
|
||||
const struct cuse_info *ci, |
|
||||
const struct cuse_lowlevel_ops *clop, |
|
||||
void *userdata) |
|
||||
{ |
|
||||
struct fuse_lowlevel_ops lop; |
|
||||
struct cuse_data *cd; |
|
||||
struct fuse_session *se; |
|
||||
struct fuse_ll *ll; |
|
||||
|
|
||||
cd = cuse_prep_data(ci, clop); |
|
||||
if (!cd) |
|
||||
return NULL; |
|
||||
|
|
||||
memset(&lop, 0, sizeof(lop)); |
|
||||
lop.init = clop->init; |
|
||||
lop.destroy = clop->destroy; |
|
||||
lop.open = clop->open ? cuse_fll_open : NULL; |
|
||||
lop.read = clop->read ? cuse_fll_read : NULL; |
|
||||
lop.write = clop->write ? cuse_fll_write : NULL; |
|
||||
lop.flush = clop->flush ? cuse_fll_flush : NULL; |
|
||||
lop.release = clop->release ? cuse_fll_release : NULL; |
|
||||
lop.fsync = clop->fsync ? cuse_fll_fsync : NULL; |
|
||||
lop.ioctl = clop->ioctl ? cuse_fll_ioctl : NULL; |
|
||||
lop.poll = clop->poll ? cuse_fll_poll : NULL; |
|
||||
|
|
||||
se = fuse_lowlevel_new_common(args, &lop, sizeof(lop), userdata); |
|
||||
if (!se) { |
|
||||
free(cd); |
|
||||
return NULL; |
|
||||
} |
|
||||
ll = se->data; |
|
||||
ll->cuse_data = cd; |
|
||||
|
|
||||
return se; |
|
||||
} |
|
||||
|
|
||||
static int cuse_reply_init(fuse_req_t req, struct cuse_init_out *arg, |
|
||||
char *dev_info, unsigned dev_info_len) |
|
||||
{ |
|
||||
struct iovec iov[3]; |
|
||||
|
|
||||
iov[1].iov_base = arg; |
|
||||
iov[1].iov_len = sizeof(struct cuse_init_out); |
|
||||
iov[2].iov_base = dev_info; |
|
||||
iov[2].iov_len = dev_info_len; |
|
||||
|
|
||||
return fuse_send_reply_iov_nofree(req, 0, iov, 3); |
|
||||
} |
|
||||
|
|
||||
void cuse_lowlevel_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) |
|
||||
{ |
|
||||
struct fuse_init_in *arg = (struct fuse_init_in *) inarg; |
|
||||
struct cuse_init_out outarg; |
|
||||
struct fuse_ll *f = req->f; |
|
||||
struct cuse_data *cd = f->cuse_data; |
|
||||
size_t bufsize = fuse_chan_bufsize(req->ch); |
|
||||
struct cuse_lowlevel_ops *clop = req_clop(req); |
|
||||
|
|
||||
(void) nodeid; |
|
||||
if (f->debug) { |
|
||||
fprintf(stderr, "CUSE_INIT: %u.%u\n", arg->major, arg->minor); |
|
||||
fprintf(stderr, "flags=0x%08x\n", arg->flags); |
|
||||
} |
|
||||
f->conn.proto_major = arg->major; |
|
||||
f->conn.proto_minor = arg->minor; |
|
||||
f->conn.capable = 0; |
|
||||
f->conn.want = 0; |
|
||||
|
|
||||
if (arg->major < 7) { |
|
||||
fprintf(stderr, "cuse: unsupported protocol version: %u.%u\n", |
|
||||
arg->major, arg->minor); |
|
||||
fuse_reply_err(req, EPROTO); |
|
||||
return; |
|
||||
} |
|
||||
|
|
||||
if (bufsize < FUSE_MIN_READ_BUFFER) { |
|
||||
fprintf(stderr, "cuse: warning: buffer size too small: %zu\n", |
|
||||
bufsize); |
|
||||
bufsize = FUSE_MIN_READ_BUFFER; |
|
||||
} |
|
||||
|
|
||||
bufsize -= 4096; |
|
||||
if (bufsize < f->conn.max_write) |
|
||||
f->conn.max_write = bufsize; |
|
||||
|
|
||||
f->got_init = 1; |
|
||||
if (f->op.init) |
|
||||
f->op.init(f->userdata, &f->conn); |
|
||||
|
|
||||
memset(&outarg, 0, sizeof(outarg)); |
|
||||
outarg.major = FUSE_KERNEL_VERSION; |
|
||||
outarg.minor = FUSE_KERNEL_MINOR_VERSION; |
|
||||
outarg.flags = cd->flags; |
|
||||
outarg.max_read = cd->max_read; |
|
||||
outarg.max_write = f->conn.max_write; |
|
||||
outarg.dev_major = cd->dev_major; |
|
||||
outarg.dev_minor = cd->dev_minor; |
|
||||
|
|
||||
if (f->debug) { |
|
||||
fprintf(stderr, " CUSE_INIT: %u.%u\n", |
|
||||
outarg.major, outarg.minor); |
|
||||
fprintf(stderr, " flags=0x%08x\n", outarg.flags); |
|
||||
fprintf(stderr, " max_read=0x%08x\n", outarg.max_read); |
|
||||
fprintf(stderr, " max_write=0x%08x\n", outarg.max_write); |
|
||||
fprintf(stderr, " dev_major=%u\n", outarg.dev_major); |
|
||||
fprintf(stderr, " dev_minor=%u\n", outarg.dev_minor); |
|
||||
fprintf(stderr, " dev_info: %.*s\n", cd->dev_info_len, |
|
||||
cd->dev_info); |
|
||||
} |
|
||||
|
|
||||
cuse_reply_init(req, &outarg, cd->dev_info, cd->dev_info_len); |
|
||||
|
|
||||
if (clop->init_done) |
|
||||
clop->init_done(f->userdata); |
|
||||
|
|
||||
fuse_free_req(req); |
|
||||
} |
|
||||
|
|
||||
struct fuse_session *cuse_lowlevel_setup(int argc, char *argv[], |
|
||||
const struct cuse_info *ci, |
|
||||
const struct cuse_lowlevel_ops *clop, |
|
||||
int *multithreaded, void *userdata) |
|
||||
{ |
|
||||
const char *devname = "/dev/cuse"; |
|
||||
static const struct fuse_opt kill_subtype_opts[] = { |
|
||||
FUSE_OPT_KEY("subtype=", FUSE_OPT_KEY_DISCARD), |
|
||||
FUSE_OPT_END |
|
||||
}; |
|
||||
struct fuse_args args = FUSE_ARGS_INIT(argc, argv); |
|
||||
struct fuse_session *se; |
|
||||
struct fuse_chan *ch; |
|
||||
int fd; |
|
||||
int foreground; |
|
||||
int res; |
|
||||
|
|
||||
res = fuse_parse_cmdline(&args, NULL, multithreaded, &foreground); |
|
||||
if (res == -1) |
|
||||
goto err_args; |
|
||||
|
|
||||
res = fuse_opt_parse(&args, NULL, kill_subtype_opts, NULL); |
|
||||
if (res == -1) |
|
||||
goto err_args; |
|
||||
|
|
||||
/* |
|
||||
* Make sure file descriptors 0, 1 and 2 are open, otherwise chaos |
|
||||
* would ensue. |
|
||||
*/ |
|
||||
do { |
|
||||
fd = open("/dev/null", O_RDWR); |
|
||||
if (fd > 2) |
|
||||
close(fd); |
|
||||
} while (fd >= 0 && fd <= 2); |
|
||||
|
|
||||
se = cuse_lowlevel_new(&args, ci, clop, userdata); |
|
||||
fuse_opt_free_args(&args); |
|
||||
if (se == NULL) |
|
||||
goto err_args; |
|
||||
|
|
||||
fd = open(devname, O_RDWR); |
|
||||
if (fd == -1) { |
|
||||
if (errno == ENODEV || errno == ENOENT) |
|
||||
fprintf(stderr, "cuse: device not found, try 'modprobe cuse' first\n"); |
|
||||
else |
|
||||
fprintf(stderr, "cuse: failed to open %s: %s\n", |
|
||||
devname, strerror(errno)); |
|
||||
goto err_se; |
|
||||
} |
|
||||
|
|
||||
ch = fuse_kern_chan_new(fd); |
|
||||
if (!ch) { |
|
||||
close(fd); |
|
||||
goto err_se; |
|
||||
} |
|
||||
|
|
||||
fuse_session_add_chan(se, ch); |
|
||||
|
|
||||
res = fuse_set_signal_handlers(se); |
|
||||
if (res == -1) |
|
||||
goto err_se; |
|
||||
|
|
||||
res = fuse_daemonize(foreground); |
|
||||
if (res == -1) |
|
||||
goto err_sig; |
|
||||
|
|
||||
return se; |
|
||||
|
|
||||
err_sig: |
|
||||
fuse_remove_signal_handlers(se); |
|
||||
err_se: |
|
||||
fuse_session_destroy(se); |
|
||||
err_args: |
|
||||
fuse_opt_free_args(&args); |
|
||||
return NULL; |
|
||||
} |
|
||||
|
|
||||
void cuse_lowlevel_teardown(struct fuse_session *se) |
|
||||
{ |
|
||||
fuse_remove_signal_handlers(se); |
|
||||
fuse_session_destroy(se); |
|
||||
} |
|
||||
|
|
||||
int cuse_lowlevel_main(int argc, char *argv[], const struct cuse_info *ci, |
|
||||
const struct cuse_lowlevel_ops *clop, void *userdata) |
|
||||
{ |
|
||||
struct fuse_session *se; |
|
||||
int multithreaded; |
|
||||
int res; |
|
||||
|
|
||||
se = cuse_lowlevel_setup(argc, argv, ci, clop, &multithreaded, |
|
||||
userdata); |
|
||||
if (se == NULL) |
|
||||
return 1; |
|
||||
|
|
||||
if (multithreaded) |
|
||||
res = fuse_session_loop_mt(se, 0); |
|
||||
else |
|
||||
res = fuse_session_loop(se); |
|
||||
|
|
||||
cuse_lowlevel_teardown(se); |
|
||||
if (res == -1) |
|
||||
return 1; |
|
||||
|
|
||||
return 0; |
|
||||
} |
|
@ -0,0 +1,248 @@ |
|||||
|
#define _GNU_SOURCE |
||||
|
|
||||
|
#include "fuse_chan.h" |
||||
|
#include "fuse_lowlevel.h" |
||||
|
#include "fuse_kernel.h" |
||||
|
#include "sys.h" |
||||
|
|
||||
|
#include <assert.h> |
||||
|
#include <errno.h> |
||||
|
#include <fcntl.h> |
||||
|
#include <stdio.h> |
||||
|
#include <stdlib.h> |
||||
|
#include <string.h> |
||||
|
#include <sys/ioctl.h> |
||||
|
#include <unistd.h> |
||||
|
|
||||
|
static const char DEV_FUSE[] = "/dev/fuse"; |
||||
|
|
||||
|
static |
||||
|
void* |
||||
|
aligned_mem(const uint64_t size_) |
||||
|
{ |
||||
|
int rv; |
||||
|
void *mem; |
||||
|
int pagesize; |
||||
|
|
||||
|
pagesize = sys_get_pagesize(); |
||||
|
|
||||
|
rv = posix_memalign(&mem,pagesize,size_); |
||||
|
if(rv == 0) |
||||
|
return mem; |
||||
|
|
||||
|
errno = rv; |
||||
|
return NULL; |
||||
|
} |
||||
|
|
||||
|
static |
||||
|
int |
||||
|
clone_devfuse_fd(const int devfuse_fd_) |
||||
|
{ |
||||
|
#ifdef FUSE_DEV_IOC_CLONE |
||||
|
int rv; |
||||
|
int clone_fd; |
||||
|
|
||||
|
clone_fd = open(DEV_FUSE,O_RDWR|O_CLOEXEC); |
||||
|
if(clone_fd == -1) |
||||
|
return devfuse_fd_; |
||||
|
|
||||
|
rv = ioctl(clone_fd,FUSE_DEV_IOC_CLONE,&devfuse_fd_); |
||||
|
if(rv == -1) |
||||
|
{ |
||||
|
perror("fuse: failed to clone /dev/fuse"); |
||||
|
close(clone_fd); |
||||
|
return devfuse_fd_; |
||||
|
} |
||||
|
|
||||
|
return clone_fd; |
||||
|
#else |
||||
|
return devfuse_fd_; |
||||
|
#endif |
||||
|
} |
||||
|
|
||||
|
int |
||||
|
fuse_msg_bufsize(void) |
||||
|
{ |
||||
|
int bufsize; |
||||
|
|
||||
|
bufsize = ((FUSE_MSG_MAX_PAGES + 1) * sys_get_pagesize()); |
||||
|
|
||||
|
return bufsize; |
||||
|
} |
||||
|
|
||||
|
fuse_chan_t* |
||||
|
fuse_chan_new(int32_t devfuse_fd_, |
||||
|
uint32_t flags_) |
||||
|
{ |
||||
|
int rv; |
||||
|
int bufsize; |
||||
|
fuse_chan_t *ch; |
||||
|
|
||||
|
ch = (fuse_chan_t*)calloc(1,sizeof(fuse_chan_t)); |
||||
|
if(ch == NULL) |
||||
|
{ |
||||
|
fprintf(stderr, "fuse: failed to allocate channel memory\n"); |
||||
|
return NULL; |
||||
|
} |
||||
|
|
||||
|
bufsize = fuse_msg_bufsize(); |
||||
|
ch->fd = clone_devfuse_fd(devfuse_fd_); |
||||
|
ch->buf = aligned_mem(bufsize); |
||||
|
ch->bufsize = bufsize; |
||||
|
ch->flags = flags_; |
||||
|
if(flags_ & (FUSE_CHAN_SPLICE_READ|FUSE_CHAN_SPLICE_WRITE)) |
||||
|
{ |
||||
|
rv = sys_alloc_pipe(ch->splice_pipe,bufsize); |
||||
|
if(rv == -1) |
||||
|
ch->flags &= ~(FUSE_CHAN_SPLICE_READ|FUSE_CHAN_SPLICE_WRITE); |
||||
|
} |
||||
|
|
||||
|
return ch; |
||||
|
} |
||||
|
|
||||
|
static |
||||
|
int64_t |
||||
|
fuse_chan_recv_splice(fuse_chan_t *ch_, |
||||
|
char *buf_, |
||||
|
uint64_t size_) |
||||
|
{ |
||||
|
int64_t rv; |
||||
|
struct iovec iov; |
||||
|
|
||||
|
restart_splice: |
||||
|
rv = splice(ch_->fd,NULL,ch_->splice_pipe[1],NULL,size_,SPLICE_F_MOVE); |
||||
|
switch((rv == -1) ? errno : 0) |
||||
|
{ |
||||
|
case 0: |
||||
|
break; |
||||
|
case ENOENT: |
||||
|
case EINTR: |
||||
|
case EAGAIN: |
||||
|
goto restart_splice; |
||||
|
case ENODEV: |
||||
|
return 0; |
||||
|
default: |
||||
|
return -errno; |
||||
|
} |
||||
|
|
||||
|
iov.iov_base = buf_; |
||||
|
iov.iov_len = rv; |
||||
|
restart_vmsplice: |
||||
|
rv = vmsplice(ch_->splice_pipe[0],&iov,1,SPLICE_F_MOVE); |
||||
|
switch((rv == -1) ? errno : 0) |
||||
|
{ |
||||
|
case 0: |
||||
|
break; |
||||
|
case ENOENT: |
||||
|
case EINTR: |
||||
|
case EAGAIN: |
||||
|
goto restart_vmsplice; |
||||
|
case ENODEV: |
||||
|
return 0; |
||||
|
default: |
||||
|
return -errno; |
||||
|
} |
||||
|
|
||||
|
return rv; |
||||
|
} |
||||
|
|
||||
|
static |
||||
|
int |
||||
|
fuse_chan_recv_read(fuse_chan_t *ch_, |
||||
|
char *buf_, |
||||
|
uint64_t size_) |
||||
|
{ |
||||
|
int64_t rv; |
||||
|
|
||||
|
restart: |
||||
|
rv = read(ch_->fd,buf_,size_); |
||||
|
switch((rv == -1) ? errno : 0) |
||||
|
{ |
||||
|
case 0: |
||||
|
break; |
||||
|
case ENOENT: |
||||
|
case EINTR: |
||||
|
case EAGAIN: |
||||
|
goto restart; |
||||
|
case ENODEV: |
||||
|
return 0; |
||||
|
default: |
||||
|
return -errno; |
||||
|
} |
||||
|
|
||||
|
if(rv < sizeof(struct fuse_in_header)) |
||||
|
{ |
||||
|
fprintf(stderr, "fuse: short read on fuse device\n"); |
||||
|
return -EIO; |
||||
|
} |
||||
|
|
||||
|
return rv; |
||||
|
} |
||||
|
|
||||
|
int64_t |
||||
|
fuse_chan_recv(fuse_chan_t *ch_, |
||||
|
char *buf_, |
||||
|
size_t size_) |
||||
|
{ |
||||
|
if(ch_->flags & FUSE_CHAN_SPLICE_READ) |
||||
|
return fuse_chan_recv_splice(ch_,buf_,size_); |
||||
|
return fuse_chan_recv_read(ch_,buf_,size_); |
||||
|
} |
||||
|
|
||||
|
static |
||||
|
int64_t |
||||
|
fuse_chan_send_write(fuse_chan_t *ch_, |
||||
|
const struct iovec iov_[], |
||||
|
size_t count_) |
||||
|
{ |
||||
|
int64_t rv; |
||||
|
|
||||
|
if(iov_ == NULL) |
||||
|
return 0; |
||||
|
|
||||
|
rv = writev(ch_->fd,iov_,count_); |
||||
|
if(rv == -1) |
||||
|
return -errno; |
||||
|
|
||||
|
return rv; |
||||
|
} |
||||
|
|
||||
|
static |
||||
|
int64_t |
||||
|
fuse_chan_send_splice(fuse_chan_t *ch_, |
||||
|
const struct iovec iov_[], |
||||
|
size_t count_) |
||||
|
{ |
||||
|
int64_t rv; |
||||
|
|
||||
|
rv = vmsplice(ch_->splice_pipe[1],iov_,count_,SPLICE_F_MOVE); |
||||
|
if(rv == -1) |
||||
|
return -errno; |
||||
|
|
||||
|
rv = splice(ch_->splice_pipe[0],NULL,ch_->fd,NULL,rv,SPLICE_F_MOVE); |
||||
|
|
||||
|
return rv; |
||||
|
} |
||||
|
|
||||
|
int64_t |
||||
|
fuse_chan_send(fuse_chan_t *ch, |
||||
|
const struct iovec iov[], |
||||
|
size_t count) |
||||
|
{ |
||||
|
if(ch->flags & FUSE_CHAN_SPLICE_WRITE) |
||||
|
return fuse_chan_send_splice(ch,iov,count); |
||||
|
return fuse_chan_send_write(ch,iov,count); |
||||
|
} |
||||
|
|
||||
|
void |
||||
|
fuse_chan_destroy(fuse_chan_t *ch) |
||||
|
{ |
||||
|
close(ch->fd); |
||||
|
if(ch->flags & (FUSE_CHAN_SPLICE_READ|FUSE_CHAN_SPLICE_WRITE)) |
||||
|
{ |
||||
|
close(ch->splice_pipe[0]); |
||||
|
close(ch->splice_pipe[1]); |
||||
|
} |
||||
|
free(ch->buf); |
||||
|
free(ch); |
||||
|
} |
@ -0,0 +1,56 @@ |
|||||
|
#include "fuse_dev.h" |
||||
|
|
||||
|
#include <stdlib.h> |
||||
|
#include <sys/uio.h> |
||||
|
#include <unistd.h> |
||||
|
|
||||
|
fuse_dev_t* |
||||
|
fuse_dev_alloc(void) |
||||
|
{ |
||||
|
return calloc(1,sizeof(fuse_dev_t)); |
||||
|
} |
||||
|
|
||||
|
void |
||||
|
fuse_dev_free(fuse_dev_t *fd_) |
||||
|
{ |
||||
|
if(fd_) |
||||
|
free(fd_); |
||||
|
} |
||||
|
|
||||
|
fuse_dev_t* |
||||
|
fuse_dev_clone(fuse_dev_t *fd_) |
||||
|
{ |
||||
|
return fd_; |
||||
|
} |
||||
|
|
||||
|
int64_t |
||||
|
fuse_dev_read(const fuse_dev_t *fd_, |
||||
|
void *buf_, |
||||
|
uint64_t count_) |
||||
|
{ |
||||
|
int64_t rv; |
||||
|
|
||||
|
rv = read(fd_->fd,buf_,count_); |
||||
|
|
||||
|
return rv; |
||||
|
} |
||||
|
|
||||
|
int64_t |
||||
|
fuse_dev_write(const fuse_dev_t *fd_, |
||||
|
const struct iovec *iov_, |
||||
|
int iovcnt_) |
||||
|
{ |
||||
|
int64_t rv; |
||||
|
|
||||
|
rv = writev(fd_->fd,iov_,iovcnt_); |
||||
|
|
||||
|
return rv; |
||||
|
} |
||||
|
|
||||
|
int64_t |
||||
|
fuse_dev_write_splice(const fuse_dev_t* fd_, |
||||
|
const struct iovec *iov_, |
||||
|
int iovcnt_) |
||||
|
{ |
||||
|
|
||||
|
} |
@ -0,0 +1,40 @@ |
|||||
|
/* |
||||
|
ISC License |
||||
|
|
||||
|
Copyright (c) 2020, Antonio SJ Musumeci <trapexit@spawn.link> |
||||
|
|
||||
|
Permission to use, copy, modify, and/or distribute this software for any |
||||
|
purpose with or without fee is hereby granted, provided that the above |
||||
|
copyright notice and this permission notice appear in all copies. |
||||
|
|
||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
||||
|
*/ |
||||
|
|
||||
|
#pragma once |
||||
|
|
||||
|
#include <stdint.h> |
||||
|
#include <sys/uio.h> |
||||
|
|
||||
|
typedef struct fuse_dev_s fuse_dev_t; |
||||
|
struct fuse_dev_s |
||||
|
{ |
||||
|
int fd; |
||||
|
}; |
||||
|
|
||||
|
fuse_dev_t* fuse_dev_alloc(void); |
||||
|
void fuse_dev_free(fuse_dev_t *fd); |
||||
|
fuse_dev_t* fuse_dev_clone(fuse_dev_t *fd); |
||||
|
|
||||
|
int64_t fuse_dev_read(const fuse_dev_t *fd, |
||||
|
void *buf, |
||||
|
uint64_t count); |
||||
|
|
||||
|
int64_t fuse_dev_write(const fuse_dev_t *fd, |
||||
|
const struct iovec *iov, |
||||
|
int iovcnt); |
@ -1,103 +0,0 @@ |
|||||
/* |
|
||||
FUSE: Filesystem in Userspace |
|
||||
Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu> |
|
||||
|
|
||||
This program can be distributed under the terms of the GNU LGPLv2. |
|
||||
See the file COPYING.LIB |
|
||||
*/ |
|
||||
|
|
||||
#include "fuse_lowlevel.h" |
|
||||
#include "fuse_kernel.h" |
|
||||
#include "fuse_i.h" |
|
||||
|
|
||||
#include <stdio.h> |
|
||||
#include <errno.h> |
|
||||
#include <unistd.h> |
|
||||
#include <assert.h> |
|
||||
|
|
||||
static int fuse_kern_chan_receive(struct fuse_chan **chp, char *buf, |
|
||||
size_t size) |
|
||||
{ |
|
||||
struct fuse_chan *ch = *chp; |
|
||||
int err; |
|
||||
ssize_t res; |
|
||||
struct fuse_session *se = fuse_chan_session(ch); |
|
||||
assert(se != NULL); |
|
||||
|
|
||||
restart: |
|
||||
res = read(fuse_chan_fd(ch), buf, size); |
|
||||
err = errno; |
|
||||
|
|
||||
if (fuse_session_exited(se)) |
|
||||
return 0; |
|
||||
if (res == -1) { |
|
||||
/* ENOENT means the operation was interrupted, it's safe |
|
||||
to restart */ |
|
||||
if (err == ENOENT) |
|
||||
goto restart; |
|
||||
|
|
||||
if (err == ENODEV) { |
|
||||
fuse_session_exit(se); |
|
||||
return 0; |
|
||||
} |
|
||||
/* Errors occurring during normal operation: EINTR (read |
|
||||
interrupted), EAGAIN (nonblocking I/O), ENODEV (filesystem |
|
||||
umounted) */ |
|
||||
if (err != EINTR && err != EAGAIN) |
|
||||
perror("fuse: reading device"); |
|
||||
return -err; |
|
||||
} |
|
||||
if ((size_t) res < sizeof(struct fuse_in_header)) { |
|
||||
fprintf(stderr, "short read on fuse device\n"); |
|
||||
return -EIO; |
|
||||
} |
|
||||
return res; |
|
||||
} |
|
||||
|
|
||||
static int fuse_kern_chan_send(struct fuse_chan *ch, const struct iovec iov[], |
|
||||
size_t count) |
|
||||
{ |
|
||||
if (iov) { |
|
||||
ssize_t res = writev(fuse_chan_fd(ch), iov, count); |
|
||||
int err = errno; |
|
||||
|
|
||||
if (res == -1) { |
|
||||
struct fuse_session *se = fuse_chan_session(ch); |
|
||||
|
|
||||
assert(se != NULL); |
|
||||
|
|
||||
/* ENOENT means the operation was interrupted */ |
|
||||
if (!fuse_session_exited(se) && err != ENOENT) |
|
||||
perror("fuse: writing device"); |
|
||||
return -err; |
|
||||
} |
|
||||
} |
|
||||
return 0; |
|
||||
} |
|
||||
|
|
||||
static void fuse_kern_chan_destroy(struct fuse_chan *ch) |
|
||||
{ |
|
||||
int fd = fuse_chan_fd(ch); |
|
||||
|
|
||||
if (fd != -1) |
|
||||
close(fd); |
|
||||
} |
|
||||
|
|
||||
struct fuse_chan * |
|
||||
fuse_kern_chan_new(int fd_) |
|
||||
{ |
|
||||
long pagesize; |
|
||||
size_t bufsize; |
|
||||
struct fuse_chan_ops op = |
|
||||
{ |
|
||||
.receive = fuse_kern_chan_receive, |
|
||||
.send = fuse_kern_chan_send, |
|
||||
.destroy = fuse_kern_chan_destroy, |
|
||||
}; |
|
||||
|
|
||||
pagesize = sysconf(_SC_PAGESIZE); |
|
||||
|
|
||||
bufsize = ((FUSE_MAX_MAX_PAGES * pagesize) + 0x1000); |
|
||||
|
|
||||
return fuse_chan_new(&op, fd_, bufsize, NULL); |
|
||||
} |
|
@ -1,46 +0,0 @@ |
|||||
/* |
|
||||
FUSE: Filesystem in Userspace |
|
||||
Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu> |
|
||||
|
|
||||
This program can be distributed under the terms of the GNU LGPLv2. |
|
||||
See the file COPYING.LIB |
|
||||
*/ |
|
||||
|
|
||||
#include "fuse_lowlevel.h" |
|
||||
|
|
||||
#include <stdio.h> |
|
||||
#include <stdlib.h> |
|
||||
#include <errno.h> |
|
||||
|
|
||||
int fuse_session_loop(struct fuse_session *se) |
|
||||
{ |
|
||||
int res = 0; |
|
||||
struct fuse_chan *ch = fuse_session_next_chan(se, NULL); |
|
||||
size_t bufsize = fuse_chan_bufsize(ch); |
|
||||
char *buf = (char*)calloc(bufsize,1); |
|
||||
if (!buf) { |
|
||||
fprintf(stderr, "fuse: failed to allocate read buffer\n"); |
|
||||
return -1; |
|
||||
} |
|
||||
|
|
||||
while (!fuse_session_exited(se)) { |
|
||||
struct fuse_chan *tmpch = ch; |
|
||||
struct fuse_buf fbuf = { |
|
||||
.mem = buf, |
|
||||
.size = bufsize, |
|
||||
}; |
|
||||
|
|
||||
res = fuse_session_receive_buf(se, &fbuf, &tmpch); |
|
||||
|
|
||||
if (res == -EINTR) |
|
||||
continue; |
|
||||
if (res <= 0) |
|
||||
break; |
|
||||
|
|
||||
fuse_session_process_buf(se, &fbuf, tmpch); |
|
||||
} |
|
||||
|
|
||||
free(buf); |
|
||||
fuse_session_reset(se); |
|
||||
return res < 0 ? -1 : 0; |
|
||||
} |
|
914
libfuse/lib/fuse_lowlevel.c
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1,207 +0,0 @@ |
|||||
FUSE_2.2 { |
|
||||
global: |
|
||||
fuse_destroy; |
|
||||
fuse_exit; |
|
||||
fuse_exited; |
|
||||
fuse_invalidate; |
|
||||
fuse_is_lib_option; |
|
||||
fuse_loop; |
|
||||
fuse_loop_mt; |
|
||||
fuse_loop_mt_proc; |
|
||||
fuse_main; |
|
||||
fuse_main_compat1; |
|
||||
fuse_main_compat2; |
|
||||
fuse_mount_compat1; |
|
||||
fuse_new_compat1; |
|
||||
fuse_new_compat2; |
|
||||
fuse_process_cmd; |
|
||||
fuse_read_cmd; |
|
||||
fuse_set_getcontext_func; |
|
||||
fuse_setup_compat2; |
|
||||
}; |
|
||||
|
|
||||
FUSE_2.4 { |
|
||||
global: |
|
||||
fuse_add_dirent; |
|
||||
fuse_chan_bufsize; |
|
||||
fuse_chan_data; |
|
||||
fuse_chan_destroy; |
|
||||
fuse_chan_fd; |
|
||||
fuse_chan_receive; |
|
||||
fuse_chan_send; |
|
||||
fuse_chan_session; |
|
||||
fuse_dirent_size; |
|
||||
fuse_kern_chan_new; |
|
||||
fuse_lowlevel_is_lib_option; |
|
||||
fuse_reply_attr; |
|
||||
fuse_reply_buf; |
|
||||
fuse_reply_entry; |
|
||||
fuse_reply_err; |
|
||||
fuse_reply_none; |
|
||||
fuse_reply_readlink; |
|
||||
fuse_reply_write; |
|
||||
fuse_reply_xattr; |
|
||||
fuse_req_userdata; |
|
||||
fuse_session_add_chan; |
|
||||
fuse_session_destroy; |
|
||||
fuse_session_exit; |
|
||||
fuse_session_exited; |
|
||||
fuse_session_loop; |
|
||||
fuse_session_loop_mt; |
|
||||
fuse_session_new; |
|
||||
fuse_session_next_chan; |
|
||||
fuse_session_process; |
|
||||
fuse_session_reset; |
|
||||
} FUSE_2.2; |
|
||||
|
|
||||
FUSE_2.5 { |
|
||||
global: |
|
||||
fuse_lowlevel_new_compat; |
|
||||
fuse_main_real_compat22; |
|
||||
fuse_mount_compat22; |
|
||||
fuse_new_compat22; |
|
||||
fuse_opt_parse; |
|
||||
fuse_opt_add_opt; |
|
||||
fuse_opt_add_arg; |
|
||||
fuse_opt_free_args; |
|
||||
fuse_opt_match; |
|
||||
fuse_parse_cmdline; |
|
||||
fuse_remove_signal_handlers; |
|
||||
fuse_reply_create; |
|
||||
fuse_reply_open; |
|
||||
fuse_reply_open_compat; |
|
||||
fuse_reply_statfs; |
|
||||
fuse_reply_statfs_compat; |
|
||||
fuse_setup_compat22; |
|
||||
fuse_set_signal_handlers; |
|
||||
} FUSE_2.4; |
|
||||
|
|
||||
FUSE_2.6 { |
|
||||
global: |
|
||||
fuse_add_direntry; |
|
||||
fuse_chan_new; |
|
||||
fuse_chan_new_compat24; |
|
||||
fuse_chan_recv; |
|
||||
fuse_daemonize; |
|
||||
fuse_get_session; |
|
||||
fuse_interrupted; |
|
||||
fuse_lowlevel_new; |
|
||||
fuse_lowlevel_new_compat25; |
|
||||
fuse_main_real; |
|
||||
fuse_main_real_compat25; |
|
||||
fuse_mount; |
|
||||
fuse_mount_compat25; |
|
||||
fuse_new; |
|
||||
fuse_new_compat25; |
|
||||
fuse_opt_insert_arg; |
|
||||
fuse_reply_lock; |
|
||||
fuse_req_interrupt_func; |
|
||||
fuse_req_interrupted; |
|
||||
fuse_session_remove_chan; |
|
||||
fuse_setup; |
|
||||
fuse_setup_compat25; |
|
||||
fuse_teardown; |
|
||||
fuse_teardown_compat22; |
|
||||
fuse_unmount; |
|
||||
fuse_unmount_compat22; |
|
||||
} FUSE_2.5; |
|
||||
|
|
||||
FUSE_2.7 { |
|
||||
global: |
|
||||
fuse_fs_access; |
|
||||
fuse_fs_bmap; |
|
||||
fuse_fs_chmod; |
|
||||
fuse_fs_chown; |
|
||||
fuse_fs_create; |
|
||||
fuse_fs_destroy; |
|
||||
fuse_fs_fgetattr; |
|
||||
fuse_fs_flush; |
|
||||
fuse_fs_fsync; |
|
||||
fuse_fs_fsyncdir; |
|
||||
fuse_fs_ftruncate; |
|
||||
fuse_fs_getattr; |
|
||||
fuse_fs_getxattr; |
|
||||
fuse_fs_init; |
|
||||
fuse_fs_link; |
|
||||
fuse_fs_listxattr; |
|
||||
fuse_fs_lock; |
|
||||
fuse_fs_mkdir; |
|
||||
fuse_fs_mknod; |
|
||||
fuse_fs_new; |
|
||||
fuse_fs_open; |
|
||||
fuse_fs_opendir; |
|
||||
fuse_fs_read; |
|
||||
fuse_fs_readdir; |
|
||||
fuse_fs_readlink; |
|
||||
fuse_fs_release; |
|
||||
fuse_fs_releasedir; |
|
||||
fuse_fs_removexattr; |
|
||||
fuse_fs_rename; |
|
||||
fuse_fs_rmdir; |
|
||||
fuse_fs_setxattr; |
|
||||
fuse_fs_statfs; |
|
||||
fuse_fs_symlink; |
|
||||
fuse_fs_truncate; |
|
||||
fuse_fs_unlink; |
|
||||
fuse_fs_utimens; |
|
||||
fuse_fs_write; |
|
||||
fuse_register_module; |
|
||||
fuse_reply_iov; |
|
||||
fuse_version; |
|
||||
} FUSE_2.6; |
|
||||
|
|
||||
FUSE_2.7.5 { |
|
||||
global: |
|
||||
fuse_reply_bmap; |
|
||||
} FUSE_2.7; |
|
||||
|
|
||||
FUSE_2.8 { |
|
||||
global: |
|
||||
cuse_lowlevel_new; |
|
||||
cuse_lowlevel_main; |
|
||||
cuse_lowlevel_setup; |
|
||||
cuse_lowlevel_teardown; |
|
||||
fuse_fs_ioctl; |
|
||||
fuse_fs_poll; |
|
||||
fuse_get_context; |
|
||||
fuse_getgroups; |
|
||||
fuse_lowlevel_notify_inval_entry; |
|
||||
fuse_lowlevel_notify_inval_inode; |
|
||||
fuse_lowlevel_notify_poll; |
|
||||
fuse_notify_poll; |
|
||||
fuse_opt_add_opt_escaped; |
|
||||
fuse_pollhandle_destroy; |
|
||||
fuse_reply_ioctl; |
|
||||
fuse_reply_ioctl_iov; |
|
||||
fuse_reply_ioctl_retry; |
|
||||
fuse_reply_poll; |
|
||||
fuse_req_ctx; |
|
||||
fuse_req_getgroups; |
|
||||
fuse_session_data; |
|
||||
} FUSE_2.7.5; |
|
||||
|
|
||||
FUSE_2.9 { |
|
||||
global: |
|
||||
fuse_buf_copy; |
|
||||
fuse_buf_size; |
|
||||
fuse_fs_read_buf; |
|
||||
fuse_fs_write_buf; |
|
||||
fuse_lowlevel_notify_retrieve; |
|
||||
fuse_lowlevel_notify_store; |
|
||||
fuse_reply_data; |
|
||||
fuse_session_process_buf; |
|
||||
fuse_session_receive_buf; |
|
||||
fuse_start_cleanup_thread; |
|
||||
fuse_stop_cleanup_thread; |
|
||||
fuse_clean_cache; |
|
||||
fuse_lowlevel_notify_delete; |
|
||||
fuse_fs_flock; |
|
||||
} FUSE_2.8; |
|
||||
|
|
||||
FUSE_2.9.1 { |
|
||||
global: |
|
||||
fuse_fs_fallocate; |
|
||||
|
|
||||
local: |
|
||||
*; |
|
||||
} FUSE_2.9; |
|
@ -0,0 +1,48 @@ |
|||||
|
#define _GNU_SOURCE |
||||
|
|
||||
|
#include <fcntl.h> |
||||
|
#include <unistd.h> |
||||
|
|
||||
|
static |
||||
|
int |
||||
|
sys_get_pagesize_(void) |
||||
|
{ |
||||
|
#ifdef _SC_PAGESIZE |
||||
|
return sysconf(_SC_PAGESIZE); |
||||
|
#else |
||||
|
return getpagesize(); |
||||
|
#endif |
||||
|
} |
||||
|
|
||||
|
int |
||||
|
sys_get_pagesize(void) |
||||
|
{ |
||||
|
static int pagesize = 0; |
||||
|
|
||||
|
if(pagesize == 0) |
||||
|
pagesize = sys_get_pagesize_(); |
||||
|
|
||||
|
return pagesize; |
||||
|
} |
||||
|
|
||||
|
int |
||||
|
sys_alloc_pipe(int pipe_[2], |
||||
|
int bufsize_) |
||||
|
{ |
||||
|
#ifdef F_SETPIPE_SZ |
||||
|
int rv; |
||||
|
|
||||
|
rv = pipe(pipe_); |
||||
|
if(rv == -1) |
||||
|
return -1; |
||||
|
|
||||
|
rv = fcntl(pipe_[0],F_SETPIPE_SZ,bufsize_); |
||||
|
if(rv == -1) |
||||
|
return -1; |
||||
|
|
||||
|
return rv; |
||||
|
#else |
||||
|
errno = ENOSYS; |
||||
|
return -1; |
||||
|
#endif |
||||
|
} |
@ -0,0 +1,4 @@ |
|||||
|
#pragma once |
||||
|
|
||||
|
int sys_get_pagesize(void); |
||||
|
int sys_alloc_pipe(int p[2], int bufsize); |
Write
Preview
Loading…
Cancel
Save
Reference in new issue