Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ericpruitt opened this issue Jan 20, 2024 · 2 comments
Labels

Comments

@ericpruitt
Copy link
Contributor

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.

@SimonHeimberg
Copy link

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

@ericpruitt
Copy link
Contributor Author

ericpruitt commented Jul 24, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants