ftruncate

This commit is contained in:
Paul Sajna
2018-03-04 09:24:33 -08:00
parent 3ad7c62601
commit b5192437c3
3 changed files with 11 additions and 1 deletions
+6
View File
@@ -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 {
+4
View File
@@ -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
+1 -1
View File
@@ -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]