Skip to content

Commit

Permalink
Remove syscall module.
Browse files Browse the repository at this point in the history
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
a type-safe `syscall()` because of its variadic argument list.
  • Loading branch information
Susurrus committed Aug 27, 2017
1 parent a1067a2 commit d322aa9
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 100 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Fix compilation and tests for OpenBSD targets
([#688](https://github.com/nix-rust/nix/pull/688))

# Removed
- The syscall module has been removed. This only exposed enough functionality for
`memfd_create()` and `pivot_root()`, which are still exposed as separate functions.
([#747](https://github.com/nix-rust/nix/pull/747))

## [0.9.0] 2017-07-23

### Added
Expand Down
5 changes: 3 additions & 2 deletions src/sys/memfd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ bitflags!(
);

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

Errno::result(res).map(|r| r as RawFd)
}
3 changes: 0 additions & 3 deletions src/sys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ pub mod socket;

pub mod stat;

#[cfg(any(target_os = "linux", target_os = "android"))]
pub mod syscall;

#[cfg(any(target_os = "linux"))]
pub mod reboot;

Expand Down
91 changes: 0 additions & 91 deletions src/sys/syscall.rs

This file was deleted.

8 changes: 4 additions & 4 deletions src/unistd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use sys::stat::Mode;
use std::fmt;

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

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

#[cfg(any(target_os = "android", target_os = "linux"))]
mod linux {
use sys::syscall::{syscall, SYSPIVOTROOT};
mod pivot_root {
use libc;
use {Errno, Result, NixPath};

pub fn pivot_root<P1: ?Sized + NixPath, P2: ?Sized + NixPath>(
new_root: &P1, put_old: &P2) -> Result<()> {
let res = try!(try!(new_root.with_nix_path(|new_root| {
put_old.with_nix_path(|put_old| {
unsafe {
syscall(SYSPIVOTROOT, new_root.as_ptr(), put_old.as_ptr())
libc::syscall(libc::SYS_pivot_root, new_root.as_ptr(), put_old.as_ptr())
}
})
})));
Expand Down

0 comments on commit d322aa9

Please sign in to comment.