Closed cehteh closed 3 years ago
I believe Filesystem::init
already covers this, and I think it will be more reliable than the interface you proposed, because it's called only after the event loop has started, rather than right before se.run()
is entered.
Let me know if that doesn't work
Ah, good catch, I'll give it a try tomorrow. It may be a bit tricky to get a callback closure into the init, possibly has to be passed to my filesystems constructor and be stored there, lingering there forever after the once-use.
Either way I just implemented what I proposed above as proof or concept: https://github.com/cehteh/fuser/commit/4cc0df882279ef68d15ecfad2e7d227ba8516121 Works for me, but I don't make a PR before i see if the ::init thing works.
Got it working, but its a bit tricky :) (have to impl Filesystem for &mut MyFilesystem
)
My draft PR #184 addresses this. mount
ing a filesystem is now separate from actually running the mainloop.
I am sending a filesystem process into the background with the 'daemonize' crate. To make this somewhat reliable/scriptable I would like if the parent process returns when the mount is established (or failed thereof)
Imagine some shell script like:
Now there is some chance of a race between 'myfilesystem' forking into the background and starting the mount and the execution of the 'ls' command. Moreover there is no way to tell if the mounting was successful by the exit code.
I am already establishing an ipc channel from background child to the parent to pass information/errors up. All whats left is some way the 'fuser' lib can notify back that a mount was successful, after establishing an Session but right before entering the event loop.
Similar to 'mount2' i would propose the following API:
The callback can then inspect the error or the session and take proper action (sending the status over the IPC channel).
This .or_else().and_then() chaining looks a bit ugly for now (could be written more pretty?), one may consider to implement a .inspect() for Result (there is an existing crate for that, but that one only passes the Ok() part).