diff --git a/platform/src/linux/mod.rs b/platform/src/linux/mod.rs index d146fe10952ea8cf92917c33520dcd979e0f4684..20c1d59355a662b5f586413a29aca662e01ee02b 100644 --- a/platform/src/linux/mod.rs +++ b/platform/src/linux/mod.rs @@ -14,7 +14,7 @@ pub fn chdir(path: *const c_char) -> c_int { } } -pub fn chown(path: *const c_char, owner: usize, group: usize) -> c_int { +pub fn chown(path: *const c_char, owner: uid_t, group: gid_t) -> c_int { unsafe { syscall!(CHOWN, owner as u32, group as u32) as c_int } @@ -45,6 +45,12 @@ pub fn exit(status: c_int) -> ! { loop {} } +pub fn fchown(fildes: c_int, owner: uid_t, group: gid_t) -> c_int { + unsafe { + syscall!(FCHOWN, owner, group) as c_int + } +} + #[cfg(target_arch = "x86_64")] pub fn open(path: *const c_char, oflag: c_int, mode: mode_t) -> c_int { unsafe { diff --git a/platform/src/redox/mod.rs b/platform/src/redox/mod.rs index c0cc9b06f766db7fc5da21a3ec57f604a1953efd..02755a3c9edd692b456c949c7945e62e899be285 100644 --- a/platform/src/redox/mod.rs +++ b/platform/src/redox/mod.rs @@ -14,9 +14,9 @@ pub fn chdir(path: *const c_char) -> c_int { syscall::chdir(cstr_to_slice(path))? as c_int } -pub fn chown(path: *const c_char, owner: usize, group: usize) -> c_int { +pub fn chown(path: *const c_char, owner: uid_t, group: gid_t) -> c_int { let fd = syscall::open(cstr_to_slice(path)); - syscall::fchown(fd, owner as u32, group as u32)? as c_int + syscall::fchown(fd, owner, group)? as c_int pub fn close(fd: c_int) -> c_int { syscall::close(fd as usize); @@ -36,6 +36,10 @@ pub fn exit(status: c_int) -> ! { loop {} } +pub fn fchown(fd: c_int, owner: uid_t, group: gid_t) -> c_int { + syscall::fchown(owner, group)? 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 diff --git a/src/unistd/src/lib.rs b/src/unistd/src/lib.rs index 485a38debb797dd643b2d83d51183f501139db0c..2b7de078b47104805673391fc16e32ec20209207 100644 --- a/src/unistd/src/lib.rs +++ b/src/unistd/src/lib.rs @@ -131,7 +131,7 @@ pub extern "C" fn execvp(file: *const c_char, argv: *const *mut c_char) -> c_int #[no_mangle] pub extern "C" fn fchown(fildes: c_int, owner: uid_t, group: gid_t) -> c_int { - unimplemented!(); + platform::fchown(fildes, owner, group) } #[no_mangle]