getcwd
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user