mkfifo and constants
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
+27
-1
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user