Skip to content

Commit

Permalink
Fix Linux umount
Browse files Browse the repository at this point in the history
  • Loading branch information
zargony committed Feb 27, 2015
1 parent a6b4f31 commit e9560fd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ mod libc {

pub fn realpath (file_name: *const c_char, resolved_name: *mut c_char) -> *const c_char;

#[cfg(target_os = "macos")]
pub fn unmount(dir: *const c_char, flags: c_int) -> c_int;
#[cfg(not(target_os = "macos"))]
pub fn umount(dir: *const c_char) -> c_int;
}

/// Max length for path names. 4096 should be reasonable safe (OS X uses 1024, Linux uses 4096)
Expand Down Expand Up @@ -153,8 +156,13 @@ pub fn unmount (mountpoint: &Path) -> io::Result<()> {
// 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.
#[cfg(target_os = "macos")] #[inline]
fn libc_umount (mnt: &CStr) -> c_int { unsafe { libc::unmount(mnt.as_ptr(), 0) } }
#[cfg(not(target_os = "macos"))] #[inline]
fn libc_umount (mnt: &CStr) -> c_int { unsafe { libc::umount(mnt.as_ptr()) } }

let mnt = try!(mountpoint.as_os_str().to_cstring());
let rc = unsafe { libc::unmount(mnt.as_ptr(), 0) };
let rc = libc_umount(&mnt);
if rc < 0 {
Err(io::Error::last_os_error())
} else {
Expand Down

0 comments on commit e9560fd

Please sign in to comment.