Is there anyway in linux (I don't care which distribution or flavor) to have a dynamic file system with read/write hooks? For example I would like to mount a dynamic file system at /dynamic and whenever I try to read/write to a non-existing location a bash script or program is run. like if I did tail /dynamic/folder1/file1.log a bash script would run before the read operation and the path would be available as an argument. Is there any projects out there that do something like this?
|
|
|||
|
|
|
You're looking for FUSE.
Although to be fair, I haven't seen a FUSE module for raw programs/scripts so you'll still need to do some coding. |
||||
|
|
You might also want to have a look at inotify. It provides an API that listens for file system changes. You could for example use However I think it's not possible to get informed of read attempts to inexisting files (with an option to create it before the other program can read it) but depending on your use-case you might get around that issue. If inotify is not the right choice for you, I'd use FUSE as Ignacio suggested. But that might add a lot of additional work to implement what you desire. |
|||
|
|