Skip to content

Commit ec37fa8

Browse files
committed
Auto merge of #356 - brianp:mount-libc, r=posborne
mount: Use bindings from libc instead of our own Ref #264 Changing internal usage of `ffi::mount` and `ffi:umount` to make use of libc.
2 parents b7c2f88 + 2f54367 commit ec37fa8

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

src/mount.rs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use libc::{c_ulong, c_int};
2+
use libc;
23
use {Errno, Result, NixPath};
34

45
bitflags!(
@@ -48,23 +49,6 @@ bitflags!(
4849
}
4950
);
5051

51-
mod ffi {
52-
use libc::{c_char, c_int, c_ulong, c_void};
53-
54-
extern {
55-
pub fn mount(
56-
source: *const c_char,
57-
target: *const c_char,
58-
fstype: *const c_char,
59-
flags: c_ulong,
60-
data: *const c_void) -> c_int;
61-
62-
pub fn umount(target: *const c_char) -> c_int;
63-
64-
pub fn umount2(target: *const c_char, flags: c_int) -> c_int;
65-
}
66-
}
67-
6852
pub fn mount<P1: ?Sized + NixPath, P2: ?Sized + NixPath, P3: ?Sized + NixPath, P4: ?Sized + NixPath>(
6953
source: Option<&P1>,
7054
target: &P2,
@@ -79,7 +63,7 @@ pub fn mount<P1: ?Sized + NixPath, P2: ?Sized + NixPath, P3: ?Sized + NixPath, P
7963
fstype.with_nix_path(|fstype| {
8064
data.with_nix_path(|data| {
8165
unsafe {
82-
ffi::mount(source.as_ptr(),
66+
libc::mount(source.as_ptr(),
8367
target.as_ptr(),
8468
fstype.as_ptr(),
8569
flags.bits,
@@ -95,15 +79,15 @@ pub fn mount<P1: ?Sized + NixPath, P2: ?Sized + NixPath, P3: ?Sized + NixPath, P
9579

9680
pub fn umount<P: ?Sized + NixPath>(target: &P) -> Result<()> {
9781
let res = try!(target.with_nix_path(|cstr| {
98-
unsafe { ffi::umount(cstr.as_ptr()) }
82+
unsafe { libc::umount(cstr.as_ptr()) }
9983
}));
10084

10185
Errno::result(res).map(drop)
10286
}
10387

10488
pub fn umount2<P: ?Sized + NixPath>(target: &P, flags: MntFlags) -> Result<()> {
10589
let res = try!(target.with_nix_path(|cstr| {
106-
unsafe { ffi::umount2(cstr.as_ptr(), flags.bits) }
90+
unsafe { libc::umount2(cstr.as_ptr(), flags.bits) }
10791
}));
10892

10993
Errno::result(res).map(drop)

0 commit comments

Comments
 (0)