Improve FreeBSD compatibility

First draft. Need to investigate why upstream patches include certain
function that appear to exist in FreeBSD 14.2.
This commit is contained in:
Antonio SJ Musumeci 2025-01-12 14:55:04 -06:00
parent dd906c8a4c
commit b83bd5fd14
10 changed files with 117 additions and 27 deletions

View file

@ -54,7 +54,8 @@ These options are the same regardless of whether you use them with the
mergerfs. (default: false)
- **lazy-umount-mountpoint=BOOL**: mergerfs will attempt to "lazy
umount" the mountpoint before mounting itself. Useful when
performing live upgrades of mergerfs. (default: false)
performing live upgrades of mergerfs. May not work on
FreeBSD. (default: false)
- **ignorepponrename=BOOL**: Ignore path preserving on
rename. Typically rename and link act differently depending on the
policy of `create` (read below). Enabling this will cause rename and

View file

@ -213,3 +213,27 @@ at best, provide equivalent performance, and in some cases, worse
performance. Splice is not supported on other platforms forcing a
traditional read/write fallback to be provided. The splice code was
removed to simplify the codebase.
## How does mergerfs handle credentials?
mergerfs is a multithreaded application in order to handle requests
from the kernel concurrently. Each FUSE message has a header with
certain details about the request include the process ID (pid) of the
requestion application, the process' effective user id (uid), and
group id (gid). To ensure proper POSIX filesystem behavior and
security mergerfs must change its identity to match that of the
requester when performing the core filesystem function on the
underlying filesystem. On most Unix/POSIX based system a process and
all its threads are under the same uid and gid. However, on Linux each
thread may have its own credentials. This allows mergerfs to be
multithreaded and for each thread to change to the credentials
(seteuid,setegid) as required by the incoming message it is
handling. However, on FreeBSD this is not possible at the moment
(though there has been
[discussions](https://wiki.freebsd.org/Per-Thread%20Credentials) and
as such must change the credentials of the whole application when
actioning messages. mergerfs does optimize this behavior by only
changing credentials and locking the thread to do so if the process is
currently not the same as what is necessary by the incoming request.

View file

@ -37,8 +37,8 @@
mergerfs can be found in the
[repositories](https://pkgs.org/download/mergerfs) of [many
Linux](https://repology.org/project/mergerfs/versions) (and maybe
FreeBSD) distributions.
Linux](https://repology.org/project/mergerfs/versions) distributions
and FreeBSD.
Note: Any non-rolling release based distro is likely to have
out-of-date versions.
@ -51,6 +51,7 @@ out-of-date versions.
* [Gentoo](https://packages.gentoo.org/packages/sys-fs/mergerfs)
* [Arch (AUR)](https://aur.archlinux.org/packages/mergerfs)
* [Void](https://voidlinux.org/packages/?arch=x86_64&q=mergerfs)
* [NixOS](https://search.nixos.org/packages?channel=22.11&show=mergerfs&from=0&size=50&sort=relevance&type=packages&query=mergerfs)
* [NixOS](https://search.nixos.org/packages?type=packages&query=mergerfs)
* [Guix]()
* [Slackware](https://slackbuilds.org/repository/15.0/system/mergerfs/?search=mergerfs)
* [FreeBSD](https://www.freshports.org/filesystems/mergerfs)

View file

@ -33,9 +33,9 @@ $ su -
# rpm -i rpmbuild/RPMS/<arch>/mergerfs-<version>.<arch>.rpm
```
## Generic
## Generic Linux
Have git, g++, make, python installed.
Have git, g++ or clang, make, python installed.
```
@ -44,6 +44,17 @@ $ make
$ sudo make install
```
## FreeBSD
Have git, g++ or clang, gmake, python installed.
```
$ cd mergerfs
$ gmake
$ gmake install # as root
```
## Build options
```

View file

@ -81,6 +81,14 @@ wget https://github.com/trapexit/mergerfs/releases/download/<ver>/mergerfs-<ver>
sudo rpm -i mergerfs-<ver>.el<rel>.<arch>.rpm
```
## NixOS
[search.nixos.org](https://search.nixos.org/packages?channel=unstable&show=mergerfs&from=0&size=50&sort=relevance&type=packages&query=mergerfs)
```
nix-env -iA nixos.mergerfs
```
## ArchLinux
@ -88,10 +96,15 @@ sudo rpm -i mergerfs-<ver>.el<rel>.<arch>.rpm
2. `pacman -S mergerfs`
## Other
## Other Linux Distros
Static binaries are provided for situations where native packages are
unavailable.
[Check your distro.](../related_projects.md#distributions-including-mergerfs)
## Static Linux Binaries
If your distro does not package mergerfs there are static binaries
provided.
Get the tarball from the [releases page](https://github.com/trapexit/mergerfs/releases).
@ -99,3 +112,13 @@ Get the tarball from the [releases page](https://github.com/trapexit/mergerfs/re
wget https://github.com/trapexit/mergerfs/releases/download/<ver>/mergerfs-static-linux_<arch>.tar.gz
sudo tar xvf mergerfs-static-linux_<arch>.tar.gz -C /
```
## FreeBSD
[https://www.freshports.org/filesystems/mergerfs](https://www.freshports.org/filesystems/mergerfs)
```
pkg install filesystems/mergerfs
```