Add getgroups/setgroups (stub on redox)

This commit is contained in:
Jeremy Soller
2023-09-13 11:16:59 -06:00
parent 13f22d72c6
commit afdc26f9cc
4 changed files with 34 additions and 3 deletions
+8 -3
View File
@@ -321,9 +321,9 @@ pub extern "C" fn getgid() -> gid_t {
Sys::getgid()
}
// #[no_mangle]
pub extern "C" fn getgroups(gidsetsize: c_int, grouplist: *mut gid_t) -> c_int {
unimplemented!();
#[no_mangle]
pub unsafe extern "C" fn getgroups(size: c_int, list: *mut gid_t) -> c_int {
Sys::getgroups(size, list)
}
// #[no_mangle]
@@ -620,6 +620,11 @@ pub extern "C" fn setgid(gid: gid_t) -> c_int {
Sys::setregid(gid, gid)
}
#[no_mangle]
pub unsafe extern "C" fn setgroups(size: size_t, list: *const gid_t) -> c_int {
Sys::setgroups(size, list)
}
#[no_mangle]
pub extern "C" fn setpgid(pid: pid_t, pgid: pid_t) -> c_int {
Sys::setpgid(pid, pgid)
+8
View File
@@ -277,6 +277,10 @@ impl Pal for Sys {
e(unsafe { syscall!(GETGID) }) as gid_t
}
unsafe fn getgroups(size: c_int, list: *mut gid_t) -> c_int {
e(unsafe { syscall!(GETGROUPS, size, list) })
}
fn getpagesize() -> usize {
4096
}
@@ -508,6 +512,10 @@ impl Pal for Sys {
e(unsafe { syscall!(SCHED_YIELD) }) as c_int
}
unsafe fn setgroups(size: size_t, list: *const gid_t) -> c_int {
e(unsafe { syscall!(SETGROUPS, size, list) })
}
fn setpgid(pid: pid_t, pgid: pid_t) -> c_int {
e(unsafe { syscall!(SETPGID, pid, pgid) }) as c_int
}
+4
View File
@@ -98,6 +98,8 @@ pub trait Pal {
fn getgid() -> gid_t;
unsafe fn getgroups(size: c_int, list: *mut gid_t) -> c_int;
/* Note that this is distinct from the legacy POSIX function
* getpagesize(), which returns a c_int. On some Linux platforms,
* page size may be determined through a syscall ("getpagesize"). */
@@ -184,6 +186,8 @@ pub trait Pal {
fn sched_yield() -> c_int;
unsafe fn setgroups(size: size_t, list: *const gid_t) -> c_int;
fn setpgid(pid: pid_t, pgid: pid_t) -> c_int;
fn setpriority(which: c_int, who: id_t, prio: c_int) -> c_int;
+14
View File
@@ -504,6 +504,13 @@ impl Pal for Sys {
e(syscall::getgid()) as gid_t
}
unsafe fn getgroups(size: c_int, list: *mut gid_t) -> c_int {
// TODO
eprintln!("relibc getgroups({}, {:p}): not implemented", size, list);
unsafe { errno = ENOSYS };
-1
}
fn getpagesize() -> usize {
PAGE_SIZE
}
@@ -827,6 +834,13 @@ impl Pal for Sys {
e(syscall::sched_yield()) as c_int
}
unsafe fn setgroups(size: size_t, list: *const gid_t) -> c_int {
// TODO
eprintln!("relibc setgroups({}, {:p}): not implemented", size, list);
unsafe { errno = ENOSYS };
-1
}
fn setpgid(pid: pid_t, pgid: pid_t) -> c_int {
e(syscall::setpgid(pid as usize, pgid as usize)) as c_int
}