Merge pull request #38 from danburkert/fs

bind additional filesystem APIs
This commit is contained in:
Alex Crichton 2015-11-04 23:06:44 -08:00
commit e4bb63a9b2
9 changed files with 123 additions and 3 deletions

View File

@ -86,6 +86,7 @@ fn main() {
} else if !windows {
cfg.header("glob.h");
cfg.header("ifaddrs.h");
cfg.header("sys/statvfs.h");
if !musl {
cfg.header("execinfo.h");

View File

@ -134,6 +134,33 @@ s! {
pub ss_size: ::size_t,
pub ss_flags: ::c_int,
}
pub struct fstore_t {
pub fst_flags: ::c_uint,
pub fst_posmode: ::c_int,
pub fst_offset: ::off_t,
pub fst_length: ::off_t,
pub fst_bytesalloc: ::off_t,
}
pub struct radvisory {
pub ra_offset: ::off_t,
pub ra_count: ::c_int,
}
pub struct statvfs {
pub f_bsize: ::c_ulong,
pub f_frsize: ::c_ulong,
pub f_blocks: ::fsblkcnt_t,
pub f_bfree: ::fsblkcnt_t,
pub f_bavail: ::fsblkcnt_t,
pub f_files: ::fsfilcnt_t,
pub f_ffree: ::fsfilcnt_t,
pub f_favail: ::fsfilcnt_t,
pub f_fsid: ::c_ulong,
pub f_flag: ::c_ulong,
pub f_namemax: ::c_ulong,
}
}
pub const EXIT_FAILURE: ::c_int = 1;
@ -196,7 +223,6 @@ pub const F_LOCK: ::c_int = 1;
pub const F_TEST: ::c_int = 3;
pub const F_TLOCK: ::c_int = 2;
pub const F_ULOCK: ::c_int = 0;
pub const F_DUPFD_CLOEXEC: ::c_int = 67;
pub const SIGHUP: ::c_int = 1;
pub const SIGINT: ::c_int = 2;
pub const SIGQUIT: ::c_int = 3;
@ -342,10 +368,27 @@ pub const EQFULL: ::c_int = 106;
pub const ELAST: ::c_int = 106;
pub const F_DUPFD: ::c_int = 0;
pub const F_DUPFD_CLOEXEC: ::c_int = 67;
pub const F_GETFD: ::c_int = 1;
pub const F_SETFD: ::c_int = 2;
pub const F_GETFL: ::c_int = 3;
pub const F_SETFL: ::c_int = 4;
pub const F_PREALLOCATE: ::c_int = 42;
pub const F_RDADVISE: ::c_int = 44;
pub const F_RDAHEAD: ::c_int = 45;
pub const F_NOCACHE: ::c_int = 48;
pub const F_GETPATH: ::c_int = 50;
pub const F_FULLFSYNC: ::c_int = 51;
pub const F_FREEZE_FS: ::c_int = 53;
pub const F_THAW_FS: ::c_int = 54;
pub const F_GLOBAL_NOCACHE: ::c_int = 55;
pub const F_NODIRECT: ::c_int = 62;
pub const F_ALLOCATECONTIG: ::c_uint = 0x02;
pub const F_ALLOCATEALL: ::c_uint = 0x04;
pub const F_PEOFPOSMODE: ::c_int = 3;
pub const F_VOLPOSMODE: ::c_int = 4;
pub const O_ACCMODE: ::c_int = 3;
@ -491,8 +534,6 @@ pub const LOCK_UN: ::c_int = 8;
pub const O_DSYNC: ::c_int = 4194304;
pub const O_SYNC: ::c_int = 128;
pub const O_NONBLOCK: ::c_int = 4;
pub const F_GETPATH: ::c_int = 50;
pub const F_FULLFSYNC: ::c_int = 51;
pub const MAP_COPY: ::c_int = 0x0002;
pub const MAP_RENAME: ::c_int = 0x0020;

View File

@ -85,6 +85,20 @@ s! {
pub ss_size: ::size_t,
pub ss_flags: ::c_int,
}
pub struct statvfs {
pub f_bavail: ::fsblkcnt_t,
pub f_bfree: ::fsblkcnt_t,
pub f_blocks: ::fsblkcnt_t,
pub f_favail: ::fsfilcnt_t,
pub f_ffree: ::fsfilcnt_t,
pub f_files: ::fsfilcnt_t,
pub f_bsize: ::c_ulong,
pub f_flag: ::c_ulong,
pub f_frsize: ::c_ulong,
pub f_fsid: ::c_ulong,
pub f_namemax: ::c_ulong,
}
}
pub const EXIT_FAILURE: ::c_int = 1;
@ -520,6 +534,8 @@ extern {
-> ::c_int;
pub fn clock_gettime(clk_id: ::c_int, tp: *mut ::timespec) -> ::c_int;
pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char);
pub fn posix_fallocate(fd: ::c_int, offset: ::off_t,
len: ::off_t) -> ::c_int;
}
cfg_if! {

View File

@ -6,6 +6,8 @@ pub type blkcnt_t = i64;
pub type socklen_t = u32;
pub type sa_family_t = u8;
pub type pthread_t = ::uintptr_t;
pub type fsblkcnt_t = ::c_uint;
pub type fsfilcnt_t = ::c_uint;
s! {
pub struct sockaddr {
@ -102,6 +104,9 @@ pub const IPV6_V6ONLY: ::c_int = 27;
pub const FD_SETSIZE: usize = 1024;
pub const ST_RDONLY: ::c_ulong = 1;
pub const ST_NOSUID: ::c_ulong = 2;
f! {
pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () {
let fd = fd as usize;

View File

@ -92,6 +92,20 @@ s! {
pub st_birthtime: ::time_t,
pub st_birthtime_nsec: ::c_long,
}
pub struct statvfs {
pub f_bsize: ::c_ulong,
pub f_frsize: ::c_ulong,
pub f_blocks: ::fsblkcnt_t,
pub f_bfree: ::fsblkcnt_t,
pub f_bavail: ::fsblkcnt_t,
pub f_files: ::fsfilcnt_t,
pub f_ffree: ::fsfilcnt_t,
pub f_favail: ::fsfilcnt_t,
pub f_fsid: ::c_ulong,
pub f_flag: ::c_ulong,
pub f_namemax: ::c_ulong,
}
}
pub const EXIT_FAILURE : ::c_int = 1;

View File

@ -558,6 +558,8 @@ extern {
whence: ::c_int) -> ::c_int;
pub fn ftello(stream: *mut ::FILE) -> ::off_t;
pub fn timegm(tm: *mut ::tm) -> time_t;
pub fn statvfs(path: *const c_char, buf: *mut statvfs) -> ::c_int;
pub fn fstatvfs(fd: ::c_int, buf: *mut statvfs) -> ::c_int;
}
cfg_if! {

View File

@ -9,6 +9,8 @@ pub type ino64_t = u64;
pub type off64_t = i64;
pub type blkcnt64_t = i64;
pub type rlim64_t = u64;
pub type fsblkcnt_t = ::c_ulong;
pub type fsfilcnt_t = ::c_ulong;
pub enum fpos64_t {} // TODO: fill this out with a struct
@ -99,6 +101,23 @@ s! {
pub pw_dir: *mut ::c_char,
pub pw_shell: *mut ::c_char,
}
pub struct statvfs {
pub f_bsize: ::c_ulong,
pub f_frsize: ::c_ulong,
pub f_blocks: ::fsblkcnt_t,
pub f_bfree: ::fsblkcnt_t,
pub f_bavail: ::fsblkcnt_t,
pub f_files: ::fsfilcnt_t,
pub f_ffree: ::fsfilcnt_t,
pub f_favail: ::fsfilcnt_t,
pub f_fsid: ::c_ulong,
#[cfg(target_pointer_width = "32")]
pub __f_unused: ::c_int,
pub f_flag: ::c_ulong,
pub f_namemax: ::c_ulong,
__f_spare: [::c_int; 6],
}
}
pub const FILENAME_MAX: ::c_uint = 4096;
@ -218,6 +237,18 @@ pub const F_TEST: ::c_int = 3;
pub const F_TLOCK: ::c_int = 2;
pub const F_ULOCK: ::c_int = 0;
pub const ST_RDONLY: ::c_ulong = 1;
pub const ST_NOSUID: ::c_ulong = 2;
pub const ST_NODEV: ::c_ulong = 4;
pub const ST_NOEXEC: ::c_ulong = 8;
pub const ST_SYNCHRONOUS: ::c_ulong = 16;
pub const ST_MANDLOCK: ::c_ulong = 64;
pub const ST_WRITE: ::c_ulong = 128;
pub const ST_APPEND: ::c_ulong = 256;
pub const ST_IMMUTABLE: ::c_ulong = 512;
pub const ST_NOATIME: ::c_ulong = 1024;
pub const ST_NODIRATIME: ::c_ulong = 2048;
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
pub const MAP_32BIT: ::c_int = 0x0040;
@ -281,6 +312,12 @@ extern {
offset: ::off64_t,
whence: ::c_int) -> ::c_int;
pub fn ftello64(stream: *mut ::FILE) -> ::off64_t;
pub fn fallocate(fd: ::c_int, mode: ::c_int,
offset: ::off_t, len: ::off_t) -> ::c_int;
pub fn posix_fallocate(fd: ::c_int, offset: ::off_t,
len: ::off_t) -> ::c_int;
pub fn readahead(fd: ::c_int, offset: ::off64_t,
count: ::size_t) -> ::ssize_t;
}
cfg_if! {

View File

@ -179,6 +179,9 @@ pub const SIGCHLD: ::c_int = 17;
pub const SIGBUS: ::c_int = 7;
pub const SIG_SETMASK: ::c_int = 2;
pub const FALLOC_FL_KEEP_SIZE: ::c_int = 0x01;
pub const FALLOC_FL_PUNCH_HOLE: ::c_int = 0x02;
extern {
pub fn getnameinfo(sa: *const ::sockaddr,
salen: ::socklen_t,

View File

@ -21,6 +21,7 @@ pub const _SC_2_C_VERSION: ::c_int = 96;
pub const RUSAGE_THREAD: ::c_int = 1;
pub const O_ACCMODE: ::c_int = 3;
pub const RUSAGE_CHILDREN: ::c_int = -1;
pub const ST_RELATIME: ::c_ulong = 4096;
extern {
pub fn sysctl(name: *mut ::c_int,