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

Add FreeBSD's Capsicum constants #3628

Merged
merged 1 commit into from
Apr 20, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions libc-test/semver/freebsd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,100 @@ BUFSIZ
BUS_ADRALN
BUS_ADRERR
BUS_OBJERR
CAP_READ
CAP_RIGHTS_VERSION_00
CAP_RIGHTS_VERSION
CAP_WRITE
CAP_SEEK_TELL
CAP_SEEK
CAP_PREAD
CAP_PWRITE
CAP_MMAP
CAP_MMAP_R
CAP_MMAP_W
CAP_MMAP_X
CAP_MMAP_RW
CAP_MMAP_RX
CAP_MMAP_WX
CAP_MMAP_RWX
CAP_CREATE
CAP_FEXECVE
CAP_FSYNC
CAP_FTRUNCATE
CAP_LOOKUP
CAP_FCHDIR
CAP_FCHFLAGS
CAP_CHFLAGSAT
CAP_FCHMOD
CAP_FCHMODAT
CAP_FCHOWN
CAP_FCHOWNAT
CAP_FCNTL
CAP_FLOCK
CAP_FPATHCONF
CAP_FSCK
CAP_FSTAT
CAP_FSTATAT
CAP_FSTATFS
CAP_FUTIMES
CAP_FUTIMESAT
CAP_LINKAT_TARGET
CAP_MKDIRAT
CAP_MKFIFOAT
CAP_MKNODAT
CAP_RENAMEAT_SOURCE
CAP_SYMLINKAT
CAP_UNLINKAT
CAP_ACCEPT
CAP_BIND
CAP_CONNECT
CAP_GETPEERNAME
CAP_GETSOCKNAME
CAP_GETSOCKOPT
CAP_LISTEN
CAP_PEELOFF
CAP_RECV
CAP_SEND
CAP_SETSOCKOPT
CAP_SHUTDOWN
CAP_BINDAT
CAP_CONNECTAT
CAP_LINKAT_SOURCE
CAP_RENAMEAT_TARGET
CAP_SOCK_CLIENT
CAP_SOCK_SERVER
CAP_ALL0
CAP_UNUSED0_44
CAP_UNUSED0_57
CAP_MAC_GET
CAP_MAC_SET
CAP_SEM_GETVALUE
CAP_SEM_POST
CAP_SEM_WAIT
CAP_EVENT
CAP_KQUEUE_EVENT
CAP_IOCTL
CAP_TTYHOOK
CAP_PDGETPID
CAP_PDWAIT
CAP_PDKILL
CAP_EXTATTR_DELETE
CAP_EXTATTR_GET
CAP_EXTATTR_LIST
CAP_EXTATTR_SET
CAP_ACL_CHECK
CAP_ACL_DELETE
CAP_ACL_GET
CAP_ACL_SET
CAP_KQUEUE_CHANGE
CAP_KQUEUE
CAP_ALL1
CAP_UNUSED1_22
CAP_UNUSED1_57
CAP_FCNTL_GETFL
CAP_FCNTL_SETFL
CAP_FCNTL_GETOWN
CAP_FCNTL_SETOWN
CCAR_OFLOW
CCTS_OFLOW
CDSR_OFLOW
Expand Down
123 changes: 123 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2546,6 +2546,129 @@ pub const LIO_VECTORED: ::c_int = 4;
pub const LIO_WRITEV: ::c_int = 5;
pub const LIO_READV: ::c_int = 6;

// sys/caprights.h
pub const CAP_RIGHTS_VERSION_00: i32 = 0;
pub const CAP_RIGHTS_VERSION: i32 = CAP_RIGHTS_VERSION_00;

// sys/capsicum.h
macro_rules! cap_right {
($idx:expr, $bit:expr) => {
((1u64 << (57 + ($idx))) | ($bit))
};
}
pub const CAP_READ: u64 = cap_right!(0, 0x0000000000000001u64);
pub const CAP_WRITE: u64 = cap_right!(0, 0x0000000000000002u64);
pub const CAP_SEEK_TELL: u64 = cap_right!(0, 0x0000000000000004u64);
pub const CAP_SEEK: u64 = CAP_SEEK_TELL | 0x0000000000000008u64;
pub const CAP_PREAD: u64 = CAP_SEEK | CAP_READ;
pub const CAP_PWRITE: u64 = CAP_SEEK | CAP_WRITE;
pub const CAP_MMAP: u64 = cap_right!(0, 0x0000000000000010u64);
pub const CAP_MMAP_R: u64 = CAP_MMAP | CAP_SEEK | CAP_READ;
pub const CAP_MMAP_W: u64 = CAP_MMAP | CAP_SEEK | CAP_WRITE;
pub const CAP_MMAP_X: u64 = CAP_MMAP | CAP_SEEK | 0x0000000000000020u64;
pub const CAP_MMAP_RW: u64 = CAP_MMAP_R | CAP_MMAP_W;
pub const CAP_MMAP_RX: u64 = CAP_MMAP_R | CAP_MMAP_X;
pub const CAP_MMAP_WX: u64 = CAP_MMAP_W | CAP_MMAP_X;
pub const CAP_MMAP_RWX: u64 = CAP_MMAP_R | CAP_MMAP_W | CAP_MMAP_X;
pub const CAP_CREATE: u64 = cap_right!(0, 0x0000000000000040u64);
pub const CAP_FEXECVE: u64 = cap_right!(0, 0x0000000000000080u64);
pub const CAP_FSYNC: u64 = cap_right!(0, 0x0000000000000100u64);
pub const CAP_FTRUNCATE: u64 = cap_right!(0, 0x0000000000000200u64);
pub const CAP_LOOKUP: u64 = cap_right!(0, 0x0000000000000400u64);
pub const CAP_FCHDIR: u64 = cap_right!(0, 0x0000000000000800u64);
pub const CAP_FCHFLAGS: u64 = cap_right!(0, 0x0000000000001000u64);
pub const CAP_CHFLAGSAT: u64 = CAP_FCHFLAGS | CAP_LOOKUP;
pub const CAP_FCHMOD: u64 = cap_right!(0, 0x0000000000002000u64);
pub const CAP_FCHMODAT: u64 = CAP_FCHMOD | CAP_LOOKUP;
pub const CAP_FCHOWN: u64 = cap_right!(0, 0x0000000000004000u64);
pub const CAP_FCHOWNAT: u64 = CAP_FCHOWN | CAP_LOOKUP;
pub const CAP_FCNTL: u64 = cap_right!(0, 0x0000000000008000u64);
pub const CAP_FLOCK: u64 = cap_right!(0, 0x0000000000010000u64);
pub const CAP_FPATHCONF: u64 = cap_right!(0, 0x0000000000020000u64);
pub const CAP_FSCK: u64 = cap_right!(0, 0x0000000000040000u64);
pub const CAP_FSTAT: u64 = cap_right!(0, 0x0000000000080000u64);
pub const CAP_FSTATAT: u64 = CAP_FSTAT | CAP_LOOKUP;
pub const CAP_FSTATFS: u64 = cap_right!(0, 0x0000000000100000u64);
pub const CAP_FUTIMES: u64 = cap_right!(0, 0x0000000000200000u64);
pub const CAP_FUTIMESAT: u64 = CAP_FUTIMES | CAP_LOOKUP;
// Note: this was named CAP_LINKAT prior to FreeBSD 11.0.
pub const CAP_LINKAT_TARGET: u64 = CAP_LOOKUP | 0x0000000000400000u64;
pub const CAP_MKDIRAT: u64 = CAP_LOOKUP | 0x0000000000800000u64;
pub const CAP_MKFIFOAT: u64 = CAP_LOOKUP | 0x0000000001000000u64;
pub const CAP_MKNODAT: u64 = CAP_LOOKUP | 0x0000000002000000u64;
// Note: this was named CAP_RENAMEAT prior to FreeBSD 11.0.
pub const CAP_RENAMEAT_SOURCE: u64 = CAP_LOOKUP | 0x0000000004000000u64;
pub const CAP_SYMLINKAT: u64 = CAP_LOOKUP | 0x0000000008000000u64;
pub const CAP_UNLINKAT: u64 = CAP_LOOKUP | 0x0000000010000000u64;
pub const CAP_ACCEPT: u64 = cap_right!(0, 0x0000000020000000u64);
pub const CAP_BIND: u64 = cap_right!(0, 0x0000000040000000u64);
pub const CAP_CONNECT: u64 = cap_right!(0, 0x0000000080000000u64);
pub const CAP_GETPEERNAME: u64 = cap_right!(0, 0x0000000100000000u64);
pub const CAP_GETSOCKNAME: u64 = cap_right!(0, 0x0000000200000000u64);
pub const CAP_GETSOCKOPT: u64 = cap_right!(0, 0x0000000400000000u64);
pub const CAP_LISTEN: u64 = cap_right!(0, 0x0000000800000000u64);
pub const CAP_PEELOFF: u64 = cap_right!(0, 0x0000001000000000u64);
pub const CAP_RECV: u64 = CAP_READ;
pub const CAP_SEND: u64 = CAP_WRITE;
pub const CAP_SETSOCKOPT: u64 = cap_right!(0, 0x0000002000000000u64);
pub const CAP_SHUTDOWN: u64 = cap_right!(0, 0x0000004000000000u64);
pub const CAP_BINDAT: u64 = CAP_LOOKUP | 0x0000008000000000u64;
pub const CAP_CONNECTAT: u64 = CAP_LOOKUP | 0x0000010000000000u64;
pub const CAP_LINKAT_SOURCE: u64 = CAP_LOOKUP | 0x0000020000000000u64;
pub const CAP_RENAMEAT_TARGET: u64 = CAP_LOOKUP | 0x0000040000000000u64;
pub const CAP_SOCK_CLIENT: u64 = CAP_CONNECT
| CAP_GETPEERNAME
| CAP_GETSOCKNAME
| CAP_GETSOCKOPT
| CAP_PEELOFF
| CAP_RECV
| CAP_SEND
| CAP_SETSOCKOPT
| CAP_SHUTDOWN;
pub const CAP_SOCK_SERVER: u64 = CAP_ACCEPT
| CAP_BIND
| CAP_GETPEERNAME
| CAP_GETSOCKNAME
| CAP_GETSOCKOPT
| CAP_LISTEN
| CAP_PEELOFF
| CAP_RECV
| CAP_SEND
| CAP_SETSOCKOPT
| CAP_SHUTDOWN;
pub const CAP_ALL0: u64 = cap_right!(0, 0x000007FFFFFFFFFFu64);
pub const CAP_UNUSED0_44: u64 = cap_right!(0, 0x0000080000000000u64);
pub const CAP_UNUSED0_57: u64 = cap_right!(0, 0x0100000000000000u64);
pub const CAP_MAC_GET: u64 = cap_right!(1, 0x0000000000000001u64);
pub const CAP_MAC_SET: u64 = cap_right!(1, 0x0000000000000002u64);
pub const CAP_SEM_GETVALUE: u64 = cap_right!(1, 0x0000000000000004u64);
pub const CAP_SEM_POST: u64 = cap_right!(1, 0x0000000000000008u64);
pub const CAP_SEM_WAIT: u64 = cap_right!(1, 0x0000000000000010u64);
pub const CAP_EVENT: u64 = cap_right!(1, 0x0000000000000020u64);
pub const CAP_KQUEUE_EVENT: u64 = cap_right!(1, 0x0000000000000040u64);
pub const CAP_IOCTL: u64 = cap_right!(1, 0x0000000000000080u64);
pub const CAP_TTYHOOK: u64 = cap_right!(1, 0x0000000000000100u64);
pub const CAP_PDGETPID: u64 = cap_right!(1, 0x0000000000000200u64);
pub const CAP_PDWAIT: u64 = cap_right!(1, 0x0000000000000400u64);
pub const CAP_PDKILL: u64 = cap_right!(1, 0x0000000000000800u64);
pub const CAP_EXTATTR_DELETE: u64 = cap_right!(1, 0x0000000000001000u64);
pub const CAP_EXTATTR_GET: u64 = cap_right!(1, 0x0000000000002000u64);
pub const CAP_EXTATTR_LIST: u64 = cap_right!(1, 0x0000000000004000u64);
pub const CAP_EXTATTR_SET: u64 = cap_right!(1, 0x0000000000008000u64);
pub const CAP_ACL_CHECK: u64 = cap_right!(1, 0x0000000000010000u64);
pub const CAP_ACL_DELETE: u64 = cap_right!(1, 0x0000000000020000u64);
pub const CAP_ACL_GET: u64 = cap_right!(1, 0x0000000000040000u64);
pub const CAP_ACL_SET: u64 = cap_right!(1, 0x0000000000080000u64);
pub const CAP_KQUEUE_CHANGE: u64 = cap_right!(1, 0x0000000000100000u64);
pub const CAP_KQUEUE: u64 = CAP_KQUEUE_EVENT | CAP_KQUEUE_CHANGE;
pub const CAP_ALL1: u64 = cap_right!(1, 0x00000000001FFFFFu64);
pub const CAP_UNUSED1_22: u64 = cap_right!(1, 0x0000000000200000u64);
pub const CAP_UNUSED1_57: u64 = cap_right!(1, 0x0100000000000000u64);
pub const CAP_FCNTL_GETFL: u32 = 1 << 3;
pub const CAP_FCNTL_SETFL: u32 = 1 << 4;
pub const CAP_FCNTL_GETOWN: u32 = 1 << 5;
pub const CAP_FCNTL_SETOWN: u32 = 1 << 6;

// sys/devicestat.h
pub const DEVSTAT_N_TRANS_FLAGS: ::c_int = 4;
pub const DEVSTAT_NAME_LEN: ::c_int = 16;
Expand Down