Merge branch 'getsetpriority_impl' into 'master'

sys_resource: get/setpriority implementations.

See merge request redox-os/relibc!369
This commit is contained in:
Jeremy Soller
2023-04-17 14:35:36 +00:00
4 changed files with 41 additions and 4 deletions
+8
View File
@@ -259,6 +259,10 @@ impl Pal for Sys {
e(unsafe { syscall!(GETPPID) }) as pid_t
}
fn getpriority(which: c_int, who: id_t) -> c_int {
e(unsafe { syscall!(GETPRIORITY, which, who) }) as c_int
}
fn getrandom(buf: &mut [u8], flags: c_uint) -> ssize_t {
e(unsafe { syscall!(GETRANDOM, buf.as_mut_ptr(), buf.len(), flags) }) as ssize_t
}
@@ -456,6 +460,10 @@ impl Pal for Sys {
e(unsafe { syscall!(SETPGID, pid, pgid) }) as c_int
}
fn setpriority(which: c_int, who: id_t, prio: c_int) -> c_int {
e(unsafe { syscall!(SETPRIORITY, which, who, prio) }) as c_int
}
fn setregid(rgid: gid_t, egid: gid_t) -> c_int {
e(unsafe { syscall!(SETREGID, rgid, egid) }) as c_int
}
+4
View File
@@ -96,6 +96,8 @@ pub trait Pal {
fn getppid() -> pid_t;
fn getpriority(which: c_int, who: id_t) -> c_int;
fn getrandom(buf: &mut [u8], flags: c_uint) -> ssize_t;
unsafe fn getrlimit(resource: c_int, rlim: *mut rlimit) -> c_int;
@@ -165,6 +167,8 @@ pub trait Pal {
fn setpgid(pid: pid_t, pgid: pid_t) -> c_int;
fn setpriority(which: c_int, who: id_t, prio: c_int) -> c_int;
fn setregid(rgid: gid_t, egid: gid_t) -> c_int;
fn setreuid(ruid: uid_t, euid: uid_t) -> c_int;
+12
View File
@@ -499,6 +499,12 @@ impl Pal for Sys {
e(syscall::getppid()) as pid_t
}
fn getpriority(which: c_int, who: id_t) -> c_int {
// TODO
unsafe { errno = ENOSYS };
-1
}
fn getrandom(buf: &mut [u8], flags: c_uint) -> ssize_t {
//TODO: make this a system call?
@@ -790,6 +796,12 @@ impl Pal for Sys {
e(syscall::setpgid(pid as usize, pgid as usize)) as c_int
}
fn setpriority(which: c_int, who: id_t, prio: c_int) -> c_int {
// TODO
unsafe { errno = ENOSYS };
-1
}
fn setregid(rgid: gid_t, egid: gid_t) -> c_int {
e(syscall::setregid(rgid as usize, egid as usize)) as c_int
}