Skip to content

Commit

Permalink
Auto merge of #531 - freqlabs:master, r=alexcrichton
Browse files Browse the repository at this point in the history
Add jail functions and constants for FreeBSD

These are the system calls for creating and managing jails on FreeBSD.
  • Loading branch information
bors committed Feb 21, 2017
2 parents 3ae5203 + 7c03711 commit 0824426
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ fn main() {
cfg.header("pthread_np.h");
cfg.header("sched.h");
cfg.header("ufs/ufs/quota.h");
cfg.header("sys/jail.h");
}

if netbsd {
Expand Down
30 changes: 30 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ s! {
pub d_name: [::c_char; 256],
}

pub struct jail {
pub version: u32,
pub path: *mut ::c_char,
pub hostname: *mut ::c_char,
pub jailname: *mut ::c_char,
pub ip4s: ::c_uint,
pub ip6s: ::c_uint,
pub ip4: *mut ::in_addr,
pub ip6: *mut ::in6_addr,
}

pub struct sigevent {
pub sigev_notify: ::c_int,
pub sigev_signo: ::c_int,
Expand Down Expand Up @@ -322,6 +333,17 @@ pub const TIOCSIG: ::c_uint = 0x2004745f;
pub const TIOCM_DCD: ::c_int = 0x40;
pub const H4DISC: ::c_int = 0x7;

pub const JAIL_API_VERSION: u32 = 2;
pub const JAIL_CREATE: ::c_int = 0x01;
pub const JAIL_UPDATE: ::c_int = 0x02;
pub const JAIL_ATTACH: ::c_int = 0x04;
pub const JAIL_DYING: ::c_int = 0x08;
pub const JAIL_SET_MASK: ::c_int = 0x0f;
pub const JAIL_GET_MASK: ::c_int = 0x08;
pub const JAIL_SYS_DISABLE: ::c_int = 0;
pub const JAIL_SYS_NEW: ::c_int = 1;
pub const JAIL_SYS_INHERIT: ::c_int = 2;

// The *_MAXID constants never should've been used outside of the
// FreeBSD base system. And with the exception of CTL_P1003_1B_MAXID,
// they were all removed in svn r262489. They remain here for backwards
Expand Down Expand Up @@ -385,6 +407,14 @@ extern {
pub fn clock_gettime(clk_id: clockid_t, tp: *mut ::timespec) -> ::c_int;
pub fn clock_settime(clk_id: clockid_t, tp: *const ::timespec) -> ::c_int;

pub fn jail(jail: *mut ::jail) -> ::c_int;
pub fn jail_attach(jid: ::c_int) -> ::c_int;
pub fn jail_remove(jid: ::c_int) -> ::c_int;
pub fn jail_get(iov: *mut ::iovec, niov: ::c_uint, flags: ::c_int)
-> ::c_int;
pub fn jail_set(iov: *mut ::iovec, niov: ::c_uint, flags: ::c_int)
-> ::c_int;

pub fn posix_fallocate(fd: ::c_int, offset: ::off_t,
len: ::off_t) -> ::c_int;
pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t,
Expand Down

0 comments on commit 0824426

Please sign in to comment.