/// Unmount an arbitrary mountpoint
// FIXME: This should be moved to `Channel::unmount`, but it's still needed for `BackgroundSession`
Unmount an arbitrary mountpoint
FIXME: This should be moved to `Channel::unmount`, but it's still needed for `BackgroundSession`
Unmount an arbitrary mountpoint FIXME : This should be moved to ` Channel :: unmount ` but it ' s still needed for ` BackgroundSession `
pub fn unmount(mountpoint: &Path) -> io::Result<()> {
    // `fuse_unmount_compat22` unfortunately doesn't return a status. Additionally, it attempts
    // to call `realpath`, which in turn calls into the filesystem. So if the filesystem returns
    // an error, the unmount does not take place, with no indication of the error available to
    // the caller. So we call unmount directly (which is what OSXFUSE does anyway), since we
    // already converted to the real path when we first mounted.
    // On macOS and BSD, simply call `libc::unmount` to unmount.
    #[cfg(any(
        target_os = "macos",
        target_os = "freebsd",
        target_os = "dragonfly",
        target_os = "openbsd",
        target_os = "bitrig",
        target_os = "netbsd"
    ))]
    #[inline]
    fn unmount(path: &CStr) -> libc::c_int {
        unsafe { libc::unmount(path.as_ptr(), 0) }
    }
    // On Linux, try calling `libc::umount` but fall back to libfuse in case of permission
    // errors.
    #[cfg(not(any(
        target_os = "macos",
        target_os = "freebsd",
        target_os = "dragonfly",
        target_os = "openbsd",
        target_os = "bitrig",
        target_os = "netbsd"
    )))]
    #[inline]
    fn unmount(path: &CStr) -> libc::c_int {
        use fuse_sys::fuse_unmount_compat22;
        use std::io::ErrorKind::PermissionDenied;
        let rc = unsafe { libc::umount(path.as_ptr()) };
        if rc < 0 && io::Error::last_os_error().kind() == PermissionDenied {
            // Linux always returns EPERM for non-root users. We have to let the
            // library go through the setuid-root "fusermount -u" to unmount.
            unsafe {
                fuse_unmount_compat22(path.as_ptr());
            }
            0
        } else {
            rc
        }
    }
    // Unmount this channel's mountpoint
    let path = CString::new(mountpoint.as_os_str().as_bytes())?;
    try_io!(unmount(&path));
    Ok(())
}
pub fn unmount ( mountpoint : & Path ) -> io :: Result < ( ) > { // `fuse_unmount_compat22` unfortunately doesn't return a status. Additionally, it attempts // to call `realpath`, which in turn calls into the filesystem. So if the filesystem returns // an error, the unmount does not take place, with no indication of the error available to // the caller. So we call unmount directly (which is what OSXFUSE does anyway), since we // already converted to the real path when we first mounted. // On macOS and BSD, simply call `libc::unmount` to unmount. # [ cfg ( any ( target_os " " target_os " " target_os " " target_os " " target_os " " target_os " " ) ) ] # [ inline ] fn unmount ( path : & CStr ) -> libc :: c_int { unsafe { libc :: unmount ( path . as_ptr ( ) , 0 ) } } // On Linux, try calling `libc::umount` but fall back to libfuse in case of permission // errors. # [ cfg ( not ( any ( target_os " " target_os " " target_os " " target_os " " target_os " " target_os " " ) ) ) ] # [ inline ] fn unmount ( path : & CStr ) -> libc :: c_int { use fuse_sys :: fuse_unmount_compat22 ; use std :: io :: ErrorKind :: PermissionDenied ; let rc = unsafe { libc :: umount ( path . as_ptr ( ) ) } ; if rc < 0 && io :: Error :: last_os_error ( ) . kind ( ) == PermissionDenied { // Linux always returns EPERM for non-root users. We have to let the // library go through the setuid-root "fusermount -u" to unmount. unsafe { fuse_unmount_compat22 ( path . as_ptr ( ) ) ; } 0 } else { rc } } // Unmount this channel's mountpoint let path = CString :: new ( mountpoint . as_os_str ( ) . as_bytes ( ) ) ? ; try_io ! ( unmount ( path ) ) ; Ok ( ( ) ) }
Unmount an arbitrary mountpoint
FIXME: This should be moved to `Channel::unmount`, but it's still needed for `BackgroundSession`
Unmount an arbitrary mountpoint FIXME : This should be moved to ` Channel :: unmount ` but it ' s still needed for ` BackgroundSession `
mountpoint
&Path