Skip to content

Commit ff99768

Browse files
authored
Merge branch 'master' into ptrace
2 parents a603a5d + 386c50c commit ff99768

16 files changed

+121
-166
lines changed

.travis.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ matrix:
4949
rust: 1.13.0
5050
- env: TARGET=arm-unknown-linux-gnueabi
5151
rust: 1.13.0
52-
# - env: TARGET=arm-unknown-linux-musleabi
52+
- env: TARGET=arm-unknown-linux-musleabi
53+
rust: 1.14.0
5354
- env: TARGET=armv7-unknown-linux-gnueabihf
5455
rust: 1.13.0
5556
- env: TARGET=i686-unknown-linux-gnu
@@ -58,8 +59,10 @@ matrix:
5859
rust: 1.13.0
5960
- env: TARGET=mips-unknown-linux-gnu
6061
rust: 1.13.0
61-
# - env: TARGET=mips64-unknown-linux-gnuabi64
62-
# - env: TARGET=mips64el-unknown-linux-gnuabi64
62+
- env: TARGET=mips64-unknown-linux-gnuabi64
63+
rust: 1.13.0
64+
- env: TARGET=mips64el-unknown-linux-gnuabi64
65+
rust: 1.13.0
6366
- env: TARGET=mipsel-unknown-linux-gnu
6467
rust: 1.13.0
6568
- env: TARGET=powerpc-unknown-linux-gnu
@@ -68,7 +71,8 @@ matrix:
6871
rust: 1.13.0
6972
- env: TARGET=powerpc64le-unknown-linux-gnu
7073
rust: 1.13.0
71-
# - env: TARGET=s390x-unknown-linux-gnu
74+
- env: TARGET=s390x-unknown-linux-gnu
75+
rust: 1.13.0
7276
- env: TARGET=x86_64-unknown-linux-gnu
7377
rust: 1.13.0
7478
- env: TARGET=x86_64-unknown-linux-musl
@@ -121,6 +125,16 @@ matrix:
121125
rust: 1.13.0
122126
os: osx
123127

128+
# Planning to add these targets, but they can fail for now
129+
- env: TARGET=mips64-unknown-linux-gnuabi64
130+
rust: 1.13.0
131+
- env: TARGET=mips64el-unknown-linux-gnuabi64
132+
rust: 1.13.0
133+
- env: TARGET=arm-unknown-linux-musleabi
134+
rust: 1.14.0
135+
- env: TARGET=s390x-unknown-linux-gnu
136+
rust: 1.13.0
137+
124138
# Failures for nightlies may be because of compiler bugs, so don't fail the
125139
# build if these fail.
126140
- env: TARGET=x86_64-unknown-linux-gnu

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
3939
respectively. Various functions have been changed to use these new types as
4040
arguments. ([#629](https://github.com/nix-rust/nix/pull/629))
4141
- Promoted all Android targets to Tier 2 support
42+
- `nix::sys::statfs::{statfs,fstatfs}` uses statfs definition from `libc::statfs` instead of own linux specific type `nix::sys::Statfs`.
43+
Also file system type constants like `nix::sys::statfs::ADFS_SUPER_MAGIC` were removed in favor of the libc equivalent.
44+
([#561](https://github.com/nix-rust/nix/pull/561))
4245

4346
### Removed
4447
- Removed io::Error from nix::Error and conversion from nix::Error to Errno
@@ -54,6 +57,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
5457
`Android` ([#631](https://github.com/nix-rust/nix/pull/631)).
5558
- `bind` and `errno_location` now work correctly on `Android`
5659
([#631](https://github.com/nix-rust/nix/pull/631))
60+
- Added `nix::ptrace` on all Linux-kernel-based platforms
61+
[#624](https://github.com/nix-rust/nix/pull/624). Previously it was
62+
only available on x86, x86-64, and ARM, and also not on Android.
5763

5864
## [0.8.1] 2017-04-16
5965

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
name = "nix"
44
description = "Rust friendly bindings to *nix APIs"
5-
version = "0.8.1-pre"
5+
version = "0.9.0-pre"
66
authors = ["The nix-rust Project Developers"]
77
homepage = "https://github.com/nix-rust/nix"
88
repository = "https://github.com/nix-rust/nix"
@@ -22,7 +22,7 @@ preadv_pwritev = []
2222
signalfd = []
2323

2424
[dependencies]
25-
libc = { git = "https://github.com/rust-lang/libc" }
25+
libc = "0.2.25"
2626
bitflags = "0.9"
2727
cfg-if = "0.1.0"
2828
void = "1.0.2"

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ call:
2626
// libc api (unsafe, requires handling return code/errno)
2727
pub unsafe extern fn gethostname(name: *mut c_char, len: size_t) -> c_int;
2828
29-
// nix api (returns a nix::Result)
30-
pub fn gethostname(name: &mut [u8]) -> Result<()>;
29+
// nix api (returns a nix::Result<CStr>)
30+
pub fn gethostname<'a>(buffer: &'a mut [u8]) -> Result<&'a CStr>;
3131
```
3232

3333
## Supported Platforms
@@ -77,9 +77,13 @@ Tier 2:
7777

7878
Tier 3:
7979
* aarch64-apple-ios
80+
* arm-unknown-linux-musleabi (requires Rust >= 1.14)
8081
* armv7-apple-ios
8182
* armv7s-apple-ios
8283
* i386-apple-ios
84+
* mips64-unknown-linux-gnuabi64
85+
* mips64el-unknown-linux-gnuabi64
86+
* s390x-unknown-linux-gnu
8387
* x86_64-apple-ios
8488

8589
## Usage

src/sys/ioctl/platform/linux.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pub const NRBITS: u32 = 8;
22
pub const TYPEBITS: u32 = 8;
33

4-
#[cfg(any(target_arch = "mips", target_arch = "powerpc", target_arch = "powerpc64"))]
4+
#[cfg(any(target_arch = "mips", target_arch = "mips64", target_arch = "powerpc", target_arch = "powerpc64"))]
55
mod consts {
66
pub const NONE: u8 = 1;
77
pub const READ: u8 = 2;
@@ -12,16 +12,19 @@ mod consts {
1212

1313
#[cfg(not(any(target_arch = "powerpc",
1414
target_arch = "mips",
15+
target_arch = "mips64",
1516
target_arch = "x86",
1617
target_arch = "arm",
1718
target_arch = "x86_64",
1819
target_arch = "powerpc64",
20+
target_arch = "s390x",
1921
target_arch = "aarch64")))]
2022
use this_arch_not_supported;
2123

2224
// "Generic" ioctl protocol
2325
#[cfg(any(target_arch = "x86",
2426
target_arch = "arm",
27+
target_arch = "s390x",
2528
target_arch = "x86_64",
2629
target_arch = "aarch64"))]
2730
mod consts {

src/sys/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,7 @@ pub mod uio;
5252

5353
pub mod time;
5454

55-
#[cfg(all(target_os = "linux",
56-
any(target_arch = "x86",
57-
target_arch = "x86_64",
58-
target_arch = "arm")),
59-
)]
55+
#[cfg(any(target_os = "linux", target_os = "android"))]
6056
pub mod ptrace;
6157

6258
pub mod select;

src/sys/ptrace.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ use ::unistd::Pid;
55

66
//------------------ First part: a low-level wrapper for ptrace -----------------//
77

8-
#[cfg(all(target_os = "linux",
9-
any(target_arch = "x86",
10-
target_arch = "x86_64",
11-
target_arch = "arm")),
12-
)]
138
pub mod ptrace {
149
use libc::c_int;
1510

src/sys/signal.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub enum Signal {
3232
SIGPIPE = libc::SIGPIPE,
3333
SIGALRM = libc::SIGALRM,
3434
SIGTERM = libc::SIGTERM,
35-
#[cfg(all(any(target_os = "linux", target_os = "android", target_os = "emscripten"), not(target_arch = "mips")))]
35+
#[cfg(all(any(target_os = "linux", target_os = "android", target_os = "emscripten"), not(any(target_arch = "mips", target_arch = "mips64"))))]
3636
SIGSTKFLT = libc::SIGSTKFLT,
3737
SIGCHLD = libc::SIGCHLD,
3838
SIGCONT = libc::SIGCONT,
@@ -58,7 +58,7 @@ pub enum Signal {
5858

5959
pub use self::Signal::*;
6060

61-
#[cfg(all(any(target_os = "linux", target_os = "android", target_os = "emscripten"), not(target_arch = "mips")))]
61+
#[cfg(all(any(target_os = "linux", target_os = "android", target_os = "emscripten"), not(any(target_arch = "mips", target_arch = "mips64"))))]
6262
const SIGNALS: [Signal; 31] = [
6363
SIGHUP,
6464
SIGINT,
@@ -91,7 +91,7 @@ const SIGNALS: [Signal; 31] = [
9191
SIGIO,
9292
SIGPWR,
9393
SIGSYS];
94-
#[cfg(all(any(target_os = "linux", target_os = "android", target_os = "emscripten"), target_arch = "mips"))]
94+
#[cfg(all(any(target_os = "linux", target_os = "android", target_os = "emscripten"), any(target_arch = "mips", target_arch = "mips64")))]
9595
const SIGNALS: [Signal; 30] = [
9696
SIGHUP,
9797
SIGINT,

src/sys/stat.rs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,6 @@ use libc::{self, mode_t};
77
use std::mem;
88
use std::os::unix::io::RawFd;
99

10-
mod ffi {
11-
use libc::{c_char, c_int, mode_t, dev_t};
12-
pub use libc::{stat, fstat, lstat};
13-
14-
extern {
15-
pub fn mknod(pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int;
16-
pub fn umask(mask: mode_t) -> mode_t;
17-
}
18-
}
19-
2010
libc_bitflags!(
2111
pub flags SFlag: mode_t {
2212
S_IFIFO,
@@ -56,7 +46,7 @@ bitflags! {
5646
pub fn mknod<P: ?Sized + NixPath>(path: &P, kind: SFlag, perm: Mode, dev: dev_t) -> Result<()> {
5747
let res = try!(path.with_nix_path(|cstr| {
5848
unsafe {
59-
ffi::mknod(cstr.as_ptr(), kind.bits | perm.bits() as mode_t, dev)
49+
libc::mknod(cstr.as_ptr(), kind.bits | perm.bits() as mode_t, dev)
6050
}
6151
}));
6252

@@ -84,15 +74,15 @@ pub fn makedev(major: u64, minor: u64) -> dev_t {
8474
}
8575

8676
pub fn umask(mode: Mode) -> Mode {
87-
let prev = unsafe { ffi::umask(mode.bits() as mode_t) };
77+
let prev = unsafe { libc::umask(mode.bits() as mode_t) };
8878
Mode::from_bits(prev).expect("[BUG] umask returned invalid Mode")
8979
}
9080

9181
pub fn stat<P: ?Sized + NixPath>(path: &P) -> Result<FileStat> {
9282
let mut dst = unsafe { mem::uninitialized() };
9383
let res = try!(path.with_nix_path(|cstr| {
9484
unsafe {
95-
ffi::stat(cstr.as_ptr(), &mut dst as *mut FileStat)
85+
libc::stat(cstr.as_ptr(), &mut dst as *mut FileStat)
9686
}
9787
}));
9888

@@ -105,7 +95,7 @@ pub fn lstat<P: ?Sized + NixPath>(path: &P) -> Result<FileStat> {
10595
let mut dst = unsafe { mem::uninitialized() };
10696
let res = try!(path.with_nix_path(|cstr| {
10797
unsafe {
108-
ffi::lstat(cstr.as_ptr(), &mut dst as *mut FileStat)
98+
libc::lstat(cstr.as_ptr(), &mut dst as *mut FileStat)
10999
}
110100
}));
111101

@@ -116,7 +106,7 @@ pub fn lstat<P: ?Sized + NixPath>(path: &P) -> Result<FileStat> {
116106

117107
pub fn fstat(fd: RawFd) -> Result<FileStat> {
118108
let mut dst = unsafe { mem::uninitialized() };
119-
let res = unsafe { ffi::fstat(fd, &mut dst as *mut FileStat) };
109+
let res = unsafe { libc::fstat(fd, &mut dst as *mut FileStat) };
120110

121111
try!(Errno::result(res));
122112

src/sys/statfs.rs

Lines changed: 5 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,21 @@
11
use {Errno, Result, NixPath};
22
use std::os::unix::io::AsRawFd;
3+
use libc;
34

4-
pub mod vfs {
5-
#[cfg(target_pointer_width = "32")]
6-
pub mod hwdep {
7-
use libc::{c_uint};
8-
pub type FsType = c_uint;
9-
pub type BlockSize = c_uint;
10-
pub type NameLen = c_uint;
11-
pub type FragmentSize = c_uint;
12-
pub type SwordType = c_uint;
13-
}
14-
15-
#[cfg(target_pointer_width = "64")]
16-
pub mod hwdep {
17-
use libc::{c_long};
18-
pub type FsType = c_long;
19-
pub type BlockSize = c_long;
20-
pub type NameLen = c_long;
21-
pub type FragmentSize = c_long;
22-
pub type SwordType = c_long;
23-
}
24-
25-
use sys::statfs::vfs::hwdep::*;
26-
27-
#[repr(C)]
28-
#[derive(Debug,Copy,Clone)]
29-
pub struct Statfs {
30-
pub f_type: FsType,
31-
pub f_bsize: BlockSize,
32-
pub f_blocks: u64,
33-
pub f_bfree: u64,
34-
pub f_bavail: u64,
35-
pub f_files: u64,
36-
pub f_ffree: u64,
37-
pub f_fsid: u64,
38-
pub f_namelen: NameLen,
39-
pub f_frsize: FragmentSize,
40-
pub f_spare: [SwordType; 5],
41-
}
42-
43-
pub const ADFS_SUPER_MAGIC : FsType = 0xadf5;
44-
pub const AFFS_SUPER_MAGIC : FsType = 0xADFF;
45-
pub const BEFS_SUPER_MAGIC : FsType = 0x42465331;
46-
pub const BFS_MAGIC : FsType = 0x1BADFACE;
47-
pub const CIFS_MAGIC_NUMBER : FsType = 0xFF534D42;
48-
pub const CODA_SUPER_MAGIC : FsType = 0x73757245;
49-
pub const COH_SUPER_MAGIC : FsType = 0x012FF7B7;
50-
pub const CRAMFS_MAGIC : FsType = 0x28cd3d45;
51-
pub const DEVFS_SUPER_MAGIC : FsType = 0x1373;
52-
pub const EFS_SUPER_MAGIC : FsType = 0x00414A53;
53-
pub const EXT_SUPER_MAGIC : FsType = 0x137D;
54-
pub const EXT2_OLD_SUPER_MAGIC : FsType = 0xEF51;
55-
pub const EXT2_SUPER_MAGIC : FsType = 0xEF53;
56-
pub const EXT3_SUPER_MAGIC : FsType = 0xEF53;
57-
pub const EXT4_SUPER_MAGIC : FsType = 0xEF53;
58-
pub const HFS_SUPER_MAGIC : FsType = 0x4244;
59-
pub const HPFS_SUPER_MAGIC : FsType = 0xF995E849;
60-
pub const HUGETLBFS_MAGIC : FsType = 0x958458f6;
61-
pub const ISOFS_SUPER_MAGIC : FsType = 0x9660;
62-
pub const JFFS2_SUPER_MAGIC : FsType = 0x72b6;
63-
pub const JFS_SUPER_MAGIC : FsType = 0x3153464a;
64-
pub const MINIX_SUPER_MAGIC : FsType = 0x137F; /* orig. minix */
65-
pub const MINIX_SUPER_MAGIC2 : FsType = 0x138F; /* 30 char minix */
66-
pub const MINIX2_SUPER_MAGIC : FsType = 0x2468; /* minix V2 */
67-
pub const MINIX2_SUPER_MAGIC2 : FsType = 0x2478; /* minix V2, 30 char names */
68-
pub const MSDOS_SUPER_MAGIC : FsType = 0x4d44;
69-
pub const NCP_SUPER_MAGIC : FsType = 0x564c;
70-
pub const NFS_SUPER_MAGIC : FsType = 0x6969;
71-
pub const NTFS_SB_MAGIC : FsType = 0x5346544e;
72-
pub const OPENPROM_SUPER_MAGIC : FsType = 0x9fa1;
73-
pub const PROC_SUPER_MAGIC : FsType = 0x9fa0;
74-
pub const QNX4_SUPER_MAGIC : FsType = 0x002f;
75-
pub const REISERFS_SUPER_MAGIC : FsType = 0x52654973;
76-
pub const ROMFS_MAGIC : FsType = 0x7275;
77-
pub const SMB_SUPER_MAGIC : FsType = 0x517B;
78-
pub const SYSV2_SUPER_MAGIC : FsType = 0x012FF7B6;
79-
pub const SYSV4_SUPER_MAGIC : FsType = 0x012FF7B5;
80-
pub const TMPFS_MAGIC : FsType = 0x01021994;
81-
pub const UDF_SUPER_MAGIC : FsType = 0x15013346;
82-
pub const UFS_MAGIC : FsType = 0x00011954;
83-
pub const USBDEVICE_SUPER_MAGIC : FsType = 0x9fa2;
84-
pub const VXFS_SUPER_MAGIC : FsType = 0xa501FCF5;
85-
pub const XENIX_SUPER_MAGIC : FsType = 0x012FF7B4;
86-
pub const XFS_SUPER_MAGIC : FsType = 0x58465342;
87-
pub const _XIAFS_SUPER_MAGIC : FsType = 0x012FD16D;
88-
}
89-
90-
mod ffi {
91-
use libc::{c_int,c_char};
92-
use sys::statfs::vfs;
93-
94-
extern {
95-
pub fn statfs(path: * const c_char, buf: *mut vfs::Statfs) -> c_int;
96-
pub fn fstatfs(fd: c_int, buf: *mut vfs::Statfs) -> c_int;
97-
}
98-
}
99-
100-
pub fn statfs<P: ?Sized + NixPath>(path: &P, stat: &mut vfs::Statfs) -> Result<()> {
5+
pub fn statfs<P: ?Sized + NixPath>(path: &P, stat: &mut libc::statfs) -> Result<()> {
1016
unsafe {
1027
Errno::clear();
1038
let res = try!(
104-
path.with_nix_path(|path| ffi::statfs(path.as_ptr(), stat))
9+
path.with_nix_path(|path| libc::statfs(path.as_ptr(), stat))
10510
);
10611

10712
Errno::result(res).map(drop)
10813
}
10914
}
11015

111-
pub fn fstatfs<T: AsRawFd>(fd: &T, stat: &mut vfs::Statfs) -> Result<()> {
16+
pub fn fstatfs<T: AsRawFd>(fd: &T, stat: &mut libc::statfs) -> Result<()> {
11217
unsafe {
11318
Errno::clear();
114-
Errno::result(ffi::fstatfs(fd.as_raw_fd(), stat)).map(drop)
19+
Errno::result(libc::fstatfs(fd.as_raw_fd(), stat)).map(drop)
11520
}
11621
}

0 commit comments

Comments
 (0)