sys_resource: get/setpriority implementations.

This commit is contained in:
David Carlier
2023-04-15 07:15:19 +01:00
parent d5c88c7ca6
commit 7f36abc33c
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
}
@@ -452,6 +456,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;
@@ -163,6 +165,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?
@@ -785,6 +791,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
}