Skip to content
Snippets Groups Projects
Commit 95ed0b59 authored by Paul Sajna's avatar Paul Sajna
Browse files

getcwd

parent b5192437
No related branches found
No related tags found
1 merge request!14implement some unistd
......@@ -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]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment