Skip to content

question: how to pass information from fuse-fs to file_class? #97

Description

@knarrff

Hi,

while starting to implement a fs using python-fuse (https://gitlab.com/remarkable7735917/rmfs) and using the xmp example as a starting point I faced a problem: I did not want to use the current directory as 'state' for the filesystem to essentially pass around the "source-dir". That's easy within the fs itself: just add a class field and use that in all methods. However, things got complicated with file_class, but here is the more general question:

How can I pass information from an instance of a fuse-fs to the respective instances of file_class? This could be a user-specified mount-option which modifies how file_class would do things, or in the example of xmp it could be the source-dir (which directory to mirror).

The problem, as I see it, is: the class file_class is passed to python-fuse as-is and instantiated from there (not from an instance of fs). file_class does not have any information about which instance of the fs it is currently 'serving' nor what options given to that fs might be. I can reference the class of the fs from file_class, but I cannot reference the current instance which would hold the information I need. I also do not have a way to get to the instance of file_class from the instance of fs, especially not before file_class.init is called (where I most likely already need that info), because it is not fs instantiating file_class, but python-fuse.

My current workaround is to change file_class by adding a field (to the class) before passing that (modified) class to python-fuse, and then reading that class-field from the instance. That works. However, I feel this isn't clean: this information should not be stored at class-level but on instance-level. Another option could possibly be to pass the instance of the fs to file_class.init as well, so then the new instance of file_class can reference fields from the instance of fs it is used for. Yet another option could be to call the fs to instantiate file_class instead of doing that from within python-fuse: then fs could pass information to the new instance directly.

What is the currently preferred way to pass information from an instance of a fs to init of a new instance of file_class?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions