Hello.
Now a question easier than my previous one. How do you unmount a
(OSXFUSE) filesystem from code? Do you launch a new process with the
`umount` program, or you do it making calls to FUSE functions? I've
attempted several combinations of the latter, with no luck.
I mount more or less like this:
// (...) Setup options, operations, etc.
// Save some return values for later in member variables of a class.
m_channel = fuse_mount(mountpoint, &arguments);
m_filesystem = fuse_new(m_channel, &arguments, &operations,
sizeof(operations), 0);
int result = fuse_loop(m_filesystem);
fuse_unmount(mountpoint, m_channel);
fuse_destroy(m_filesystem);
This is more or less what fuse_main does, but I don't launch the file
system from a console, so the UNIX signal handlers are not useful to me
to interrupt the file system. I try to unmount it the same way it's done
by those signal handlers that fuse_main installs, which is:
fuse_session_exit(fuse_get_session(m_filesystem));
I call that from a different thread instead of a signal handler.
This works with one important issue: it unmounts the file system cleanly
after some access to the file system, and after about 60 seconds (the
FUSE_DEFAULT_DAEMON_TIMEOUT, I assume). On Linux the behaviour is the
same, but there is no delay. This matches this known behaviour:
http://stackoverflow.com/questions/8903448/libfuse-exiting-fuse-session-loop/
On Linux the following works unmounting immediately without noticeable
problems, but Valgrind reports some memory issues (and on OSXFUSE it
crashes the application):
fuse_unmount(mountpoint, m_channel);
// And then NOT calling fuse_unmount again after fuse_loop.
Calling umount (or unmounting through Finder) seems to work always, and
I do wonder if that's the only supported way.
Thank you.
Regards.