link
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
/ftruncate
|
||||
/ftruncate.out
|
||||
/getid
|
||||
/link
|
||||
/link.out
|
||||
/math
|
||||
/printf
|
||||
/write
|
||||
|
||||
@@ -9,6 +9,7 @@ BINS=\
|
||||
fsync \
|
||||
ftruncate \
|
||||
getid \
|
||||
link \
|
||||
math \
|
||||
printf \
|
||||
write
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int status = link("link.c", "link.out");
|
||||
}
|
||||
Reference in New Issue
Block a user