Is it possible to differentiate between operations on different file descriptors?
In my filesystem, I want to be able to differentiate between operations that take place on different file descriptors, but since the I/O operations only include the path, I don't see a way to do that. Is it possible at all? If not, is it a limitation of FUSE or the python-fuse library? I see in the FUSE struct that there's a an "fh" value that looks like it might be what I need, but I'm not certain.
Reading a chapter in new_fusepy_api[1] I see two possibilities:
- The method
YourFuseClass.open(...)returns any object (like a dict, a list, a class instance, ...). Then the other methods (read(...),write(...)get this object as additional fh argument. - Set
YourFuseClass.file_class = YourOwnFileClassbefore callingmain(). Then the related I/O methods (read(...),write(...)are called on a separate class instance (of YourOwnFileClass) for each file handle. (And__init__(...)is called instead ofopen().)
[1] https://github.com/libfuse/python-fuse/blob/master/README.new_fusepy_api.rst#filehandles-can-also-be-objects-if-you-want
I don't understand how that's supposed to work. python-fuse will still pass in strings to indicate the open file regardless of the underlying class. If you open the same file multiple times, regardless of the underlying IO type, python-fuse will still use the exact same string for all handles.