This commit is contained in:
Paul Sajna
2018-03-04 09:35:38 -08:00
parent b5192437c3
commit 95ed0b59bd
3 changed files with 14 additions and 1 deletions
+7
View File
@@ -69,6 +69,13 @@ pub fn ftruncate(fildes: c_int, length: off_t) -> c_int {
}
}
pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char {
unsafe {
syscall!(GETCWD, buf, size);
buf as *mut c_char
}
}
#[cfg(target_arch = "x86_64")]
pub fn open(path: *const c_char, oflag: c_int, mode: mode_t) -> c_int {
unsafe {
+6
View File
@@ -55,6 +55,12 @@ pub fn ftruncate(fd: c_int, len: off_t) -> {
syscall::ftruncate(fd as usize, len as usize)? as c_int
}
pub fn getcwd(buf: *mut c_char, size: size_t) -> {
// XXX: do something with size maybe
let rbuf = unsafe { c_str(buf) };
syscall::getcwd(rbuf)? 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
@@ -166,7 +166,7 @@ pub extern "C" fn ftruncate(fildes: c_int, length: off_t) -> c_int {
#[no_mangle]
pub extern "C" fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char {
unimplemented!();
platform::getcwd(buf, size)
}
#[no_mangle]