Skip to content

Commit f830e00

Browse files
committed
Remove syscall module.
This module merely contained FFI declarations, and only enough to implement memfd_create() and pivot_root() wrapper functions in nix. Since these declarations are redundant with equivalent FFI declarations in libc, we'll remove them here. In the future, any syscall-related wrapper function will be implemented directly and utilize libc for FFI declarations as we cannot generically expose `syscall()` because of its variadic argument list.
1 parent a1067a2 commit f830e00

File tree

4 files changed

+7
-100
lines changed

4 files changed

+7
-100
lines changed

src/sys/memfd.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ bitflags!(
1111
);
1212

1313
pub fn memfd_create(name: &CStr, flags: MemFdCreateFlag) -> Result<RawFd> {
14-
use sys::syscall::{syscall, MEMFD_CREATE};
15-
let res = unsafe { syscall(MEMFD_CREATE, name.as_ptr(), flags.bits()) };
14+
let res = unsafe {
15+
libc::syscall(libc::SYS_memfd_create, name.as_ptr(), flags.bits())
16+
};
1617

1718
Errno::result(res).map(|r| r as RawFd)
1819
}

src/sys/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ pub mod socket;
3131

3232
pub mod stat;
3333

34-
#[cfg(any(target_os = "linux", target_os = "android"))]
35-
pub mod syscall;
36-
3734
#[cfg(any(target_os = "linux"))]
3835
pub mod reboot;
3936

src/sys/syscall.rs

Lines changed: 0 additions & 91 deletions
This file was deleted.

src/unistd.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use sys::stat::Mode;
1616
use std::fmt;
1717

1818
#[cfg(any(target_os = "android", target_os = "linux"))]
19-
pub use self::linux::*;
19+
pub use self::pivot_root::*;
2020

2121
#[cfg(any(target_os = "android", target_os = "freebsd",
2222
target_os = "linux", target_os = "openbsd"))]
@@ -1647,16 +1647,16 @@ pub fn sysconf(var: SysconfVar) -> Result<Option<c_long>> {
16471647
}
16481648

16491649
#[cfg(any(target_os = "android", target_os = "linux"))]
1650-
mod linux {
1651-
use sys::syscall::{syscall, SYSPIVOTROOT};
1650+
mod pivot_root {
1651+
use libc;
16521652
use {Errno, Result, NixPath};
16531653

16541654
pub fn pivot_root<P1: ?Sized + NixPath, P2: ?Sized + NixPath>(
16551655
new_root: &P1, put_old: &P2) -> Result<()> {
16561656
let res = try!(try!(new_root.with_nix_path(|new_root| {
16571657
put_old.with_nix_path(|put_old| {
16581658
unsafe {
1659-
syscall(SYSPIVOTROOT, new_root.as_ptr(), put_old.as_ptr())
1659+
libc::syscall(libc::SYS_pivot_root, new_root.as_ptr(), put_old.as_ptr())
16601660
}
16611661
})
16621662
})));

0 commit comments

Comments
 (0)