diff --git a/include/sys/types.h b/include/sys/types.h index 3efc6300b3afd8658afb6d7eba0bb6b4d979a0c5..3a466d2b2a4e3f79a79604ddfd89521ca65842ed 100644 --- a/include/sys/types.h +++ b/include/sys/types.h @@ -35,6 +35,8 @@ typedef int clockid_t; typedef void* timer_t; +typedef unsigned long int blkcnt_t; + #ifdef __linux__ #define _SC_PAGE_SIZE 30 #endif diff --git a/src/platform/src/linux/mod.rs b/src/platform/src/linux/mod.rs index bf9a6169b3435a67af4fbf25c7dc9dc52331cd72..86a883bc0a259bb14f639aaae495517c0ad04559 100644 --- a/src/platform/src/linux/mod.rs +++ b/src/platform/src/linux/mod.rs @@ -154,8 +154,8 @@ pub fn mkdir(path: *const c_char, mode: mode_t) -> c_int { e(unsafe { syscall!(MKDIRAT, AT_FDCWD, path, mode) }) as c_int } -pub fn mkfifo(path: *const c_char mode: mode_t) -> c_int { - e(unsafe { syscall!(MKNODAT, AT_FDCWD, path, mode, 0) }) +pub fn mkfifo(path: *const c_char, mode: mode_t) -> c_int { + e(unsafe { syscall!(MKNODAT, AT_FDCWD, path, mode, 0) }) as c_int } pub fn nanosleep(rqtp: *const timespec, rmtp: *mut timespec) -> c_int { diff --git a/src/platform/src/types.rs b/src/platform/src/types.rs index 1993edbe18af4952acf7e197fa7b293d40dbd9f6..29ed354d1b543470513c0f47cc2844176358fa06 100644 --- a/src/platform/src/types.rs +++ b/src/platform/src/types.rs @@ -59,6 +59,7 @@ pub type dev_t = usize; pub type ino_t = usize; pub type nlink_t = usize; pub type blksize_t = isize; +pub type blkcnt_t = u64; pub type useconds_t = i32; pub type suseconds_t = i64; @@ -98,4 +99,5 @@ pub struct stat { pub st_atim: time_t, pub st_mtim: time_t, pub st_ctim: time_t, + pub st_blocks: blkcnt_t, } diff --git a/src/stat/src/lib.rs b/src/stat/src/lib.rs index d2c3d04663f1d9a3bfe7ba4cec52c117b025127a..5b4a389d7d4dc287ee17f7d9f4f7a61f8982173a 100644 --- a/src/stat/src/lib.rs +++ b/src/stat/src/lib.rs @@ -6,13 +6,13 @@ extern crate platform; use platform::types::*; -pub const S_IFMT: c_int = 00170000; -pub const S_IFBLK: c_int = 0060000; -pub const S_IFCHR: c_int = 0020000; -pub const S_IFIFO: c_int = 0010000; -pub const S_IFREG: c_int = 0100000; -pub const S_IFDIR: c_int = 0040000; -pub const S_IFLNK: c_int = 0120000; +pub const S_IFMT: c_int = 00170000; +pub const S_IFBLK: c_int = 0060000; +pub const S_IFCHR: c_int = 0020000; +pub const S_IFIFO: c_int = 0010000; +pub const S_IFREG: c_int = 0100000; +pub const S_IFDIR: c_int = 0040000; +pub const S_IFLNK: c_int = 0120000; pub const S_IRWXU: c_int = 00700; pub const S_IRUSR: c_int = 00400; @@ -46,6 +46,7 @@ pub struct stat { pub st_atim: time_t, pub st_mtim: time_t, pub st_ctim: time_t, + pub st_blocks: blkcnt_t, } #[no_mangle] @@ -59,12 +60,12 @@ pub extern "C" fn fchmod(fildes: c_int, mode: mode_t) -> c_int { } #[no_mangle] -pub extern "C" fn fstat(fildes: c_int, buf: *mut stat) -> c_int { +pub extern "C" fn fstat(fildes: c_int, buf: *mut platform::types::stat) -> c_int { platform::fstat(fildes, buf) } #[no_mangle] -pub extern "C" fn lstat(path: *const c_char, buf: *mut stat) -> c_int { +pub extern "C" fn lstat(path: *const c_char, buf: *mut platform::types::stat) -> c_int { platform::lstat(path, buf) } @@ -84,7 +85,7 @@ pub extern "C" fn mknod(path: *const c_char, mode: mode_t, dev: dev_t) -> c_int } #[no_mangle] -pub extern "C" fn stat(file: *const c_char, buf: *mut stat) -> c_int { +pub extern "C" fn stat(file: *const c_char, buf: *mut platform::types::stat) -> c_int { platform::stat(file, buf) }