History log of /haiku/src/add-ons/kernel/file_systems/userlandfs/server/fuse/FUSEVolume.h
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>


# 03f7a184 16-Jul-2022 PulkoMandy <pulkomandy@pulkomandy.tk>

userlandfs-fuse: improve fuse_ll_readdir

The previous implementation needed a temporary buffer to store entries
and then sent them to the actual readdir buffer. This is now fixed, the
actual buffer is filled directly.

Also fixes problems with reading the same directory multiple times, and
reading large directories.

Change-Id: I8dc9677ee676144547d17f313a7f2d91fd2bca05
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5480
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


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

* Fixed double-lock in RemoveDir() spotted by Stippi.
* Added node monitoring support. For the changes we make at least. Changes made
by other peer in network file systems are not recognized.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29749 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


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

* Refactored node locking methods. There's now a LockIterator class which helps
with locking.
* Implemented methods for locking two directories. It's a bit complex, since
we need to enforce a global locking order on the node tree to avoid
deadlocks. Untested yet.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29738 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


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

Removed the fs_vnode_ops::create_dir() parameter for returning the ID of the
newly created dir. The VFS really doesn't need it and for some file systems
it might not be easy to get by. Several file systems (e.g. rootfs and fat)
were ignoring the parameter anyway.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29719 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


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

* Preparations for write support: Added a locking to the existing hooks. We
need to make sure that the paths of nodes don't change while we're meddling
with them. We read-lock the directories up to the root directory for that
purpose.
* Added missing locking for directory and attribute directory cookies.
We have to do that, since concurrent readdir()s on the same dir handle are
possible and we write-access the cookie data in such a case.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29687 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


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

A non-empty volume name looks much better in Tracker.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29635 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


# 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


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

* Fixed double-lock in RemoveDir() spotted by Stippi.
* Added node monitoring support. For the changes we make at least. Changes made
by other peer in network file systems are not recognized.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29749 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


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

* Refactored node locking methods. There's now a LockIterator class which helps
with locking.
* Implemented methods for locking two directories. It's a bit complex, since
we need to enforce a global locking order on the node tree to avoid
deadlocks. Untested yet.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29738 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


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

Removed the fs_vnode_ops::create_dir() parameter for returning the ID of the
newly created dir. The VFS really doesn't need it and for some file systems
it might not be easy to get by. Several file systems (e.g. rootfs and fat)
were ignoring the parameter anyway.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29719 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


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

* Preparations for write support: Added a locking to the existing hooks. We
need to make sure that the paths of nodes don't change while we're meddling
with them. We read-lock the directories up to the root directory for that
purpose.
* Added missing locking for directory and attribute directory cookies.
We have to do that, since concurrent readdir()s on the same dir handle are
possible and we write-access the cookie data in such a case.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29687 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


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

A non-empty volume name looks much better in Tracker.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29635 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


# 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