Implement futimens
This commit is contained in:
@@ -103,6 +103,10 @@ pub fn ftruncate(fildes: c_int, length: off_t) -> c_int {
|
||||
e(unsafe { syscall!(FTRUNCATE, fildes, length) }) as c_int
|
||||
}
|
||||
|
||||
pub fn futimens(fd: c_int, times: *const timespec) -> c_int {
|
||||
e(unsafe { syscall!(UTIMENSAT, fd, ptr::null::<c_char>(), times, 0) }) as c_int
|
||||
}
|
||||
|
||||
pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char {
|
||||
if e(unsafe { syscall!(GETCWD, buf, size) }) == !0 {
|
||||
ptr::null_mut()
|
||||
|
||||
@@ -246,9 +246,18 @@ pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int {
|
||||
(*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 = redox_buf.st_atime as time_t;
|
||||
(*buf).st_mtim = redox_buf.st_mtime as time_t;
|
||||
(*buf).st_ctim = redox_buf.st_ctime as time_t;
|
||||
(*buf).st_atim = timespec {
|
||||
tv_sec: redox_buf.st_atime as time_t,
|
||||
tv_nsec: 0
|
||||
};
|
||||
(*buf).st_mtim = timespec {
|
||||
tv_sec: redox_buf.st_mtime as time_t,
|
||||
tv_nsec: 0
|
||||
};
|
||||
(*buf).st_ctim = timespec {
|
||||
tv_sec: redox_buf.st_ctime as time_t,
|
||||
tv_nsec: 0
|
||||
};
|
||||
}
|
||||
}
|
||||
0
|
||||
@@ -265,6 +274,14 @@ pub fn ftruncate(fd: c_int, len: off_t) -> c_int {
|
||||
e(syscall::ftruncate(fd as usize, len as usize)) as c_int
|
||||
}
|
||||
|
||||
pub fn futimens(fd: c_int, times: *const timespec) -> c_int {
|
||||
let times = [
|
||||
unsafe { redox_timespec::from(&*times) },
|
||||
unsafe { redox_timespec::from(&*times.offset(1)) }
|
||||
];
|
||||
e(syscall::futimens(fd as usize, ×)) as c_int
|
||||
}
|
||||
|
||||
pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char {
|
||||
let buf_slice = unsafe { slice::from_raw_parts_mut(buf as *mut u8, size as usize) };
|
||||
if e(syscall::getcwd(buf_slice)) == !0 {
|
||||
|
||||
@@ -112,14 +112,14 @@ pub struct stat {
|
||||
pub st_blksize: blksize_t,
|
||||
pub st_blocks: blkcnt_t,
|
||||
|
||||
pub st_atim: time_t,
|
||||
pub st_mtim: time_t,
|
||||
pub st_ctim: time_t,
|
||||
pub st_atim: timespec,
|
||||
pub st_mtim: timespec,
|
||||
pub st_ctim: timespec,
|
||||
|
||||
// Compared to glibc, our struct is for some reason 48 bytes too small.
|
||||
// Compared to glibc, our struct is for some reason 24 bytes too small.
|
||||
// Accessing atime works, so clearly the struct isn't incorrect...
|
||||
// This works.
|
||||
pub _pad: [c_char; 48]
|
||||
pub _pad: [c_char; 24]
|
||||
}
|
||||
|
||||
pub const AF_INET: c_int = 2;
|
||||
|
||||
Reference in New Issue
Block a user