Comments (5)
I also tried using fcntl
locks, which also failed to work. I used the following Python script within a bindfs directory to test:
#!/usr/bin/python
import fcntl, os, time
fd = open('./lockfile', 'w')
fcntl.lockf(fd, fcntl.LOCK_EX|fcntl.LOCK_NB)
time.sleep(30)
fcntl.lockf(fd, fcntl.LOCK_UN)
fd.close()
When executed twice in the same directory, the second lock attempt fails to lock an already-locked file, as expected:
root@ubuntu:/test/bindfs1# ./fcntl-locktest &
[1] 5159
root@ubuntu:/test/bindfs1# ./fcntl-locktest
Traceback (most recent call last):
File "./fcntl-locktest", line 5, in <module>
fcntl.lockf(fd, fcntl.LOCK_EX|fcntl.LOCK_NB)
IOError: [Errno 11] Resource temporarily unavailable
However, when run in two different bindfs directories, both bound to the same underlying filesystem, it "succeeds" in locking the same file twice, indicating that fcntl locks are not working:
root@ubuntu:/test/bindfs1# ./fcntl-locktest &
[1] 5161
root@ubuntu:/test/bindfs1# cd ../bindfs2
root@ubuntu:/test/bindfs2# ./fcntl-locktest
Also "succeeds" in locking the same file twice when locking the file on the underlying file system, indicating that fcntl locks are not working:
root@ubuntu:/test/bindfs1# ./fcntl-locktest &
[1] 5165
root@ubuntu:/test/bindfs1# cd ../realfs/
root@ubuntu:/test/realfs# ./fcntl-locktest
The expected behavior is that the second lock attempt should fail.
from bindfs.
This should now be implemented in the master branch for both types of locks, but it requires --multithreaded
to avoid deadlocks. Please test and let me know if it works. I'll probably make a release after a week if no problems are reported.
The problems with --multithreaded
are probably fixable with a simple in-process lock, but sadly I don't have the time to do that right now. The code itself should be thread-safe i.e. I don't expect it to crash (what little global mutable state there is is behind a lock).
from bindfs.
I rebuilt using the current master + the latest FUSE and I see see this issue:
root@ubuntu-14:/test/bindfs1# which bindfs
/usr/local/bin/bindfs
root@ubuntu-14:/test/bindfs1# bindfs -V
bindfs 1.13.1
root@ubuntu-14:~# mkdir -p /test/realfs /test/bindfs1 /test/bindfs2
root@ubuntu-14:~# bindfs /test/realfs /test/bindfs1
root@ubuntu-14:~# bindfs /test/realfs /test/bindfs2
root@ubuntu-14:~# flock -n -x -o /test/bindfs1/lockfile sleep 30 &
[1] 1734
root@ubuntu-14:~# flock -n -x -o /test/bindfs2/lockfile sleep 10
root@ubuntu-14:~# echo $?
0
(Second lock succeeds, should fail.)
from bindfs.
Sorry, I forgot to mention you need to pass the new flag --enable-lock-forwarding
to make it work (new man page entry).
Enabling lock forwarding by default is blocked on some problems with multithreaded mode.
from bindfs.
Just tried:
root@ubuntu-14:~# bindfs --enable-lock-forwarding --enable-ioctl --multithreaded /test/realfs /test/bindfs1
root@ubuntu-14:~# bindfs --enable-lock-forwarding --enable-ioctl --multithreaded /test/realfs /test/bindfs2
root@ubuntu-14:~# flock -n -x -o /test/bindfs1/lockfile sleep 30 &
[1] 1798
root@ubuntu-14:~# flock -n -x -o /test/bindfs2/lockfile sleep 10
root@ubuntu-14:~# echo $?
1
Success! Thanks!
from bindfs.
Related Issues (20)
- Failed to resolve mount point on MacOS / Ventura HOT 3
- [Question/Bug maybe?] preserve/mirror file's selinux context HOT 2
- bindfs file descriptor leak with --block-devices-as-files HOT 2
- Behavior Question: Why does BindFS exhibit permission issues when bind mounted into a container? HOT 2
- Mount directory as a non-root user from /etc/fstab HOT 3
- no package Bindfs available HOT 3
- Support for 64bit statfs on macOS HOT 1
- Race condition between `bindfs` exit and filesystem actually being mounted HOT 5
- Unable to listen to unix domain socket inside bindfs mount on macOS HOT 8
- Test suite fails with fuse-t HOT 1
- ACLs on MacOS HOT 3
- configure: error: FUSE not found on Mac 13.5.1 HOT 5
- homebrew: Unsatisfied requirements failed this build. HOT 2
- macos: Provide Launch Agent to mount bindfs on system startup HOT 4
- Support for negative offset (?) HOT 3
- [1.17.5] Commit 38cd6e7e13ce966dc8e196eb3037935682e613a6 introduced undefined behavior? HOT 3
- Contributing simple Linux CI based on GitHub Actions via pull request welcome? HOT 17
- 1.17.6 no longer compiles on CentOS 7 HOT 1
- Memory allocation failures not checked
- Don't know how to build a static `bindfs` executable HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bindfs.