mkfifo and constants

This commit is contained in:
Paul Sajna
2018-03-26 15:47:36 -07:00
parent 35dbc8d351
commit cafb76abdd
3 changed files with 43 additions and 2 deletions
+4
View File
@@ -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
}
+12 -1
View File
@@ -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;