Paul Sajna %!s(int64=7) %!d(string=hai) anos
pai
achega
c7e9ec8ae2
Modificáronse 4 ficheiros con 17 adicións e 12 borrados
  1. 2 0
      include/sys/types.h
  2. 2 2
      src/platform/src/linux/mod.rs
  3. 2 0
      src/platform/src/types.rs
  4. 11 10
      src/stat/src/lib.rs

+ 2 - 0
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

+ 2 - 2
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 {

+ 2 - 0
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,
 }

+ 11 - 10
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)
 }