Auto merge of #559 - superriva:superriva-patch-1, r=alexcrichton
Add IPC,SHM,MSG for Freebsd
INFO for the patch:
FREEBSD [https://github.com/freebsd/freebsd]
/sys/sys/_types.h
typedef long __key_t;
/sys/sys/types.h
typedef __key_t key_t;
/sys/sys/ipc.h
#define IPC_CREAT 001000
#define IPC_EXCL 002000
#define IPC_NOWAIT 004000
#define IPC_PRIVATE (key_t)0
#define IPC_RMID 0
#define IPC_SET 1
#define IPC_STAT 2
#define IPC_INFO 3
#define IPC_R 000400
#define IPC_W 000200
#define IPC_M 010000
struct ipc_perm {
uid_t cuid;
gid_t cgid;
uid_t uid;
gid_t gid;
mode_t mode;
unsigned short seq;
key_t key;
};
key_t ftok(const char *, int);
/sys/sys/msg.h
#define MSG_NOERROR 010000
typedef unsigned long msglen_t;
typedef unsigned long msgqnum_t;
struct msqid_ds {
struct ipc_perm msg_perm;
struct msg *msg_first;
struct msg *msg_last;
msglen_t msg_cbytes;
msgqnum_t msg_qnum;
msglen_t msg_qbytes;
pid_t msg_lspid;
pid_t msg_lrpid;
time_t msg_stime;
time_t msg_rtime;
time_t msg_ctime;
};
struct msg {
struct msg *msg_next;
long msg_type;
u_short msg_ts;
short msg_spot;
struct label *label;
};
struct msginfo {
int msgmax,
msgmni,
msgmnb,
msgtql,
msgssz,
msgseg;
};
int msgctl(int, int, struct msqid_ds *);
int msgget(key_t, int);
ssize_t msgrcv(int, void *, size_t, long, int);
int msgsnd(int, const void *, size_t, int);
/sys/sys/shm.h
#define SHM_RDONLY 010000
#define SHM_RND 020000
#define SHMLBA PAGE_SIZE
#define SHM_R (IPC_R)
#define SHM_W (IPC_W)
#define SHM_LOCK 11
#define SHM_UNLOCK 12
#define SHM_STAT 13
#define SHM_INFO 14
typedef unsigned int shmatt_t;
struct shmid_ds {
struct ipc_perm shm_perm;
size_t shm_segsz;
pid_t shm_lpid;
pid_t shm_cpid;
shmatt_t shm_nattch;
time_t shm_atime;
time_t shm_dtime;
time_t shm_ctime;
};
void *shmat(int, const void *, int);
int shmget(key_t, size_t, int);
int shmctl(int, int, struct shmid_ds *);
int shmdt(const void *);
/sys/security/mac/mac_internal.h
#define MAC_MAX_SLOTS 4
struct label {
int l_flags;
intptr_t l_perpolicy[MAC_MAX_SLOTS];
};
diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs
index 32c6c80..6652bb8 100644
--- a/src/unix/bsd/apple/mod.rs
+++ b/src/unix/bsd/apple/mod.rs
@@ -665,6 +665,12 @@
pub const F_PEOFPOSMODE: ::c_int = 3;
pub const F_VOLPOSMODE: ::c_int = 4;
+pub const AT_FDCWD: ::c_int = -2;
+pub const AT_EACCESS: ::c_int = 0x0010;
+pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x0020;
+pub const AT_SYMLINK_FOLLOW: ::c_int = 0x0040;
+pub const AT_REMOVEDIR: ::c_int = 0x0080;
+
pub const O_ACCMODE: ::c_int = 3;
pub const TIOCMODG: ::c_ulong = 0x40047403;
diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs
index f30035a..8fdde1a 100644
--- a/src/unix/bsd/freebsdlike/mod.rs
+++ b/src/unix/bsd/freebsdlike/mod.rs
@@ -452,6 +452,11 @@
pub const F_GETFL: ::c_int = 3;
pub const F_SETFL: ::c_int = 4;
+pub const AT_EACCESS: ::c_int = 0x100;
+pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x200;
+pub const AT_SYMLINK_FOLLOW: ::c_int = 0x400;
+pub const AT_REMOVEDIR: ::c_int = 0x800;
+
pub const SIGTRAP: ::c_int = 5;
pub const GLOB_APPEND : ::c_int = 0x0001;
diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs
index a329cdf..2078c59 100644
--- a/src/unix/bsd/netbsdlike/netbsd/mod.rs
+++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs
@@ -246,6 +246,12 @@
}
}
+pub const AT_FDCWD: ::c_int = -100;
+pub const AT_EACCESS: ::c_int = 0x100;
+pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x200;
+pub const AT_SYMLINK_FOLLOW: ::c_int = 0x400;
+pub const AT_REMOVEDIR: ::c_int = 0x800;
+
pub const LC_COLLATE_MASK: ::c_int = (1 << ::LC_COLLATE);
pub const LC_CTYPE_MASK: ::c_int = (1 << ::LC_CTYPE);
pub const LC_MONETARY_MASK: ::c_int = (1 << ::LC_MONETARY);
diff --git a/src/unix/bsd/netbsdlike/openbsdlike/mod.rs b/src/unix/bsd/netbsdlike/openbsdlike/mod.rs
index 0e53ccd..b0d8128 100644
--- a/src/unix/bsd/netbsdlike/openbsdlike/mod.rs
+++ b/src/unix/bsd/netbsdlike/openbsdlike/mod.rs
@@ -157,6 +157,12 @@
pub const F_DUPFD_CLOEXEC : ::c_int = 10;
+pub const AT_FDCWD: ::c_int = -100;
+pub const AT_EACCESS: ::c_int = 0x01;
+pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x02;
+pub const AT_SYMLINK_FOLLOW: ::c_int = 0x04;
+pub const AT_REMOVEDIR: ::c_int = 0x08;
+
pub const RLIM_NLIMITS: ::c_int = 9;
pub const SO_SNDTIMEO: ::c_int = 0x1005;
diff --git a/src/unix/mod.rs b/src/unix/mod.rs
index 29f93ad..b9f8cc0 100644
--- a/src/unix/mod.rs
+++ b/src/unix/mod.rs
@@ -369,6 +369,9 @@
mode: ::c_int, flags: ::c_int) -> ::c_int;
pub fn fchmodat(dirfd: ::c_int, pathname: *const ::c_char,
mode: ::mode_t, flags: ::c_int) -> ::c_int;
+ pub fn fchown(fd: ::c_int,
+ owner: ::uid_t,
+ group: ::gid_t) -> ::c_int;
pub fn fchownat(dirfd: ::c_int, pathname: *const ::c_char,
owner: ::uid_t, group: ::gid_t,
flags: ::c_int) -> ::c_int;
diff --git a/src/unix/notbsd/linux/musl/mod.rs b/src/unix/notbsd/linux/musl/mod.rs
index 2bf13f9..26cc4b9 100644
--- a/src/unix/notbsd/linux/musl/mod.rs
+++ b/src/unix/notbsd/linux/musl/mod.rs
@@ -124,6 +124,9 @@
pub const BUFSIZ: ::c_uint = 1024;
pub const TMP_MAX: ::c_uint = 10000;
pub const FOPEN_MAX: ::c_uint = 1000;
+pub const O_PATH: ::c_int = 0o10000000;
+pub const O_EXEC: ::c_int = 0o10000000;
+pub const O_SEARCH: ::c_int = 0o10000000;
pub const O_ACCMODE: ::c_int = 0o10000003;
pub const O_NDELAY: ::c_int = O_NONBLOCK;
pub const NI_MAXHOST: ::socklen_t = 255;
diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs
index 3f646f1..a9ccae8 100644
--- a/src/unix/notbsd/mod.rs
+++ b/src/unix/notbsd/mod.rs
@@ -728,6 +728,10 @@
pub const AT_FDCWD: ::c_int = -100;
pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x100;
+pub const AT_REMOVEDIR: ::c_int = 0x200;
+pub const AT_SYMLINK_FOLLOW: ::c_int = 0x400;
+pub const AT_NO_AUTOMOUNT: ::c_int = 0x800;
+pub const AT_EMPTY_PATH: ::c_int = 0x1000;
pub const LOG_CRON: ::c_int = 9 << 3;
pub const LOG_AUTHPRIV: ::c_int = 10 << 3;
@@ -746,6 +750,9 @@
pub const P_PID: idtype_t = 1;
pub const P_PGID: idtype_t = 2;
+pub const UTIME_OMIT: c_long = 1073741822;
+pub const UTIME_NOW: c_long = 1073741823;
+
f! {
pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () {
let fd = fd as usize;
@@ -917,14 +924,19 @@
offset: off64_t)
-> *mut ::c_void;
pub fn open64(path: *const c_char, oflag: ::c_int, ...) -> ::c_int;
+ pub fn openat64(fd: ::c_int,
+ path: *const c_char,
+ oflag: ::c_int, ...) -> ::c_int;
pub fn pread64(fd: ::c_int, buf: *mut ::c_void, count: ::size_t,
offset: off64_t) -> ::ssize_t;
pub fn pwrite64(fd: ::c_int, buf: *const ::c_void, count: ::size_t,
offset: off64_t) -> ::ssize_t;
+ pub fn readdir64(dirp: *mut ::DIR) -> *mut ::dirent64;
pub fn readdir64_r(dirp: *mut ::DIR, entry: *mut ::dirent64,
result: *mut *mut ::dirent64) -> ::c_int;
pub fn setrlimit64(resource: ::c_int, rlim: *const rlimit64) -> ::c_int;
pub fn stat64(path: *const c_char, buf: *mut stat64) -> ::c_int;
+ pub fn truncate64(path: *const c_char, length: off64_t) -> ::c_int;
pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int;
pub fn sysinfo (info: *mut ::sysinfo) -> ::c_int;
diff --git a/src/unix/solaris/mod.rs b/src/unix/solaris/mod.rs
index 8c0d111..1e9035c 100644
--- a/src/unix/solaris/mod.rs
+++ b/src/unix/solaris/mod.rs
@@ -28,7 +28,7 @@
pub type off_t = i64;
pub type useconds_t = ::c_uint;
pub type socklen_t = u32;
-pub type sa_family_t = u8;
+pub type sa_family_t = u16;
pub type pthread_t = ::c_uint;
pub type pthread_key_t = ::c_uint;
pub type blksize_t = u32;
@@ -491,6 +491,8 @@
pub const O_RDONLY: ::c_int = 0;
pub const O_WRONLY: ::c_int = 1;
pub const O_RDWR: ::c_int = 2;
+pub const O_SEARCH: ::c_int = 0x200000;
+pub const O_EXEC: ::c_int = 0x400000;
pub const O_APPEND: ::c_int = 8;
pub const O_CREAT: ::c_int = 256;
pub const O_EXCL: ::c_int = 1024;