cberner / fuser

Filesystem in Userspace (FUSE) for Rust
MIT License
836 stars 114 forks source link

libfuse fuse_session_mount() does not set errno #176

Closed cehteh closed 3 years ago

cehteh commented 3 years ago

in fuse3.rs:29:

       let result = unsafe { fuse_session_mount(mount.fuse_session, mnt.as_ptr()) };
       if result != 0 {
            return Err(io::Error::last_os_error());
       }

fuse_session_mount() may fail with -1 but it doesn't set errno, thus Err("Success") is returned. This is a bit unfortunate and confusing.

I may send a PR next days that checks if io::Error::last_os_error() is 'Success' and in that case falls back to ErrorKind::Other to have at least some valid error. Since this comes from the fuse library nothing more we can do. If upstream fixes this (I may investigate and open an issue there) this will be fixed here too.

On another note: 'fuse_session_mount()' barfs a message to stderr about the possible problem:

$ mkdir broken_mountpoint
$ chmod 0000 broken_mountpoint
$ myfilesystem broken_mountpoint/
fusermount3: failed to chdir to mountpoint: Permission denied

¯\(ツ)

cberner commented 3 years ago

Haha, that's an unfortunate error message. Ya, happy to take a PR that improves it