|
@@ -1,6 +1,4 @@
|
|
|
|
|
|
-
|
|
|
-
|
|
|
use crate::unix::platform::pal::{e};
|
|
|
use crate::unix::c_str::CStr;
|
|
|
use crate::unix::platform::pal::e;
|
|
@@ -32,18 +30,18 @@ pub extern "C" fn chdir(dir: *const ::c_char) -> ::c_int {
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn chmod(_path: *const c_char, _mode: mode_t) -> ::c_int{
|
|
|
- 0
|
|
|
+pub extern "C" fn chmod(_path: *const c_char, _mode: mode_t) -> ::c_int {
|
|
|
+ 0
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn chown(_path: *const ::c_char, _uid: uid_t, _gid: gid_t) -> ::c_int{
|
|
|
- 0
|
|
|
+pub extern "C" fn chown(_path: *const ::c_char, _uid: uid_t, _gid: gid_t) -> ::c_int {
|
|
|
+ 0
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn clock_gettime(_clk_id: ::clockid_t, _tp: *mut ::timespec) -> ::c_int{
|
|
|
- -ENOSYS
|
|
|
+pub extern "C" fn clock_gettime(_clk_id: ::clockid_t, _tp: *mut ::timespec) -> ::c_int {
|
|
|
+ -ENOSYS
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
@@ -84,28 +82,28 @@ pub extern "C" fn exit(status: ::c_int) -> ! {
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn fchdir(_dirfd: ::c_int) -> ::c_int{
|
|
|
- unimplemented!()
|
|
|
+pub extern "C" fn fchdir(_dirfd: ::c_int) -> ::c_int {
|
|
|
+ unimplemented!()
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn fchmod(_fd: ::c_int, _mode: mode_t) -> ::c_int{
|
|
|
- 0
|
|
|
+pub extern "C" fn fchmod(_fd: ::c_int, _mode: mode_t) -> ::c_int {
|
|
|
+ 0
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn fchown(_fd: ::c_int, _owner: ::uid_t, _group: ::gid_t) -> ::c_int{
|
|
|
- 0
|
|
|
+pub extern "C" fn fchown(_fd: ::c_int, _owner: ::uid_t, _group: ::gid_t) -> ::c_int {
|
|
|
+ 0
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn flock(_fd: ::c_int, _operation: ::c_int) -> ::c_int{
|
|
|
- 0
|
|
|
+pub extern "C" fn flock(_fd: ::c_int, _operation: ::c_int) -> ::c_int {
|
|
|
+ 0
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn fstatvfs(_fd: ::c_int, _buf: *mut statvfs) -> ::c_int{
|
|
|
- unimplemented!()
|
|
|
+pub extern "C" fn fstatvfs(_fd: ::c_int, _buf: *mut statvfs) -> ::c_int {
|
|
|
+ unimplemented!()
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
@@ -119,13 +117,13 @@ pub extern "C" fn fork() -> ::pid_t {
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn fpath(_filedes: ::c_int, _name:*const ::c_char) -> c_long{
|
|
|
- unimplemented!()
|
|
|
+pub extern "C" fn fpath(_filedes: ::c_int, _name: *const ::c_char) -> c_long {
|
|
|
+ unimplemented!()
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn fsync(_fd: ::c_int) -> ::c_int{
|
|
|
- 0
|
|
|
+pub extern "C" fn fsync(_fd: ::c_int) -> ::c_int {
|
|
|
+ 0
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
@@ -134,54 +132,46 @@ pub extern "C" fn ftruncate(fd: ::c_int, length: off_t) -> ::c_int {
|
|
|
}
|
|
|
|
|
|
pub extern "C" fn futex(_addr: *mut ::c_int, _op: ::c_int, _val: ::c_int, _val2: usize) -> ::c_int {
|
|
|
- // unsafe { syscall!(FUTEX, addr, op, val, val2, 0, 0) as ::c_int }
|
|
|
- unimplemented!()
|
|
|
+ // unsafe { syscall!(FUTEX, addr, op, val, val2, 0, 0) as ::c_int }
|
|
|
+ unimplemented!()
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn futimens(_fd: ::c_int, _times: *const ::timespec) -> ::c_int{
|
|
|
- unimplemented!()
|
|
|
+pub extern "C" fn futimens(_fd: ::c_int, _times: *const ::timespec) -> ::c_int {
|
|
|
+ unimplemented!()
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
pub extern "C" fn utimensat(
|
|
|
- _dirfd: ::c_int,
|
|
|
- _path: *const ::c_char,
|
|
|
- _times: *const ::timespec,
|
|
|
- _flag: ::c_int,
|
|
|
-) -> ::c_int{
|
|
|
- unimplemented!()
|
|
|
+ _dirfd: ::c_int,
|
|
|
+ _path: *const ::c_char,
|
|
|
+ _times: *const ::timespec,
|
|
|
+ _flag: ::c_int,
|
|
|
+) -> ::c_int {
|
|
|
+ unimplemented!()
|
|
|
}
|
|
|
|
|
|
//#[no_mangle]
|
|
|
-pub extern "C" fn getcwd(buf: *mut ::c_char, size: ::size_t) -> *mut ::c_char{
|
|
|
- // if e(unsafe { syscall!(GETCWD, buf, size) }) == !0 {
|
|
|
- // ptr::null_mut()
|
|
|
- // } else {
|
|
|
- // buf
|
|
|
- // }
|
|
|
- // 临时实现,设置所有的cwd为根目录
|
|
|
- if size > 2 {
|
|
|
- unsafe {
|
|
|
- *buf = b'/' as ::c_char;
|
|
|
- *buf.add(1) = b'\0' as ::c_char;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- buf
|
|
|
-}
|
|
|
-
|
|
|
-#[no_mangle]
|
|
|
-pub extern "C" fn getdents(
|
|
|
- _fd: ::c_int,
|
|
|
- _dirents: *mut dirent,
|
|
|
- _bytes: usize) -> ::c_int{
|
|
|
- unimplemented!()
|
|
|
+pub extern "C" fn getcwd(buf: *mut ::c_char, size: ::size_t) -> *mut ::c_char {
|
|
|
+ // if e(unsafe { syscall!(GETCWD, buf, size) }) == !0 {
|
|
|
+ // ptr::null_mut()
|
|
|
+ // } else {
|
|
|
+ // buf
|
|
|
+ // }
|
|
|
+ // 临时实现,设置所有的cwd为根目录
|
|
|
+ if size > 2 {
|
|
|
+ unsafe {
|
|
|
+ *buf = b'/' as ::c_char;
|
|
|
+ *buf.add(1) = b'\0' as ::c_char;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ buf
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
pub extern "C" fn getdents(fd: ::c_int, dirents: *mut dirent, bytes: usize) -> ::c_int {
|
|
|
- unsafe { syscall!(SYS_GET_DENTS, dirents, bytes) as ::c_int }
|
|
|
+ unsafe { syscall!(SYS_GET_DENTS, fd, dirents, bytes) as ::c_int }
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
@@ -205,8 +195,8 @@ pub extern "C" fn getpagesize() -> usize {
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn getpgid(_pid: ::pid_t) -> ::pid_t{
|
|
|
- 0
|
|
|
+pub extern "C" fn getpgid(_pid: ::pid_t) -> ::pid_t {
|
|
|
+ 0
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
@@ -220,13 +210,13 @@ pub extern "C" fn getppid() -> ::pid_t {
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn getrlimit(_resource: ::c_int, _rlim: *mut ::rlimit) -> ::c_int{
|
|
|
- unimplemented!()
|
|
|
+pub extern "C" fn getrlimit(_resource: ::c_int, _rlim: *mut ::rlimit) -> ::c_int {
|
|
|
+ unimplemented!()
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn getsid(_pid: ::pid_t) -> ::pid_t{
|
|
|
- 0
|
|
|
+pub extern "C" fn getsid(_pid: ::pid_t) -> ::pid_t {
|
|
|
+ 0
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
@@ -245,13 +235,13 @@ pub extern "C" fn getuid() -> uid_t {
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn lchown(_path: *const ::c_char, _uid: uid_t, _gid: gid_t) -> ::c_int{
|
|
|
- 0
|
|
|
+pub extern "C" fn lchown(_path: *const ::c_char, _uid: uid_t, _gid: gid_t) -> ::c_int {
|
|
|
+ 0
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn link(_src: *const ::c_char, _dst: *const ::c_char) -> ::c_int{
|
|
|
- unimplemented!()
|
|
|
+pub extern "C" fn link(_src: *const ::c_char, _dst: *const ::c_char) -> ::c_int {
|
|
|
+ unimplemented!()
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
@@ -265,18 +255,18 @@ pub extern "C" fn mkdir(path: *const ::c_char, mode: mode_t) -> ::c_int {
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn mkfifo(_path: *const ::c_char, _mode: mode_t) -> ::c_int{
|
|
|
- unimplemented!()
|
|
|
+pub extern "C" fn mkfifo(_path: *const ::c_char, _mode: mode_t) -> ::c_int {
|
|
|
+ unimplemented!()
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn mlock(_addr: *const ::c_void, _len: ::size_t) -> ::c_int{
|
|
|
- unimplemented!()
|
|
|
+pub extern "C" fn mlock(_addr: *const ::c_void, _len: ::size_t) -> ::c_int {
|
|
|
+ unimplemented!()
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn mlockall(_flags: ::c_int) -> ::c_int{
|
|
|
- unimplemented!()
|
|
|
+pub extern "C" fn mlockall(_flags: ::c_int) -> ::c_int {
|
|
|
+ unimplemented!()
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
@@ -297,13 +287,13 @@ pub extern "C" fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) ->
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn msync(_addr: *mut ::c_void, _len: ::size_t, _flags: ::c_int) -> ::c_int{
|
|
|
- unimplemented!()
|
|
|
+pub extern "C" fn msync(_addr: *mut ::c_void, _len: ::size_t, _flags: ::c_int) -> ::c_int {
|
|
|
+ unimplemented!()
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn munlock(_addr: *const ::c_void, _len: ::size_t) -> ::c_int{
|
|
|
- unimplemented!()
|
|
|
+pub extern "C" fn munlock(_addr: *const ::c_void, _len: ::size_t) -> ::c_int {
|
|
|
+ unimplemented!()
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
@@ -336,8 +326,8 @@ pub extern "C" fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int {
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub unsafe extern "C" fn pte_clone(_stack: *mut usize) -> ::pid_t{
|
|
|
- unimplemented!()
|
|
|
+pub unsafe extern "C" fn pte_clone(_stack: *mut usize) -> ::pid_t {
|
|
|
+ unimplemented!()
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
@@ -345,13 +335,13 @@ pub extern "C" fn read(fd: ::c_int, buf: *mut ::c_void, count: ::size_t) -> ::ss
|
|
|
e(unsafe { syscall!(SYS_READ, fd, buf, count) }) as ::ssize_t
|
|
|
}
|
|
|
|
|
|
-pub extern "C" fn readlink(_path: *const c_char, _buf: *mut c_char, _bufsz: ::size_t) -> ::ssize_t{
|
|
|
+pub extern "C" fn readlink(_path: *const c_char, _buf: *mut c_char, _bufsz: ::size_t) -> ::ssize_t {
|
|
|
unimplemented!()
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn rename(_oldname: *const ::c_char, _newname: *const ::c_char) -> ::c_int{
|
|
|
- unimplemented!()
|
|
|
+pub extern "C" fn rename(_oldname: *const ::c_char, _newname: *const ::c_char) -> ::c_int {
|
|
|
+ unimplemented!()
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
@@ -365,33 +355,33 @@ pub extern "C" fn sched_yield() -> ::c_int {
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn setpgid(_pid: ::pid_t, _pgid: ::pid_t) -> ::c_int{
|
|
|
- unimplemented!()
|
|
|
+pub extern "C" fn setpgid(_pid: ::pid_t, _pgid: ::pid_t) -> ::c_int {
|
|
|
+ unimplemented!()
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn setregid(_rgid: gid_t, _egid: gid_t) -> ::c_int{
|
|
|
- unimplemented!()
|
|
|
+pub extern "C" fn setregid(_rgid: gid_t, _egid: gid_t) -> ::c_int {
|
|
|
+ unimplemented!()
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn setreuid(_ruid: uid_t, _euid: uid_t) -> ::c_int{
|
|
|
- unimplemented!()
|
|
|
+pub extern "C" fn setreuid(_ruid: uid_t, _euid: uid_t) -> ::c_int {
|
|
|
+ unimplemented!()
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn symlink(_path1: *const ::c_char, _path2: *const ::c_char) -> ::c_int{
|
|
|
- unimplemented!()
|
|
|
+pub extern "C" fn symlink(_path1: *const ::c_char, _path2: *const ::c_char) -> ::c_int {
|
|
|
+ unimplemented!()
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn umask(_mask: mode_t) -> mode_t{
|
|
|
- unimplemented!()
|
|
|
+pub extern "C" fn umask(_mask: mode_t) -> mode_t {
|
|
|
+ unimplemented!()
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn uname(_buf: *mut ::utsname) -> ::c_int{
|
|
|
- unimplemented!()
|
|
|
+pub extern "C" fn uname(_buf: *mut ::utsname) -> ::c_int {
|
|
|
+ unimplemented!()
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|