Closed kik0908 closed 1 year ago
Sorry for the spam. If someone has the same question, then this problem can be solved using Session
:
...
thread::spawn(move || {
let fs = create_filesystem(); // fs is impl Filesystem
let mut session = Session::new(fs, mountpoint, options).unwrap();
let session_end = session.unmount_callable();
channel.send(session_end);
session.run()
}
...
and then in main thread:
let mut unmount = channel.recv();
unmount.unmount()
I want spawn a background thread to handle filesystem operations, but
spawn_mount2
requiresimpl Send
for filesystem. As I understand from source code, fuser requiresSend
only to send the file system to a new thread, and not to work directly. This behavior prevents you from using!Send
data types(Rc
orRefCell
for example) in the fs implementation. How can I hack this to use such!Send
data types? Also I should have a way to unmount my filesystem from my code likeBackgroundSession::join
I could implement a
Send
wrapper for my filesystem and use the code fromBackgroundSession::new
but I am limited by the privacy of variables to create a newBackgroundSession
.I admit that there is a solution to my problem in the current version of fuser, but I don't understand how to do it.