Implement sys/file.h

This commit is contained in:
jD91mZM2
2018-07-30 10:04:58 +02:00
parent d3e4fa71a5
commit 2a303c4b60
8 changed files with 59 additions and 2 deletions
+4
View File
@@ -84,6 +84,10 @@ pub fn fchown(fildes: c_int, owner: uid_t, group: gid_t) -> c_int {
e(unsafe { syscall!(FCHOWN, fildes, owner, group) }) as c_int
}
pub fn flock(fd: c_int, operation: c_int) -> c_int {
e(unsafe { syscall!(FLOCK, fd, operation) }) as c_int
}
pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int {
let empty_cstr: *const c_char = unsafe { ::cstr_from_bytes_with_nul_unchecked(b"\0") };
e(unsafe { syscall!(NEWFSTATAT, fildes, empty_cstr, buf, AT_EMPTY_PATH) }) as c_int
+5
View File
@@ -226,6 +226,11 @@ pub fn fcntl(fd: c_int, cmd: c_int, args: c_int) -> c_int {
e(syscall::fcntl(fd as usize, cmd as usize, args as usize)) as c_int
}
pub fn flock(_fd: c_int, _operation: c_int) -> c_int {
// TODO: Redox does not have file locking yet
0
}
pub fn fork() -> pid_t {
e(unsafe { syscall::clone(0) }) as pid_t
}
+1
View File
@@ -1,3 +1,4 @@
use core::mem;
#[cfg(target_os = "redox")]
use syscall::data::TimeSpec as redox_timespec;
// Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help enable