Skip to content

Commit 0824426

Browse files
committed
Auto merge of rust-lang#531 - freqlabs:master, r=alexcrichton
Add jail functions and constants for FreeBSD These are the system calls for creating and managing jails on FreeBSD.
2 parents 3ae5203 + 7c03711 commit 0824426

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

libc-test/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ fn main() {
195195
cfg.header("pthread_np.h");
196196
cfg.header("sched.h");
197197
cfg.header("ufs/ufs/quota.h");
198+
cfg.header("sys/jail.h");
198199
}
199200

200201
if netbsd {

src/unix/bsd/freebsdlike/freebsd/mod.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@ s! {
4747
pub d_name: [::c_char; 256],
4848
}
4949

50+
pub struct jail {
51+
pub version: u32,
52+
pub path: *mut ::c_char,
53+
pub hostname: *mut ::c_char,
54+
pub jailname: *mut ::c_char,
55+
pub ip4s: ::c_uint,
56+
pub ip6s: ::c_uint,
57+
pub ip4: *mut ::in_addr,
58+
pub ip6: *mut ::in6_addr,
59+
}
60+
5061
pub struct sigevent {
5162
pub sigev_notify: ::c_int,
5263
pub sigev_signo: ::c_int,
@@ -322,6 +333,17 @@ pub const TIOCSIG: ::c_uint = 0x2004745f;
322333
pub const TIOCM_DCD: ::c_int = 0x40;
323334
pub const H4DISC: ::c_int = 0x7;
324335

336+
pub const JAIL_API_VERSION: u32 = 2;
337+
pub const JAIL_CREATE: ::c_int = 0x01;
338+
pub const JAIL_UPDATE: ::c_int = 0x02;
339+
pub const JAIL_ATTACH: ::c_int = 0x04;
340+
pub const JAIL_DYING: ::c_int = 0x08;
341+
pub const JAIL_SET_MASK: ::c_int = 0x0f;
342+
pub const JAIL_GET_MASK: ::c_int = 0x08;
343+
pub const JAIL_SYS_DISABLE: ::c_int = 0;
344+
pub const JAIL_SYS_NEW: ::c_int = 1;
345+
pub const JAIL_SYS_INHERIT: ::c_int = 2;
346+
325347
// The *_MAXID constants never should've been used outside of the
326348
// FreeBSD base system. And with the exception of CTL_P1003_1B_MAXID,
327349
// they were all removed in svn r262489. They remain here for backwards
@@ -385,6 +407,14 @@ extern {
385407
pub fn clock_gettime(clk_id: clockid_t, tp: *mut ::timespec) -> ::c_int;
386408
pub fn clock_settime(clk_id: clockid_t, tp: *const ::timespec) -> ::c_int;
387409

410+
pub fn jail(jail: *mut ::jail) -> ::c_int;
411+
pub fn jail_attach(jid: ::c_int) -> ::c_int;
412+
pub fn jail_remove(jid: ::c_int) -> ::c_int;
413+
pub fn jail_get(iov: *mut ::iovec, niov: ::c_uint, flags: ::c_int)
414+
-> ::c_int;
415+
pub fn jail_set(iov: *mut ::iovec, niov: ::c_uint, flags: ::c_int)
416+
-> ::c_int;
417+
388418
pub fn posix_fallocate(fd: ::c_int, offset: ::off_t,
389419
len: ::off_t) -> ::c_int;
390420
pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t,

0 commit comments

Comments
 (0)