diff --git a/src/platform/src/linux/mod.rs b/src/platform/src/linux/mod.rs index 01d4fa232b2d6f0bb11693cc646bbd2d25de103b..7bf42be63d217a630330f19474e49e87a3739f76 100644 --- a/src/platform/src/linux/mod.rs +++ b/src/platform/src/linux/mod.rs @@ -142,6 +142,10 @@ 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 nanosleep(rqtp: *const timespec, rmtp: *mut timespec) -> c_int { e(unsafe { syscall!(NANOSLEEP, rqtp, rmtp) }) as c_int } diff --git a/src/platform/src/redox/mod.rs b/src/platform/src/redox/mod.rs index 998d3d091fc3bd47479bd8826def2a488474201b..4155f6276081f084c9da3c2023b192f0c63d2d89 100644 --- a/src/platform/src/redox/mod.rs +++ b/src/platform/src/redox/mod.rs @@ -1,6 +1,5 @@ use core::ptr; use core::slice; -use core::mem; use syscall; use syscall::flag::*; use syscall::data::TimeSpec as redox_timespec; @@ -199,6 +198,18 @@ pub fn mkdir(path: *const c_char, mode: mode_t) -> c_int { } } +pub fn mkfifo(path: *const c_char, mode: mode_t) -> c_int { + let flags = O_CREAT | MODE_FIFO | mode as usize & 0o777; + let path = unsafe { c_str(path) }; + match syscall::open(path, flags) { + Ok(fd) => { + let _ = syscall::close(fd); + 0 + } + Err(err) => e(Err(err)) as c_int, + } +} + pub fn nanosleep(rqtp: *const timespec, rmtp: *mut timespec) -> c_int { let redox_rqtp = unsafe { redox_timespec::from(&*rqtp) }; let mut redox_rmtp: redox_timespec; diff --git a/src/stat/src/lib.rs b/src/stat/src/lib.rs index 6e4232cd5477413fc841e517e0da942485d26fed..d2c3d04663f1d9a3bfe7ba4cec52c117b025127a 100644 --- a/src/stat/src/lib.rs +++ b/src/stat/src/lib.rs @@ -6,6 +6,32 @@ 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_IRWXU: c_int = 00700; +pub const S_IRUSR: c_int = 00400; +pub const S_IWUSR: c_int = 00200; +pub const S_IXUSR: c_int = 00100; + +pub const S_IRWXG: c_int = 00070; +pub const S_IRGRP: c_int = 00040; +pub const S_IWGRP: c_int = 00020; +pub const S_IXGRP: c_int = 00010; + +pub const S_IRWXO: c_int = 00007; +pub const S_IROTH: c_int = 00004; +pub const S_IWOTH: c_int = 00002; +pub const S_IXOTH: c_int = 00001; +pub const S_ISUID: c_int = 04000; +pub const S_ISGID: c_int = 02000; +pub const S_ISVTX: c_int = 01000; + #[repr(C)] pub struct stat { pub st_dev: dev_t, @@ -49,7 +75,7 @@ pub extern "C" fn mkdir(path: *const c_char, mode: mode_t) -> c_int { #[no_mangle] pub extern "C" fn mkfifo(path: *const c_char, mode: mode_t) -> c_int { - unimplemented!(); + platform::mkfifo(path, mode) } #[no_mangle]