Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more bsd things: kenv, setlogin, reboot, SCM_ constants #3238

Merged
merged 4 commits into from May 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions libc-test/build.rs
Expand Up @@ -1232,6 +1232,7 @@ fn test_dragonflybsd(target: &str) {
"glob.h",
"grp.h",
"ifaddrs.h",
"kenv.h",
"kvm.h",
"langinfo.h",
"libgen.h",
Expand Down Expand Up @@ -1276,6 +1277,7 @@ fn test_dragonflybsd(target: &str) {
"sys/mount.h",
"sys/procctl.h",
"sys/ptrace.h",
"sys/reboot.h",
"sys/resource.h",
"sys/rtprio.h",
"sys/sched.h",
Expand Down Expand Up @@ -1933,6 +1935,7 @@ fn test_freebsd(target: &str) {
"grp.h",
"iconv.h",
"ifaddrs.h",
"kenv.h",
"langinfo.h",
"libgen.h",
"libutil.h",
Expand Down Expand Up @@ -1991,6 +1994,7 @@ fn test_freebsd(target: &str) {
"sys/ptrace.h",
"sys/queue.h",
"sys/random.h",
"sys/reboot.h",
"sys/resource.h",
"sys/rtprio.h",
"sys/sem.h",
Expand Down
26 changes: 26 additions & 0 deletions libc-test/semver/dragonfly.txt
Expand Up @@ -503,6 +503,12 @@ IP_TOS
ITIMER_PROF
ITIMER_REAL
ITIMER_VIRTUAL
KENV_GET
KENV_SET
KENV_UNSET
KENV_DUMP
KENV_MNAMELEN
KENV_MVALLEN
KERN_ARGMAX
KERN_BOOTFILE
KERN_BOOTTIME
Expand Down Expand Up @@ -796,6 +802,25 @@ Q_SETQUOTA
Q_SYNC
RADIXCHAR
RAND_MAX
RB_ASKNAME
RB_SINGLE
RB_NOSYNC
RB_HALT
RB_INITNAME
RB_DFLTROOT
RB_KDB
RB_RDONLY
RB_DUMP
RB_MINIROOT
RB_VERBOSE
RB_SERIAL
RB_CDROM
RB_POWEROFF
RB_GDB
RB_MUTE
RB_SELFTEST
RB_PAUSE
RB_VIDEO
REG_ASSERT
REG_ATOI
REG_BACKR
Expand Down Expand Up @@ -1484,6 +1509,7 @@ setgroups
sethostid
sethostname
setitimer
setlogin
setpriority
setproctitle
setprogname
Expand Down
38 changes: 37 additions & 1 deletion libc-test/semver/freebsd.txt
Expand Up @@ -592,6 +592,14 @@ JAIL_SYS_DISABLE
JAIL_SYS_INHERIT
JAIL_SYS_NEW
JAIL_UPDATE
KENV_GET
KENV_SET
KENV_UNSET
KENV_DUMP
KENV_DUMP_LOADER
KENV_DUMP_STATIC
KENV_MNAMELEN
KENV_MVALLEN
KERN_ARGMAX
KERN_ARND
KERN_BOOTFILE
Expand Down Expand Up @@ -1026,6 +1034,28 @@ Q_SETQUOTA
Q_SYNC
RADIXCHAR
RAND_MAX
RB_ASKNAME
RB_SINGLE
RB_NOSYNC
RB_HALT
RB_INITNAME
RB_DFLTROOT
RB_KDB
RB_RDONLY
RB_DUMP
RB_MINIROOT
RB_VERBOSE
RB_SERIAL
RB_CDROM
RB_POWEROFF
RB_GDB
RB_MUTE
RB_SELFTEST
RB_PAUSE
RB_REROOT
RB_POWERCYCLE
RB_PROBE
RB_MULTIPLE
REG_ASSERT
REG_ATOI
REG_BACKR
Expand Down Expand Up @@ -1105,9 +1135,14 @@ SCALE_PPM
SCHED_FIFO
SCHED_OTHER
SCHED_RR
SCM_CREDS
SCM_RIGHTS
SCM_TIMESTAMP
SCM_CREDS
SCM_BINTIME
SCM_REALTIME
SCM_MONOTONIC
SCM_TIME_INFO
SCM_CREDS2
SCTP_ACTIVE
SCTP_ALL_ASSOC
SCTP_ADAPTATION_LAYER
Expand Down Expand Up @@ -2126,6 +2161,7 @@ setgroups
sethostid
sethostname
setitimer
setlogin
setpriority
setproctitle
setprogname
Expand Down
1 change: 1 addition & 0 deletions libc-test/semver/netbsd.txt
Expand Up @@ -1491,6 +1491,7 @@ setgroups
sethostid
sethostname
setitimer
setlogin
setpriority
setproctitle
setprogname
Expand Down
1 change: 1 addition & 0 deletions libc-test/semver/openbsd.txt
Expand Up @@ -1199,6 +1199,7 @@ setgroups
sethostid
sethostname
setitimer
setlogin
setpriority
setproctitle
setprogname
Expand Down
3 changes: 3 additions & 0 deletions src/unix/bsd/freebsdlike/dragonfly/mod.rs
Expand Up @@ -1519,6 +1519,9 @@ pub const MAXCOMLEN: usize = 16;
pub const MAXLOGNAME: usize = 33;
pub const NGROUPS: usize = 16;

pub const RB_PAUSE: ::c_int = 0x40000;
pub const RB_VIDEO: ::c_int = 0x20000000;

const_fn! {
{const} fn _CMSG_ALIGN(n: usize) -> usize {
(n + (::mem::size_of::<::c_long>() - 1)) & !(::mem::size_of::<::c_long>() - 1)
Expand Down
13 changes: 13 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/mod.rs
Expand Up @@ -2997,6 +2997,10 @@ pub const MNT_SNAPSHOT: ::c_int = 0x01000000;
pub const MNT_UNION: ::c_int = 0x00000020;
pub const MNT_NONBUSY: ::c_int = 0x04000000;

pub const SCM_BINTIME: ::c_int = 0x04;
pub const SCM_REALTIME: ::c_int = 0x05;
pub const SCM_MONOTONIC: ::c_int = 0x06;
pub const SCM_TIME_INFO: ::c_int = 0x07;
pub const SCM_CREDS2: ::c_int = 0x08;

pub const SO_BINTIME: ::c_int = 0x2000;
Expand Down Expand Up @@ -4680,6 +4684,15 @@ pub const SCTP_ASSOC_RESET_FAILED: ::c_int = 0x0008;
pub const SCTP_STREAM_CHANGE_DENIED: ::c_int = 0x0004;
pub const SCTP_STREAM_CHANGE_FAILED: ::c_int = 0x0008;

pub const KENV_DUMP_LOADER: ::c_int = 4;
pub const KENV_DUMP_STATIC: ::c_int = 5;

pub const RB_PAUSE: ::c_int = 0x100000;
pub const RB_REROOT: ::c_int = 0x200000;
pub const RB_POWERCYCLE: ::c_int = 0x400000;
pub const RB_PROBE: ::c_int = 0x10000000;
pub const RB_MULTIPLE: ::c_int = 0x20000000;

cfg_if! {
if #[cfg(libc_const_extern_fn)] {
pub const fn MAP_ALIGNED(a: ::c_int) -> ::c_int {
Expand Down
33 changes: 33 additions & 0 deletions src/unix/bsd/freebsdlike/mod.rs
Expand Up @@ -1434,6 +1434,31 @@ pub const SHM_RND: ::c_int = 0o20000;
pub const SHM_R: ::c_int = 0o400;
pub const SHM_W: ::c_int = 0o200;

pub const KENV_GET: ::c_int = 0;
pub const KENV_SET: ::c_int = 1;
pub const KENV_UNSET: ::c_int = 2;
pub const KENV_DUMP: ::c_int = 3;
pub const KENV_MNAMELEN: ::c_int = 128;
pub const KENV_MVALLEN: ::c_int = 128;

pub const RB_ASKNAME: ::c_int = 0x001;
pub const RB_SINGLE: ::c_int = 0x002;
pub const RB_NOSYNC: ::c_int = 0x004;
pub const RB_HALT: ::c_int = 0x008;
pub const RB_INITNAME: ::c_int = 0x010;
pub const RB_DFLTROOT: ::c_int = 0x020;
pub const RB_KDB: ::c_int = 0x040;
pub const RB_RDONLY: ::c_int = 0x080;
pub const RB_DUMP: ::c_int = 0x100;
pub const RB_MINIROOT: ::c_int = 0x200;
pub const RB_VERBOSE: ::c_int = 0x800;
pub const RB_SERIAL: ::c_int = 0x1000;
pub const RB_CDROM: ::c_int = 0x2000;
pub const RB_POWEROFF: ::c_int = 0x4000;
pub const RB_GDB: ::c_int = 0x8000;
pub const RB_MUTE: ::c_int = 0x10000;
pub const RB_SELFTEST: ::c_int = 0x20000;

safe_f! {
pub {const} fn WIFCONTINUED(status: ::c_int) -> bool {
status == 0x13
Expand Down Expand Up @@ -1737,6 +1762,14 @@ extern "C" {
pub fn eui64_hostton(hostname: *const ::c_char, id: *mut eui64) -> ::c_int;

pub fn eaccess(path: *const ::c_char, mode: ::c_int) -> ::c_int;

pub fn kenv(
action: ::c_int,
name: *const ::c_char,
value: *mut ::c_char,
len: ::c_int,
) -> ::c_int;
pub fn reboot(howto: ::c_int) -> ::c_int;
}

#[link(name = "rt")]
Expand Down
1 change: 1 addition & 0 deletions src/unix/bsd/mod.rs
Expand Up @@ -628,6 +628,7 @@ extern "C" {
pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int;
pub fn freeifaddrs(ifa: *mut ::ifaddrs);
pub fn setgroups(ngroups: ::c_int, ptr: *const ::gid_t) -> ::c_int;
pub fn setlogin(name: *const ::c_char) -> ::c_int;
pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
pub fn kqueue() -> ::c_int;
pub fn unmount(target: *const ::c_char, arg: ::c_int) -> ::c_int;
Expand Down