History log of /haiku/src/add-ons/kernel/file_systems/userlandfs/server/fuse/FUSEFileSystem.cpp
Revision Date Author Comments
# 55f3abb4 28-Mar-2023 Trung Nguyen <trungnt282910@gmail.com>

userlandfs: Support mapping FUSE files to memory

- Create a file cache for FUSE mounted files on open to allow
memory mapping these files unless direct_io is specified.
- Implement DoIO for FUSE mounted files.

This patch enables files mounted through FUSE filesystems such as
sshfs or vmhgfs to be `mmap`ed, allowing remotely cross-compiled
executables to be directly run on Haiku.

Change-Id: I364b8225eae5b1d586280c2b3301fb661581caed
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6277
Tested-by: Automation <automation@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>


# 49a00a12 20-Jul-2022 PulkoMandy <pulkomandy@pulkomandy.tk>

userlandfs: implement get_fs_info using ioctl

This avoids introducing an entirely custom hook in FUSE.
It uses the ioctl hook in an unconventional way (calling it with no
valid fuse_file_info) but this can be fixed if a filesystem requires it
(by opening a file handle on /, doing the ioctl, then closing again).

An updated version of fusesmb-haiku is available and confirmed working:
https://github.com/haikuarchives/fusesmb-haiku

Change-Id: If1268113874363fa035e5340be75e9f5198216d6
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5199
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


# f0ee02b2 17-Jul-2022 PulkoMandy <pulkomandy@pulkomandy.tk>

userlandfs_fuse_lowlevel: fix opening directories in Tracker

- It is possible to call open() on a directory, but FUSE lowlevel
filesystems don't implement that and expect it to be re-routed to the
opendir call. BRoster uses this to read the dir/file attributes to
identify it, so it could not identify directories properly.
- In ReadDir, make sure to not return more entries than asked, as this
confuses the userlandfs protocol communication (the kernel does not
acknowledge the readdir reply, and then the server hits an assert when
receiving the next request instead of the ack).

Change-Id: I9c4e9a3f0fc6e9879d4cfbc0d5402a4733d2218a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5482
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 0604d554 06-Jun-2022 PulkoMandy <pulkomandy@pulkomandy.tk>

userlandfs: compatibility with FUSE 2.9 and FUSE lowlevel API

- Import latest version of files from FUSE 2.9.9 (our last
synchronization was with 2.7.4)
- Adjust fuse pkgconfig file to use the POSIX error mapper
automatically, since that's required for all FUSE software
- Implement the lowlevel API in addition to the highlevel one. The
lowlevel API uses inode numbers to identify files, rather than paths,
making it a better fit to the userlandfs architecture.

The FUSE 2.x branch is not maintained anymore by FUSE developers,
however, pretty much no one migrated to FUSE 3.x. So it is more
interesting to implement, rather than 3.x.

Confirmed still working with sshfs and curlftpfs.

Example use:

I tested this with github.com/whoozle/android-file-transfer-linux

- Build the fuse library and copy it to ~/config/non-packaged/add-ons/userlandfs/
- Start the server: /system/servers/userlandfs_server aft-mtp-mount
- Connect your Android phone and put it in USB file transfer mode
- Mount the device: mount -t userlandfs -p 'aft-mtp-mount /boot/home/MyPhone -d -o use_ino' ~/MyPhone
- You can now access your phone data

Change-Id: Ic3efda7ffbc33737e6f4958428fb3ec9939ef105
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5198
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 5adf34b0 11-Feb-2017 Julian Harnath <julian.harnath@rwth-aachen.de>

FUSE compat: add support for attribute reading

* Implement reading extended file attributes in FUSE modules,
using getxattr()

getxattr() is a quite limited API, not allowing to specify a read
offset. So we read in the entire attribute value into a buffer and
store in the cookie. This shouldn't be a problem memory-wise, since
xattr implementions usually have limitations regarding attribute size
anyway, so it'll rarely be more than a few kilobytes.

* Writing, renaming, and removing attributes is not yet implemented


# 861dbb48 08-Apr-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Implemented more of the detailed FUSE initialization functions for file systems
that use them directly instead of fuse_main().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30024 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e66cd9d7 02-Apr-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* For every request to userland we also send the team/thread/user/group ID of
the current thread, now. Implemented by introducing a new base class
KernelRequest which has respective attributes.
* Server: RequestThreadContext does now also save the request that is being
processed. Furthermore some space has been reserved for file system specific
data, which can be initialized by the new
FileSystem::InitRequestThreadContext().
* FUSE library: Implemented fuse_get_context() using the new
RequestThreadContext feature.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29872 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a7731138 02-Apr-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Initialize fuse_config before parsing the arguments.
* Implemented fuse_is_lib_option() more correctly.
* Actually use the value of the "use_ino" option.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29871 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 39f2d9e6 31-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Parse the FUSE library options. They aren't used yet, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29844 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c8722a1e 27-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Removed WriteFSInfo(). It's used only for changing the volume name and we
can't implement that with the FUSE interface.
* We now mark nodes dirty after a write operation.
* Implemented Sync() by fsync()ing all dirty nodes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29746 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 40b0400d 26-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Fixed incorrect loop check in _UnlockNodeChainInternal() nothing would ever
be unlocked.
* Fixed incorrect array indexing in _FindCommonAncestor().
* Fixed copy and paste bugs in _LockNodeChainsInternal().
* Added MultiNodeLocker class, a RAII frontend for _{Lock,Unlock}NodeChains().
* Implemented entry renaming and hard linking.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29741 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d7b73de2 26-Mar-2009 Rene Gollent <anevilyak@gmail.com>

Fix logic error that was coincidentally also triggering a gcc4 warning/error on build.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29739 a95241bf-73f2-0310-859d-f6bbb57e9c96


# edae667b 26-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Removed the asynchronous I/O methods. We won't implement them for the time
being.
* Introduced locking for FileCookie.
* Implemented SetFlags() and FSync().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29736 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b747212f 25-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Implemented WriteStat() (backend for chown(), chmod(), utime(), truncate()).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29722 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cd4ee847 25-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added support for symlink and directory creation, as well as entry deletion
(directories and other nodes).
* Removed methods we can't possibly implement, since the FUSE interface doesn't
provide them and we can't emulate them.
* A FUSEEntry does now also own a reference to its parent directory.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29715 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d16ba4b9 24-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Added support for O_TRUNC, file creation, and writing to files.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29689 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f11f1730 22-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Implemented the attribute directory methods. Untested yet -- sshfs doesn't
support the respective xattr hooks.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29656 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fd4f53a7 22-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Implemented ReadSymlink() and Access().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29655 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b5884f05 22-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Got rid of from_fuse_error(). The client FS hooks are supposed to return
negative error codes now (e.g. using the new error mapping mechanism). This
is necessary since the read() and write() hooks have to return a size or a
negative error code.
* Implemented Read(). We can now read sshfs files.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29654 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fe24dc3d 21-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Fixed the directory filler callbacks. It is possible that it is passed a NULL
struct stat (new callback) or a 0 type. So if we don't have a node type, we
need to stat the node.
* Added simple opening/closing of files (no reading/writing yet).

It's now possible to browse sshfs volumes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29634 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8d0f474c 20-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added support for the zero offset method for the readdir() hook's filler
callback.
* Added support for the deprecated getdir() hook.
* Fixed various bugs.

Listing the root directory with sshfs does now work. For subdirectories
stat()ing the entries seems to fail, which might be due to the yet missing
open() support.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29623 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f06f7337 19-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* More work on the file system initialization. Mounting/unmounting works now
with sshfs.
* Added basic node and entry management, which we need, since the FUSE
interface works with paths only, while our VFS plays with node IDs and
node cookies.
* Implemented most of the mandatory hooks (vnode operations, lookup, read stat,
open/close/read dir). I was hoping to get directory listings with sshfs now,
but as I had to find out, it implements the deprecated getdir() while we
only support the new {open,read,release}dir() interface yet.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29619 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1d077f83 19-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added "fuse_api.h" header wrapping the inclusion of <fuse.h>.
* Implemented the fuse_fs_*() functions.
* More work on the initialization procedure for the client file system. We do
now start a separate thread which calls the main() function. It won't return
from fuse_main_real() until unmounting the FS. We create a fuse_fs structure
and call the client FS initialization and cleanup hooks.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29613 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 69cd702b 19-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Pass the file system name to the FileSystem base class and store it there.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29610 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c9323289 18-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Added FileSystem and Volume subclasses for the FUSE interface. ATM they are
mostly skeletons, doing a bit of initialization.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29604 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 861dbb4810c94214c9e00837e4a1704f8050e62e 08-Apr-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Implemented more of the detailed FUSE initialization functions for file systems
that use them directly instead of fuse_main().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30024 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e66cd9d71b0ae8fe311674bf7b87cb26d7452b61 02-Apr-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* For every request to userland we also send the team/thread/user/group ID of
the current thread, now. Implemented by introducing a new base class
KernelRequest which has respective attributes.
* Server: RequestThreadContext does now also save the request that is being
processed. Furthermore some space has been reserved for file system specific
data, which can be initialized by the new
FileSystem::InitRequestThreadContext().
* FUSE library: Implemented fuse_get_context() using the new
RequestThreadContext feature.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29872 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a7731138040434ec1fccf01e6c09c70311e550e3 02-Apr-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Initialize fuse_config before parsing the arguments.
* Implemented fuse_is_lib_option() more correctly.
* Actually use the value of the "use_ino" option.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29871 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 39f2d9e66b76c701467bb211a0229ee63fced5a5 31-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Parse the FUSE library options. They aren't used yet, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29844 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c8722a1e821590c60271c58bce3c2f505f42dd98 27-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Removed WriteFSInfo(). It's used only for changing the volume name and we
can't implement that with the FUSE interface.
* We now mark nodes dirty after a write operation.
* Implemented Sync() by fsync()ing all dirty nodes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29746 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 40b0400da7f99fd4822113ddda275e49368aa690 26-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Fixed incorrect loop check in _UnlockNodeChainInternal() nothing would ever
be unlocked.
* Fixed incorrect array indexing in _FindCommonAncestor().
* Fixed copy and paste bugs in _LockNodeChainsInternal().
* Added MultiNodeLocker class, a RAII frontend for _{Lock,Unlock}NodeChains().
* Implemented entry renaming and hard linking.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29741 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d7b73de2fd0f8ceab65ac180df484a3e36c9f037 26-Mar-2009 Rene Gollent <anevilyak@gmail.com>

Fix logic error that was coincidentally also triggering a gcc4 warning/error on build.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29739 a95241bf-73f2-0310-859d-f6bbb57e9c96


# edae667b947f29e55a2e6b4ae084b068970d8354 26-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Removed the asynchronous I/O methods. We won't implement them for the time
being.
* Introduced locking for FileCookie.
* Implemented SetFlags() and FSync().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29736 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b747212f50e5d0656ca37fc0481dc5c54a98102e 25-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Implemented WriteStat() (backend for chown(), chmod(), utime(), truncate()).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29722 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cd4ee847c4fab357b09c6beb021f5b13d0672f07 25-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added support for symlink and directory creation, as well as entry deletion
(directories and other nodes).
* Removed methods we can't possibly implement, since the FUSE interface doesn't
provide them and we can't emulate them.
* A FUSEEntry does now also own a reference to its parent directory.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29715 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d16ba4b9575c3699cb3dd3d1519cb009ffec66f8 24-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Added support for O_TRUNC, file creation, and writing to files.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29689 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f11f17301f8a6cc93f53733653cd0bda1b5a1c8c 22-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Implemented the attribute directory methods. Untested yet -- sshfs doesn't
support the respective xattr hooks.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29656 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fd4f53a7a02495d3dfcd5b41d053aff41ca609e5 22-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Implemented ReadSymlink() and Access().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29655 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b5884f05a3df604904dd19da67c435cd55a58b75 22-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Got rid of from_fuse_error(). The client FS hooks are supposed to return
negative error codes now (e.g. using the new error mapping mechanism). This
is necessary since the read() and write() hooks have to return a size or a
negative error code.
* Implemented Read(). We can now read sshfs files.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29654 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fe24dc3df4436d9d110aee801def086bbd9f47f8 21-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Fixed the directory filler callbacks. It is possible that it is passed a NULL
struct stat (new callback) or a 0 type. So if we don't have a node type, we
need to stat the node.
* Added simple opening/closing of files (no reading/writing yet).

It's now possible to browse sshfs volumes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29634 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8d0f474ca185e643a8140b4ff6628009f23a2cd8 20-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added support for the zero offset method for the readdir() hook's filler
callback.
* Added support for the deprecated getdir() hook.
* Fixed various bugs.

Listing the root directory with sshfs does now work. For subdirectories
stat()ing the entries seems to fail, which might be due to the yet missing
open() support.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29623 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f06f733751a4f6013ba903906e0b6302f37e3413 19-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* More work on the file system initialization. Mounting/unmounting works now
with sshfs.
* Added basic node and entry management, which we need, since the FUSE
interface works with paths only, while our VFS plays with node IDs and
node cookies.
* Implemented most of the mandatory hooks (vnode operations, lookup, read stat,
open/close/read dir). I was hoping to get directory listings with sshfs now,
but as I had to find out, it implements the deprecated getdir() while we
only support the new {open,read,release}dir() interface yet.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29619 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1d077f8397a3a222cf62d3c197ad5af5bfb48967 19-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Added "fuse_api.h" header wrapping the inclusion of <fuse.h>.
* Implemented the fuse_fs_*() functions.
* More work on the initialization procedure for the client file system. We do
now start a separate thread which calls the main() function. It won't return
from fuse_main_real() until unmounting the FS. We create a fuse_fs structure
and call the client FS initialization and cleanup hooks.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29613 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 69cd702b39187815d61ca260bb08df759f2f352e 19-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Pass the file system name to the FileSystem base class and store it there.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29610 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c93232896fd255f40f571e1a88c66bd34ebbef16 18-Mar-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Added FileSystem and Volume subclasses for the FUSE interface. ATM they are
mostly skeletons, doing a bit of initialization.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29604 a95241bf-73f2-0310-859d-f6bbb57e9c96