@zirias
βͺ Why the hell is there no standard for checking the filesystem a file resides on? π§π
Wow, I'd always assumed statfs
was POSIX, but apparently not. I hadn't realised how anaemic the Linux version is either. It omits almost all of the useful information (such as the mount point).
In general, filesystem monitor things on network shares tend to be unreliable because they'd need the server to notify the client of writes, which is hard to scale. Apple's fswatch interface is particularly well designed to avoid ever blocking writes: if you don't keep up with consuming the firehose in userspace then you just get a notification that some writes have happened and you should go and check the modification times of files in the directories that you're watching. I believe it includes the timestamp of the first write that you missed, so you can just look for modifications newer than that.
It's possible to imagine a networked version of this but it would be very hard to implement. Consider an NFS server with 1,000 clients. Each client is doing writes and is also watching a load of files. One write may trigger monitoring events for all 1,000 clients. That's a lot of state to keep around. I don't think any network filesystem has a protocol for doing this (please point to it if I'm wrong, I'd love to see a protocol actually designed to do this!) and so, at best, you have to fall back to periodically polling the mtimes.
I believe the AFS / CODA caching protocol could be fudged to do this if you told the server that you had a local cache of all of the blocks in all of the files that you're watching.