Merge remote-tracking branch 'origin/truncate-n-mkfifo'

This commit is contained in:
Jeremy Soller
2020-01-20 11:17:15 -07:00
11 changed files with 152 additions and 30 deletions
+2 -2
View File
@@ -4,7 +4,7 @@ use core_io::Write;
use super::{errno, types::*, Pal};
use crate::{
c_str::CStr,
header::{dirent::dirent, signal::SIGCHLD},
header::{dirent::dirent, signal::SIGCHLD, sys_stat::S_IFIFO},
};
// use header::sys_resource::rusage;
use crate::header::{
@@ -292,7 +292,7 @@ impl Pal for Sys {
}
fn mkfifo(path: &CStr, mode: mode_t) -> c_int {
e(unsafe { syscall!(MKNODAT, AT_FDCWD, path.as_ptr(), mode, 0) }) as c_int
e(unsafe { syscall!(MKNODAT, AT_FDCWD, path.as_ptr(), mode | S_IFIFO, 0) }) as c_int
}
unsafe fn mmap(
+23 -25
View File
@@ -319,31 +319,29 @@ impl Pal for Sys {
let mut redox_buf: redox_stat = redox_stat::default();
match e(syscall::fstat(fildes as usize, &mut redox_buf)) {
0 => {
unsafe {
if !buf.is_null() {
(*buf).st_dev = redox_buf.st_dev as dev_t;
(*buf).st_ino = redox_buf.st_ino as ino_t;
(*buf).st_nlink = redox_buf.st_nlink as nlink_t;
(*buf).st_mode = redox_buf.st_mode as mode_t;
(*buf).st_uid = redox_buf.st_uid as uid_t;
(*buf).st_gid = redox_buf.st_gid as gid_t;
// TODO st_rdev
(*buf).st_rdev = 0;
(*buf).st_size = redox_buf.st_size as off_t;
(*buf).st_blksize = redox_buf.st_blksize as blksize_t;
(*buf).st_atim = timespec {
tv_sec: redox_buf.st_atime as time_t,
tv_nsec: redox_buf.st_atime_nsec as c_long,
};
(*buf).st_mtim = timespec {
tv_sec: redox_buf.st_mtime as time_t,
tv_nsec: redox_buf.st_mtime_nsec as c_long,
};
(*buf).st_ctim = timespec {
tv_sec: redox_buf.st_ctime as time_t,
tv_nsec: redox_buf.st_ctime_nsec as c_long,
};
}
if let Some(buf) = unsafe { buf.as_mut() } {
buf.st_dev = redox_buf.st_dev as dev_t;
buf.st_ino = redox_buf.st_ino as ino_t;
buf.st_nlink = redox_buf.st_nlink as nlink_t;
buf.st_mode = redox_buf.st_mode as mode_t;
buf.st_uid = redox_buf.st_uid as uid_t;
buf.st_gid = redox_buf.st_gid as gid_t;
// TODO st_rdev
buf.st_rdev = 0;
buf.st_size = redox_buf.st_size as off_t;
buf.st_blksize = redox_buf.st_blksize as blksize_t;
buf.st_atim = timespec {
tv_sec: redox_buf.st_atime as time_t,
tv_nsec: redox_buf.st_atime_nsec as c_long,
};
buf.st_mtim = timespec {
tv_sec: redox_buf.st_mtime as time_t,
tv_nsec: redox_buf.st_mtime_nsec as c_long,
};
buf.st_ctim = timespec {
tv_sec: redox_buf.st_ctime as time_t,
tv_nsec: redox_buf.st_ctime_nsec as c_long,
};
}
0
}