Commit 047e514e authored by Mateusz Mikuła's avatar Mateusz Mikuła

Implement {get,set}groups for Linux

parent c85145b5
Pipeline #5315 failed with stages
in 7 minutes and 24 seconds
//! grp implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/grp.h.html
use platform::types::*;
use platform::{Pal, Sys};
#[repr(C)]
pub struct group {
......@@ -57,6 +58,11 @@ pub extern "C" fn setgrent() {
unimplemented!();
}
#[no_mangle]
pub extern "C" fn setgroups(gidsetsize: c_int, grouplist: *mut gid_t) -> c_int {
Sys::setgroups(gidsetsize, grouplist)
}
/*
#[no_mangle]
pub extern "C" fn func(args) -> c_int {
......
......@@ -307,9 +307,9 @@ pub extern "C" fn getgid() -> gid_t {
Sys::getgid()
}
// #[no_mangle]
#[no_mangle]
pub extern "C" fn getgroups(gidsetsize: c_int, grouplist: *mut gid_t) -> c_int {
unimplemented!();
Sys::getgroups(gidsetsize, grouplist)
}
// #[no_mangle]
......
......@@ -239,6 +239,10 @@ impl Pal for Sys {
e(unsafe { syscall!(GETGID) }) as gid_t
}
fn getgroups(gidsetsize: c_int, grouplist: *mut gid_t) -> c_int {
e(unsafe { syscall!(GETGROUPS, gidsetsize, grouplist) }) as gid_t
}
fn getpgid(pid: pid_t) -> pid_t {
e(unsafe { syscall!(GETPGID, pid) }) as pid_t
}
......@@ -391,6 +395,10 @@ impl Pal for Sys {
e(unsafe { syscall!(SCHED_YIELD) }) as c_int
}
fn setgroups(gidsetsize: c_int, grouplist: *mut gid_t) -> c_int {
e(unsafe { syscall!(SETGROUPS, gidsetsize, grouplist) }) as c_int
}
fn setpgid(pid: pid_t, pgid: pid_t) -> c_int {
e(unsafe { syscall!(SETPGID, pid, pgid) }) as c_int
}
......
......@@ -77,6 +77,8 @@ pub trait Pal {
fn getgid() -> gid_t;
fn getgroups(gidsetsize: c_int, grouplist: *mut gid_t) -> c_int;
fn getpgid(pid: pid_t) -> pid_t;
fn getpid() -> pid_t;
......@@ -128,6 +130,8 @@ pub trait Pal {
fn sched_yield() -> c_int;
fn setgroups(gidsetsize: c_int, grouplist: *mut gid_t) -> c_int;
fn setpgid(pid: pid_t, pgid: pid_t) -> c_int;
fn setregid(rgid: gid_t, egid: gid_t) -> c_int;
......
......@@ -530,6 +530,10 @@ impl Pal for Sys {
e(syscall::getgid()) as gid_t
}
fn getgroups(gidsetsize: c_int, grouplist: *mut gid_t) -> c_int {
unimplemented!()
}
fn getpgid(pid: pid_t) -> pid_t {
e(syscall::getpgid(pid as usize)) as pid_t
}
......@@ -782,6 +786,10 @@ impl Pal for Sys {
e(syscall::sched_yield()) as c_int
}
fn setgroups(gidsetsize: c_int, grouplist: *mut gid_t) -> c_int {
unimplemented!()
}
fn setpgid(pid: pid_t, pgid: pid_t) -> c_int {
e(syscall::setpgid(pid as usize, pgid as usize)) as c_int
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment