This commit is contained in:
Paul Sajna
2018-03-04 22:34:47 -08:00
parent 3a07bc27c2
commit 151d873aba
6 changed files with 21 additions and 1 deletions
+6
View File
@@ -122,6 +122,12 @@ pub fn getuid() -> uid_t {
}
}
pub fn link(path1: *const c_char, path2: *const c_char) -> c_int {
unsafe {
syscall!(LINK, path1, path2) as c_int
}
}
#[cfg(target_arch = "x86_64")]
pub fn open(path: *const c_char, oflag: c_int, mode: mode_t) -> c_int {
unsafe {
+6
View File
@@ -92,6 +92,12 @@ pub fn getuid() -> uid_t {
syscall::getuid()? as pid_t
}
pub fn link(path1: const c_char, path2: const c_char) -> c_int {
let path1 = unsafe { c_str(path1) };
let path2 = unsafe { c_str(path2) };
syscall::link(path1, path2)? 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
@@ -261,7 +261,7 @@ pub extern "C" fn lchown(path: *const c_char, owner: uid_t, group: gid_t) -> c_i
#[no_mangle]
pub extern "C" fn link(path1: *const c_char, path2: *const c_char) -> c_int {
unimplemented!();
platform::link(path1, path2)
}
#[no_mangle]
+2
View File
@@ -11,6 +11,8 @@
/ftruncate
/ftruncate.out
/getid
/link
/link.out
/math
/printf
/write
+1
View File
@@ -9,6 +9,7 @@ BINS=\
fsync \
ftruncate \
getid \
link \
math \
printf \
write
+5
View File
@@ -0,0 +1,5 @@
#include <unistd.h>
int main(int argc, char** argv) {
int status = link("link.c", "link.out");
}