mirror of
https://github.com/ziglang/zig.git
synced 2024-11-16 09:03:12 +00:00
std: add FreeBSD's procctl api.
This commit is contained in:
parent
58bab660b5
commit
2e2d37917d
@ -202,6 +202,8 @@ pub const clock_t = isize;
|
||||
pub const socklen_t = u32;
|
||||
pub const suseconds_t = c_long;
|
||||
|
||||
pub const id_t = i64;
|
||||
|
||||
/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
|
||||
pub const Kevent = extern struct {
|
||||
/// Identifier for this event.
|
||||
@ -1947,3 +1949,128 @@ pub const MFD = struct {
|
||||
|
||||
pub extern "c" fn memfd_create(name: [*:0]const u8, flags: c_uint) c_int;
|
||||
pub extern "c" fn copy_file_range(fd_in: fd_t, off_in: ?*off_t, fd_out: fd_t, off_out: ?*off_t, len: usize, flags: u32) usize;
|
||||
|
||||
pub const idtype_t = enum(c_int) {
|
||||
P_PID = 0,
|
||||
P_PPID = 1,
|
||||
P_PGID = 2,
|
||||
P_SID = 3,
|
||||
P_CID = 4,
|
||||
P_UID = 5,
|
||||
P_GID = 6,
|
||||
P_ALL = 7,
|
||||
P_LWPID = 8,
|
||||
P_TASKID = 9,
|
||||
P_PROJID = 10,
|
||||
P_POOLID = 11,
|
||||
P_JAILID = 12,
|
||||
P_CTID = 13,
|
||||
P_CPUID = 14,
|
||||
P_PSETID = 15,
|
||||
};
|
||||
|
||||
pub const PROC = struct {
|
||||
// constants for the id_t argument
|
||||
pub const SPROTECT: id_t = 1;
|
||||
pub const REAP_ACQUIRE: id_t = 2;
|
||||
pub const REAP_RELEASE: id_t = 3;
|
||||
pub const REAP_STATUS: id_t = 4;
|
||||
pub const REAP_GETPIDS: id_t = 5;
|
||||
pub const REAP_KILL: id_t = 6;
|
||||
pub const TRACE_CTL: id_t = 7;
|
||||
pub const TRACE_STATUS: id_t = 8;
|
||||
pub const TRACECAP_CTL = 9;
|
||||
pub const TRACECAP_STATUS: id_t = 10;
|
||||
pub const PDEATHSIG_CTL: id_t = 11;
|
||||
pub const PDEATHSIG_STATUS: id_t = 12;
|
||||
pub const ASLR_CTL: id_t = 13;
|
||||
pub const ASLR_STATUS: id_t = 14;
|
||||
pub const PROTMAX_CTL: id_t = 15;
|
||||
pub const PROTMAX_STATUS: id_t = 16;
|
||||
pub const STACKGAP_CTL: id_t = 17;
|
||||
pub const STACKGAP_STATUS: id_t = 18;
|
||||
pub const NO_NEW_PRIVS_CTL: id_t = 19;
|
||||
pub const NO_NEW_PRIVS_STATUS: id_t = 20;
|
||||
pub const WXMAP_CTL: id_t = 21;
|
||||
pub const WXMAP_STATUS: id_t = 22;
|
||||
|
||||
// constants for the operations
|
||||
pub const TRACE_CTL_ENABLE = 1;
|
||||
pub const TRACE_CTL_DISABLE = 2;
|
||||
pub const TRACE_CTL_DISABLE_EXEC = 3;
|
||||
pub const TRAPCAP_CTL_ENABLE = 1;
|
||||
pub const TRAPCAP_CTL_DISABLE = 2;
|
||||
pub const ASLR_FORCE_ENABLE = 1;
|
||||
pub const ASLR_FORCE_DISABLE = 2;
|
||||
pub const ASLR_FORCE_NOFORCE = 3;
|
||||
pub const ASLR_FORCE_ACTIVE = 0x80000000;
|
||||
pub const PROTMAX_FORCE_ENABLE = 1;
|
||||
pub const PROTMAX_FORCE_DISABLE = 2;
|
||||
pub const PROTMAX_FORCE_NOFORCE = 3;
|
||||
pub const PROTMAX_FORCE_ACTIVE = 0x80000000;
|
||||
pub const STACKGAP_ENABLE = 0x0001;
|
||||
pub const STACKGAP_DISABLE = 0x0002;
|
||||
pub const STACKGAP_ENABLE_EXEC = 0x0004;
|
||||
pub const STACKGAP_DISABLE_EXEC = 0x0008;
|
||||
pub const NO_NEW_PRIVS_ENABLE = 1;
|
||||
pub const NO_NEW_PRIVS_DISABLE = 2;
|
||||
pub const WX_MAPPINGS_PERMIT = 0x0001;
|
||||
pub const WX_MAPPINGS_DISALLOW_EXEC = 0x0002;
|
||||
pub const WX_MAPPINGS_ENFORCE = 0x80000000;
|
||||
};
|
||||
|
||||
pub const PPROT = struct {
|
||||
pub fn OP(x: i32) i32 {
|
||||
return x & 0xf;
|
||||
}
|
||||
pub const SET = 1;
|
||||
pub const CLEAR = 2;
|
||||
pub fn FLAGS(x: i32) i32 {
|
||||
return x & !0xf;
|
||||
}
|
||||
pub const DESCEND = 0x10;
|
||||
pub const INHERIT = 0x20;
|
||||
};
|
||||
|
||||
pub const REAPER = struct {
|
||||
pub const STATUS_OWNED = 0x00000001;
|
||||
pub const STATUS_REALINIT = 0x00000002;
|
||||
pub const PIDINFO_VALID = 0x00000001;
|
||||
pub const PIDINFO_CHILD = 0x00000002;
|
||||
pub const PIDINFO_REAPER = 0x00000004;
|
||||
pub const KILL_CHILDREN = 0x00000001;
|
||||
pub const KILL_SUBTREE = 0x00000002;
|
||||
};
|
||||
|
||||
pub const procctl_reaper_status = extern struct {
|
||||
rs_flags: u32,
|
||||
rs_children: u32,
|
||||
rs_descendants: u32,
|
||||
rs_reaper: pid_t,
|
||||
rs_pid: pid_t,
|
||||
rs_pad0: [15]u32,
|
||||
};
|
||||
|
||||
pub const procctl_reaper_pidinfo = extern struct {
|
||||
pi_pid: pid_t,
|
||||
pi_subtree: pid_t,
|
||||
pi_flags: u32,
|
||||
pi_pad0: [15]u32,
|
||||
};
|
||||
|
||||
pub const procctl_reaper_pids = extern struct {
|
||||
rp_count: u32,
|
||||
rp_pad0: [15]u32,
|
||||
rp_pids: [*]procctl_reaper_pidinfo,
|
||||
};
|
||||
|
||||
pub const procctl_reaper_kill = extern struct {
|
||||
rk_sig: c_int,
|
||||
rk_flags: u32,
|
||||
rk_subtree: pid_t,
|
||||
rk_killed: u32,
|
||||
rk_fpid: pid_t,
|
||||
rk_pad0: [15]u32,
|
||||
};
|
||||
|
||||
pub extern "c" fn procctl(idtype: idtype_t, id: id_t, cmd: c_int, data: ?*anyopaque) c_int;
|
||||
|
Loading…
Reference in New Issue
Block a user