diff options
-rw-r--r-- | src/bindfs.c | 7 | ||||
-rwxr-xr-x | tests/test_bindfs.rb | 36 |
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') |