aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Pärtel <martin.partel@gmail.com>2024-06-05 09:06:31 +0300
committerMartin Pärtel <martin.partel@gmail.com>2024-06-05 09:06:31 +0300
commit9bd2e4223b8050da96ee78e717a9ba2473de9a60 (patch)
tree011167bca387dd74b8f7d57996ae7de9d84fa394
parent0a26c1d7d25849bb9161d35fda6734a48bff0dea (diff)
downloadbindfs-9bd2e4223b8050da96ee78e717a9ba2473de9a60.tar.gz
Warn that lock forwarding does not forward flock() on FreeBSD.
-rw-r--r--src/bindfs.c7
-rwxr-xr-xtests/test_bindfs.rb36
2 files changed, 27 insertions, 16 deletions
diff --git a/src/bindfs.c b/src/bindfs.c
index c21cdb5..ae5fa78 100644
--- a/src/bindfs.c
+++ b/src/bindfs.c
@@ -2927,6 +2927,13 @@ int main(int argc, char *argv[])
return 1;
}
+#if defined(__FreeBSD__)
+ if (settings.enable_lock_forwarding) {
+ fprintf(stderr, "WARNING: FreeBSD (version 14) doesn't yet forward flock() to FUSE filesystems: https://wiki.freebsd.org/action/recall/FUSEFS?action=recall&rev=58\n");
+ fprintf(stderr, "This means that only fcntl()-based locks might be forwarded by bindfs!\n");
+ }
+#endif
+
/* Remove the locking implementation unless the user has enabled lock
forwarding. FUSE implements locking inside the mountpoint by default. */
if (!settings.enable_lock_forwarding) {
diff --git a/tests/test_bindfs.rb b/tests/test_bindfs.rb
index 22f356f..46c6101 100755
--- a/tests/test_bindfs.rb
+++ b/tests/test_bindfs.rb
@@ -774,16 +774,18 @@ if $have_fuse_29 || $have_fuse_3
# (this test passes with an empty file as well, but this way is clearer)
# flock
- File.open('mnt/file') do |f1|
- File.open('src/file') do |f2|
+ if `uname`.strip != 'FreeBSD' # FreeBSD's FUSE doesn't yet support forwarding flock: https://wiki.freebsd.org/action/recall/FUSEFS?action=recall&rev=58
+ File.open('mnt/file') do |f1|
+ File.open('src/file') do |f2|
+ assert { f1.flock(File::LOCK_EX | File::LOCK_NB) }
+ assert { !f2.flock(File::LOCK_EX | File::LOCK_NB) }
+ assert { f1.flock(File::LOCK_UN) }
+
+ assert { f2.flock(File::LOCK_EX | File::LOCK_NB) }
+ assert { !f1.flock(File::LOCK_EX | File::LOCK_NB) }
+ end
assert { f1.flock(File::LOCK_EX | File::LOCK_NB) }
- assert { !f2.flock(File::LOCK_EX | File::LOCK_NB) }
- assert { f1.flock(File::LOCK_UN) }
-
- assert { f2.flock(File::LOCK_EX | File::LOCK_NB) }
- assert { !f1.flock(File::LOCK_EX | File::LOCK_NB) }
end
- assert { f1.flock(File::LOCK_EX | File::LOCK_NB) }
end
# fcntl locking
@@ -795,13 +797,15 @@ if $have_fuse_29 || $have_fuse_3
File.write('src/file', 'some contents for fcntl lockng')
# flock
- File.open('mnt/file') do |f1|
- File.open('src/file') do |f2|
- assert { f1.flock(File::LOCK_EX | File::LOCK_NB) }
- assert { f2.flock(File::LOCK_EX | File::LOCK_NB) }
- end
- File.open('mnt/file') do |f2|
- assert { !f2.flock(File::LOCK_EX | File::LOCK_NB) }
+ if `uname`.strip != 'FreeBSD' # FreeBSD's FUSE doesn't yet support forwarding flock: https://wiki.freebsd.org/action/recall/FUSEFS?action=recall&rev=58
+ File.open('mnt/file') do |f1|
+ File.open('src/file') do |f2|
+ assert { f1.flock(File::LOCK_EX | File::LOCK_NB) }
+ assert { f2.flock(File::LOCK_EX | File::LOCK_NB) }
+ end
+ File.open('mnt/file') do |f2|
+ assert { !f2.flock(File::LOCK_EX | File::LOCK_NB) }
+ end
end
end
@@ -818,7 +822,7 @@ end # have_fuse_29
#
# This test is also disabled for old (FUSE < 2.9) systems.
# TODO: figure out why it doesn't work.
-if $have_fuse_29 || $have_fuse_3
+if ($have_fuse_29 || $have_fuse_3) && `uname`.strip != 'FreeBSD' # FreeBSD's FUSE doesn't yet support ioctl: https://wiki.freebsd.org/action/recall/FUSEFS?action=recall&rev=58
root_testenv("--enable-ioctl", :title => "append-only ioctl", :valgrind => false) do
touch('mnt/file')
system('chattr +a mnt/file')