ftruncate
This commit is contained in:
@@ -63,6 +63,12 @@ pub fn fsync(fildes: c_int) -> c_int {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ftruncate(fildes: c_int, length: off_t) -> c_int {
|
||||
unsafe {
|
||||
syscall!(FTRUNCATE, fildes, length) as c_int
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
pub fn open(path: *const c_char, oflag: c_int, mode: mode_t) -> c_int {
|
||||
unsafe {
|
||||
|
||||
@@ -51,6 +51,10 @@ pub fn fsync(fd: c_int) -> c_int {
|
||||
syscall::fsync(fd as usize)? as c_int
|
||||
}
|
||||
|
||||
pub fn ftruncate(fd: c_int, len: off_t) -> {
|
||||
syscall::ftruncate(fd as usize, len as usize)? as c_int
|
||||
}
|
||||
|
||||
pub fn open(path: *const c_char, oflag: c_int, mode: mode_t) -> c_int {
|
||||
let path = unsafe { c_str(path) };
|
||||
syscall::open(path, (oflag as usize) | (mode as usize)).unwrap() as c_int
|
||||
|
||||
@@ -161,7 +161,7 @@ pub extern "C" fn fsync(fildes: c_int) -> c_int {
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn ftruncate(fildes: c_int, length: off_t) -> c_int {
|
||||
unimplemented!();
|
||||
platform::ftruncate(fildes, length)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
||||
Reference in New Issue
Block a user