python-fuse icon indicating copy to clipboard operation
python-fuse copied to clipboard

Is it possible to differentiate between operations on different file descriptors?

Open ericpruitt opened this issue 1 year ago • 2 comments

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.

ericpruitt avatar Jan 20 '24 00:01 ericpruitt

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 = YourOwnFileClass before calling main(). 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 of open().)

[1] https://github.com/libfuse/python-fuse/blob/master/README.new_fusepy_api.rst#filehandles-can-also-be-objects-if-you-want

SimonHeimberg avatar Jul 24 '24 21:07 SimonHeimberg

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.

ericpruitt avatar Jul 24 '24 22:07 ericpruitt