diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/errno.rs | 2580 | ||||
-rw-r--r-- | src/lib.rs | 3 | ||||
-rw-r--r-- | src/macros.rs | 4 | ||||
-rw-r--r-- | src/mount.rs | 72 | ||||
-rw-r--r-- | src/sys/aio.rs | 1 | ||||
-rw-r--r-- | src/sys/epoll.rs | 2 | ||||
-rw-r--r-- | src/sys/mman.rs | 3 | ||||
-rw-r--r-- | src/sys/quota.rs | 4 | ||||
-rw-r--r-- | src/sys/select.rs | 1 | ||||
-rw-r--r-- | src/sys/signalfd.rs | 2 | ||||
-rw-r--r-- | src/sys/socket/mod.rs | 159 | ||||
-rw-r--r-- | src/sys/socket/multicast.rs | 40 | ||||
-rw-r--r-- | src/sys/socket/sockopt.rs | 32 | ||||
-rw-r--r-- | src/sys/statvfs.rs | 26 | ||||
-rw-r--r-- | src/sys/uio.rs | 6 | ||||
-rw-r--r-- | src/sys/wait.rs | 85 | ||||
-rw-r--r-- | src/unistd.rs | 73 |
17 files changed, 1451 insertions, 1642 deletions
diff --git a/src/errno.rs b/src/errno.rs index 70da6c91..1f88ec78 100644 --- a/src/errno.rs +++ b/src/errno.rs @@ -302,7 +302,7 @@ fn desc(errno: Errno) -> &'static str { EREMCHG => "Remote address changed", #[cfg(any(target_os = "linux", target_os = "android"))] - ELIBACC => "Can not acces a needed shared library", + ELIBACC => "Can not access a needed shared library", #[cfg(any(target_os = "linux", target_os = "android"))] ELIBBAD => "Accessing a corrupted shared library", @@ -529,143 +529,143 @@ fn desc(errno: Errno) -> &'static str { mod consts { use libc; - #[derive(Debug, Clone, PartialEq, Copy)] + #[derive(Clone, Copy, Debug, Eq, PartialEq)] + #[repr(i32)] pub enum Errno { UnknownErrno = 0, - EPERM = libc::EPERM as isize, - ENOENT = libc::ENOENT as isize, - ESRCH = libc::ESRCH as isize, - EINTR = libc::EINTR as isize, - EIO = libc::EIO as isize, - ENXIO = libc::ENXIO as isize, - E2BIG = libc::E2BIG as isize, - ENOEXEC = libc::ENOEXEC as isize, - EBADF = libc::EBADF as isize, - ECHILD = libc::ECHILD as isize, - EAGAIN = libc::EAGAIN as isize, - ENOMEM = libc::ENOMEM as isize, - EACCES = libc::EACCES as isize, - EFAULT = libc::EFAULT as isize, - ENOTBLK = libc::ENOTBLK as isize, - EBUSY = libc::EBUSY as isize, - EEXIST = libc::EEXIST as isize, - EXDEV = libc::EXDEV as isize, - ENODEV = libc::ENODEV as isize, - ENOTDIR = libc::ENOTDIR as isize, - EISDIR = libc::EISDIR as isize, - EINVAL = libc::EINVAL as isize, - ENFILE = libc::ENFILE as isize, - EMFILE = libc::EMFILE as isize, - ENOTTY = libc::ENOTTY as isize, - ETXTBSY = libc::ETXTBSY as isize, - EFBIG = libc::EFBIG as isize, - ENOSPC = libc::ENOSPC as isize, - ESPIPE = libc::ESPIPE as isize, - EROFS = libc::EROFS as isize, - EMLINK = libc::EMLINK as isize, - EPIPE = libc::EPIPE as isize, - EDOM = libc::EDOM as isize, - ERANGE = libc::ERANGE as isize, - EDEADLK = libc::EDEADLK as isize, - ENAMETOOLONG = libc::ENAMETOOLONG as isize, - ENOLCK = libc::ENOLCK as isize, - ENOSYS = libc::ENOSYS as isize, - ENOTEMPTY = libc::ENOTEMPTY as isize, - ELOOP = libc::ELOOP as isize, - ENOMSG = libc::ENOMSG as isize, - EIDRM = libc::EIDRM as isize, - ECHRNG = libc::ECHRNG as isize, - EL2NSYNC = libc::EL2NSYNC as isize, - EL3HLT = libc::EL3HLT as isize, - EL3RST = libc::EL3RST as isize, - ELNRNG = libc::ELNRNG as isize, - EUNATCH = libc::EUNATCH as isize, - ENOCSI = libc::ENOCSI as isize, - EL2HLT = libc::EL2HLT as isize, - EBADE = libc::EBADE as isize, - EBADR = libc::EBADR as isize, - EXFULL = libc::EXFULL as isize, - ENOANO = libc::ENOANO as isize, - EBADRQC = libc::EBADRQC as isize, - EBADSLT = libc::EBADSLT as isize, - EBFONT = libc::EBFONT as isize, - ENOSTR = libc::ENOSTR as isize, - ENODATA = libc::ENODATA as isize, - ETIME = libc::ETIME as isize, - ENOSR = libc::ENOSR as isize, - ENONET = libc::ENONET as isize, - ENOPKG = libc::ENOPKG as isize, - EREMOTE = libc::EREMOTE as isize, - ENOLINK = libc::ENOLINK as isize, - EADV = libc::EADV as isize, - ESRMNT = libc::ESRMNT as isize, - ECOMM = libc::ECOMM as isize, - EPROTO = libc::EPROTO as isize, - EMULTIHOP = libc::EMULTIHOP as isize, - EDOTDOT = libc::EDOTDOT as isize, - EBADMSG = libc::EBADMSG as isize, - EOVERFLOW = libc::EOVERFLOW as isize, - ENOTUNIQ = libc::ENOTUNIQ as isize, - EBADFD = libc::EBADFD as isize, - EREMCHG = libc::EREMCHG as isize, - ELIBACC = libc::ELIBACC as isize, - ELIBBAD = libc::ELIBBAD as isize, - ELIBSCN = libc::ELIBSCN as isize, - ELIBMAX = libc::ELIBMAX as isize, - ELIBEXEC = libc::ELIBEXEC as isize, - EILSEQ = libc::EILSEQ as isize, - ERESTART = libc::ERESTART as isize, - ESTRPIPE = libc::ESTRPIPE as isize, - EUSERS = libc::EUSERS as isize, - ENOTSOCK = libc::ENOTSOCK as isize, - EDESTADDRREQ = libc::EDESTADDRREQ as isize, - EMSGSIZE = libc::EMSGSIZE as isize, - EPROTOTYPE = libc::EPROTOTYPE as isize, - ENOPROTOOPT = libc::ENOPROTOOPT as isize, - EPROTONOSUPPORT = libc::EPROTONOSUPPORT as isize, - ESOCKTNOSUPPORT = libc::ESOCKTNOSUPPORT as isize, - EOPNOTSUPP = libc::EOPNOTSUPP as isize, - EPFNOSUPPORT = libc::EPFNOSUPPORT as isize, - EAFNOSUPPORT = libc::EAFNOSUPPORT as isize, - EADDRINUSE = libc::EADDRINUSE as isize, - EADDRNOTAVAIL = libc::EADDRNOTAVAIL as isize, - ENETDOWN = libc::ENETDOWN as isize, - ENETUNREACH = libc::ENETUNREACH as isize, - ENETRESET = libc::ENETRESET as isize, - ECONNABORTED = libc::ECONNABORTED as isize, - ECONNRESET = libc::ECONNRESET as isize, - ENOBUFS = libc::ENOBUFS as isize, - EISCONN = libc::EISCONN as isize, - ENOTCONN = libc::ENOTCONN as isize, - ESHUTDOWN = libc::ESHUTDOWN as isize, - ETOOMANYREFS = libc::ETOOMANYREFS as isize, - ETIMEDOUT = libc::ETIMEDOUT as isize, - ECONNREFUSED = libc::ECONNREFUSED as isize, - EHOSTDOWN = libc::EHOSTDOWN as isize, - EHOSTUNREACH = libc::EHOSTUNREACH as isize, - EALREADY = libc::EALREADY as isize, - EINPROGRESS = libc::EINPROGRESS as isize, - ESTALE = libc::ESTALE as isize, - EUCLEAN = libc::EUCLEAN as isize, - ENOTNAM = libc::ENOTNAM as isize, - ENAVAIL = libc::ENAVAIL as isize, - EISNAM = libc::EISNAM as isize, - EREMOTEIO = libc::EREMOTEIO as isize, - EDQUOT = libc::EDQUOT as isize, - ENOMEDIUM = libc::ENOMEDIUM as isize, - EMEDIUMTYPE = libc::EMEDIUMTYPE as isize, - ECANCELED = libc::ECANCELED as isize, - ENOKEY = libc::ENOKEY as isize, - EKEYEXPIRED = libc::EKEYEXPIRED as isize, - EKEYREVOKED = libc::EKEYREVOKED as isize, - EKEYREJECTED = libc::EKEYREJECTED as isize, - EOWNERDEAD = libc::EOWNERDEAD as isize, - ENOTRECOVERABLE = libc::ENOTRECOVERABLE as isize, - + EPERM = libc::EPERM, + ENOENT = libc::ENOENT, + ESRCH = libc::ESRCH, + EINTR = libc::EINTR, + EIO = libc::EIO, + ENXIO = libc::ENXIO, + E2BIG = libc::E2BIG, + ENOEXEC = libc::ENOEXEC, + EBADF = libc::EBADF, + ECHILD = libc::ECHILD, + EAGAIN = libc::EAGAIN, + ENOMEM = libc::ENOMEM, + EACCES = libc::EACCES, + EFAULT = libc::EFAULT, + ENOTBLK = libc::ENOTBLK, + EBUSY = libc::EBUSY, + EEXIST = libc::EEXIST, + EXDEV = libc::EXDEV, + ENODEV = libc::ENODEV, + ENOTDIR = libc::ENOTDIR, + EISDIR = libc::EISDIR, + EINVAL = libc::EINVAL, + ENFILE = libc::ENFILE, + EMFILE = libc::EMFILE, + ENOTTY = libc::ENOTTY, + ETXTBSY = libc::ETXTBSY, + EFBIG = libc::EFBIG, + ENOSPC = libc::ENOSPC, + ESPIPE = libc::ESPIPE, + EROFS = libc::EROFS, + EMLINK = libc::EMLINK, + EPIPE = libc::EPIPE, + EDOM = libc::EDOM, + ERANGE = libc::ERANGE, + EDEADLK = libc::EDEADLK, + ENAMETOOLONG = libc::ENAMETOOLONG, + ENOLCK = libc::ENOLCK, + ENOSYS = libc::ENOSYS, + ENOTEMPTY = libc::ENOTEMPTY, + ELOOP = libc::ELOOP, + ENOMSG = libc::ENOMSG, + EIDRM = libc::EIDRM, + ECHRNG = libc::ECHRNG, + EL2NSYNC = libc::EL2NSYNC, + EL3HLT = libc::EL3HLT, + EL3RST = libc::EL3RST, + ELNRNG = libc::ELNRNG, + EUNATCH = libc::EUNATCH, + ENOCSI = libc::ENOCSI, + EL2HLT = libc::EL2HLT, + EBADE = libc::EBADE, + EBADR = libc::EBADR, + EXFULL = libc::EXFULL, + ENOANO = libc::ENOANO, + EBADRQC = libc::EBADRQC, + EBADSLT = libc::EBADSLT, + EBFONT = libc::EBFONT, + ENOSTR = libc::ENOSTR, + ENODATA = libc::ENODATA, + ETIME = libc::ETIME, + ENOSR = libc::ENOSR, + ENONET = libc::ENONET, + ENOPKG = libc::ENOPKG, + EREMOTE = libc::EREMOTE, + ENOLINK = libc::ENOLINK, + EADV = libc::EADV, + ESRMNT = libc::ESRMNT, + ECOMM = libc::ECOMM, + EPROTO = libc::EPROTO, + EMULTIHOP = libc::EMULTIHOP, + EDOTDOT = libc::EDOTDOT, + EBADMSG = libc::EBADMSG, + EOVERFLOW = libc::EOVERFLOW, + ENOTUNIQ = libc::ENOTUNIQ, + EBADFD = libc::EBADFD, + EREMCHG = libc::EREMCHG, + ELIBACC = libc::ELIBACC, + ELIBBAD = libc::ELIBBAD, + ELIBSCN = libc::ELIBSCN, + ELIBMAX = libc::ELIBMAX, + ELIBEXEC = libc::ELIBEXEC, + EILSEQ = libc::EILSEQ, + ERESTART = libc::ERESTART, + ESTRPIPE = libc::ESTRPIPE, + EUSERS = libc::EUSERS, + ENOTSOCK = libc::ENOTSOCK, + EDESTADDRREQ = libc::EDESTADDRREQ, + EMSGSIZE = libc::EMSGSIZE, + EPROTOTYPE = libc::EPROTOTYPE, + ENOPROTOOPT = libc::ENOPROTOOPT, + EPROTONOSUPPORT = libc::EPROTONOSUPPORT, + ESOCKTNOSUPPORT = libc::ESOCKTNOSUPPORT, + EOPNOTSUPP = libc::EOPNOTSUPP, + EPFNOSUPPORT = libc::EPFNOSUPPORT, + EAFNOSUPPORT = libc::EAFNOSUPPORT, + EADDRINUSE = libc::EADDRINUSE, + EADDRNOTAVAIL = libc::EADDRNOTAVAIL, + ENETDOWN = libc::ENETDOWN, + ENETUNREACH = libc::ENETUNREACH, + ENETRESET = libc::ENETRESET, + ECONNABORTED = libc::ECONNABORTED, + ECONNRESET = libc::ECONNRESET, + ENOBUFS = libc::ENOBUFS, + EISCONN = libc::EISCONN, + ENOTCONN = libc::ENOTCONN, + ESHUTDOWN = libc::ESHUTDOWN, + ETOOMANYREFS = libc::ETOOMANYREFS, + ETIMEDOUT = libc::ETIMEDOUT, + ECONNREFUSED = libc::ECONNREFUSED, + EHOSTDOWN = libc::EHOSTDOWN, + EHOSTUNREACH = libc::EHOSTUNREACH, + EALREADY = libc::EALREADY, + EINPROGRESS = libc::EINPROGRESS, + ESTALE = libc::ESTALE, + EUCLEAN = libc::EUCLEAN, + ENOTNAM = libc::ENOTNAM, + ENAVAIL = libc::ENAVAIL, + EISNAM = libc::EISNAM, + EREMOTEIO = libc::EREMOTEIO, + EDQUOT = libc::EDQUOT, + ENOMEDIUM = libc::ENOMEDIUM, + EMEDIUMTYPE = libc::EMEDIUMTYPE, + ECANCELED = libc::ECANCELED, + ENOKEY = libc::ENOKEY, + EKEYEXPIRED = libc::EKEYEXPIRED, + EKEYREVOKED = libc::EKEYREVOKED, + EKEYREJECTED = libc::EKEYREJECTED, + EOWNERDEAD = libc::EOWNERDEAD, + ENOTRECOVERABLE = libc::ENOTRECOVERABLE, #[cfg(not(any(target_os = "android", target_arch="mips")))] - ERFKILL = libc::ERFKILL as isize, + ERFKILL = libc::ERFKILL, #[cfg(not(any(target_os = "android", target_arch="mips")))] - EHWPOISON = libc::EHWPOISON as isize, + EHWPOISON = libc::EHWPOISON, } pub const EWOULDBLOCK: Errno = Errno::EAGAIN; @@ -675,7 +675,7 @@ mod consts { use self::Errno::*; match e { - 0 => UnknownErrno, + 0 => UnknownErrno, libc::EPERM => EPERM, libc::ENOENT => ENOENT, libc::ESRCH => ESRCH, @@ -805,7 +805,6 @@ mod consts { libc::EKEYREJECTED => EKEYREJECTED, libc::EOWNERDEAD => EOWNERDEAD, libc::ENOTRECOVERABLE => ENOTRECOVERABLE, - #[cfg(not(any(target_os = "android", target_arch="mips")))] libc::ERFKILL => ERFKILL, #[cfg(not(any(target_os = "android", target_arch="mips")))] @@ -817,115 +816,118 @@ mod consts { #[cfg(any(target_os = "macos", target_os = "ios"))] mod consts { - #[derive(Copy, Debug, Clone, PartialEq)] + use libc; + + #[derive(Clone, Copy, Debug, Eq, PartialEq)] + #[repr(i32)] pub enum Errno { UnknownErrno = 0, - EPERM = 1, - ENOENT = 2, - ESRCH = 3, - EINTR = 4, - EIO = 5, - ENXIO = 6, - E2BIG = 7, - ENOEXEC = 8, - EBADF = 9, - ECHILD = 10, - EDEADLK = 11, - ENOMEM = 12, - EACCES = 13, - EFAULT = 14, - ENOTBLK = 15, - EBUSY = 16, - EEXIST = 17, - EXDEV = 18, - ENODEV = 19, - ENOTDIR = 20, - EISDIR = 21, - EINVAL = 22, - ENFILE = 23, - EMFILE = 24, - ENOTTY = 25, - ETXTBSY = 26, - EFBIG = 27, - ENOSPC = 28, - ESPIPE = 29, - EROFS = 30, - EMLINK = 31, - EPIPE = 32, - EDOM = 33, - ERANGE = 34, - EAGAIN = 35, - EINPROGRESS = 36, - EALREADY = 37, - ENOTSOCK = 38, - EDESTADDRREQ = 39, - EMSGSIZE = 40, - EPROTOTYPE = 41, - ENOPROTOOPT = 42, - EPROTONOSUPPORT = 43, - ESOCKTNOSUPPORT = 44, - ENOTSUP = 45, - EPFNOSUPPORT = 46, - EAFNOSUPPORT = 47, - EADDRINUSE = 48, - EADDRNOTAVAIL = 49, - ENETDOWN = 50, - ENETUNREACH = 51, - ENETRESET = 52, - ECONNABORTED = 53, - ECONNRESET = 54, - ENOBUFS = 55, - EISCONN = 56, - ENOTCONN = 57, - ESHUTDOWN = 58, - ETOOMANYREFS = 59, - ETIMEDOUT = 60, - ECONNREFUSED = 61, - ELOOP = 62, - ENAMETOOLONG = 63, - EHOSTDOWN = 64, - EHOSTUNREACH = 65, - ENOTEMPTY = 66, - EPROCLIM = 67, - EUSERS = 68, - EDQUOT = 69, - ESTALE = 70, - EREMOTE = 71, - EBADRPC = 72, - ERPCMISMATCH = 73, - EPROGUNAVAIL = 74, - EPROGMISMATCH = 75, - EPROCUNAVAIL = 76, - ENOLCK = 77, - ENOSYS = 78, - EFTYPE = 79, - EAUTH = 80, - ENEEDAUTH = 81, - EPWROFF = 82, - EDEVERR = 83, - EOVERFLOW = 84, - EBADEXEC = 85, - EBADARCH = 86, - ESHLIBVERS = 87, - EBADMACHO = 88, - ECANCELED = 89, - EIDRM = 90, - ENOMSG = 91, - EILSEQ = 92, - ENOATTR = 93, - EBADMSG = 94, - EMULTIHOP = 95, - ENODATA = 96, - ENOLINK = 97, - ENOSR = 98, - ENOSTR = 99, - EPROTO = 100, - ETIME = 101, - EOPNOTSUPP = 102, - ENOPOLICY = 103, - ENOTRECOVERABLE = 104, - EOWNERDEAD = 105, - EQFULL = 106, + EPERM = libc::EPERM, + ENOENT = libc::ENOENT, + ESRCH = libc::ESRCH, + EINTR = libc::EINTR, + EIO = libc::EIO, + ENXIO = libc::ENXIO, + E2BIG = libc::E2BIG, + ENOEXEC = libc::ENOEXEC, + EBADF = libc::EBADF, + ECHILD = libc::ECHILD, + EDEADLK = libc::EDEADLK, + ENOMEM = libc::ENOMEM, + EACCES = libc::EACCES, + EFAULT = libc::EFAULT, + ENOTBLK = libc::ENOTBLK, + EBUSY = libc::EBUSY, + EEXIST = libc::EEXIST, + EXDEV = libc::EXDEV, + ENODEV = libc::ENODEV, + ENOTDIR = libc::ENOTDIR, + EISDIR = libc::EISDIR, + EINVAL = libc::EINVAL, + ENFILE = libc::ENFILE, + EMFILE = libc::EMFILE, + ENOTTY = libc::ENOTTY, + ETXTBSY = libc::ETXTBSY, + EFBIG = libc::EFBIG, + ENOSPC = libc::ENOSPC, + ESPIPE = libc::ESPIPE, + EROFS = libc::EROFS, + EMLINK = libc::EMLINK, + EPIPE = libc::EPIPE, + EDOM = libc::EDOM, + ERANGE = libc::ERANGE, + EAGAIN = libc::EAGAIN, + EINPROGRESS = libc::EINPROGRESS, + EALREADY = libc::EALREADY, + ENOTSOCK = libc::ENOTSOCK, + EDESTADDRREQ = libc::EDESTADDRREQ, + EMSGSIZE = libc::EMSGSIZE, + EPROTOTYPE = libc::EPROTOTYPE, + ENOPROTOOPT = libc::ENOPROTOOPT, + EPROTONOSUPPORT = libc::EPROTONOSUPPORT, + ESOCKTNOSUPPORT = libc::ESOCKTNOSUPPORT, + ENOTSUP = libc::ENOTSUP, + EPFNOSUPPORT = libc::EPFNOSUPPORT, + EAFNOSUPPORT = libc::EAFNOSUPPORT, + EADDRINUSE = libc::EADDRINUSE, + EADDRNOTAVAIL = libc::EADDRNOTAVAIL, + ENETDOWN = libc::ENETDOWN, + ENETUNREACH = libc::ENETUNREACH, + ENETRESET = libc::ENETRESET, + ECONNABORTED = libc::ECONNABORTED, + ECONNRESET = libc::ECONNRESET, + ENOBUFS = libc::ENOBUFS, + EISCONN = libc::EISCONN, + ENOTCONN = libc::ENOTCONN, + ESHUTDOWN = libc::ESHUTDOWN, + ETOOMANYREFS = libc::ETOOMANYREFS, + ETIMEDOUT = libc::ETIMEDOUT, + ECONNREFUSED = libc::ECONNREFUSED, + ELOOP = libc::ELOOP, + ENAMETOOLONG = libc::ENAMETOOLONG, + EHOSTDOWN = libc::EHOSTDOWN, + EHOSTUNREACH = libc::EHOSTUNREACH, + ENOTEMPTY = libc::ENOTEMPTY, + EPROCLIM = libc::EPROCLIM, + EUSERS = libc::EUSERS, + EDQUOT = libc::EDQUOT, + ESTALE = libc::ESTALE, + EREMOTE = libc::EREMOTE, + EBADRPC = libc::EBADRPC, + ERPCMISMATCH = libc::ERPCMISMATCH, + EPROGUNAVAIL = libc::EPROGUNAVAIL, + EPROGMISMATCH = libc::EPROGMISMATCH, + EPROCUNAVAIL = libc::EPROCUNAVAIL, + ENOLCK = libc::ENOLCK, + ENOSYS = libc::ENOSYS, + EFTYPE = libc::EFTYPE, + EAUTH = libc::EAUTH, + ENEEDAUTH = libc::ENEEDAUTH, + EPWROFF = libc::EPWROFF, + EDEVERR = libc::EDEVERR, + EOVERFLOW = libc::EOVERFLOW, + EBADEXEC = libc::EBADEXEC, + EBADARCH = libc::EBADARCH, + ESHLIBVERS = libc::ESHLIBVERS, + EBADMACHO = libc::EBADMACHO, + ECANCELED = libc::ECANCELED, + EIDRM = libc::EIDRM, + ENOMSG = libc::ENOMSG, + EILSEQ = libc::EILSEQ, + ENOATTR = libc::ENOATTR, + EBADMSG = libc::EBADMSG, + EMULTIHOP = libc::EMULTIHOP, + ENODATA = libc::ENODATA, + ENOLINK = libc::ENOLINK, + ENOSR = libc::ENOSR, + ENOSTR = libc::ENOSTR, + EPROTO = libc::EPROTO, + ETIME = libc::ETIME, + EOPNOTSUPP = libc::EOPNOTSUPP, + ENOPOLICY = libc::ENOPOLICY, + ENOTRECOVERABLE = libc::ENOTRECOVERABLE, + EOWNERDEAD = libc::EOWNERDEAD, + EQFULL = libc::EQFULL, } pub const ELAST: Errno = Errno::EQFULL; @@ -938,113 +940,113 @@ mod consts { use self::Errno::*; match e { - 0 => UnknownErrno, - 1 => EPERM, - 2 => ENOENT, - 3 => ESRCH, - 4 => EINTR, - 5 => EIO, - 6 => ENXIO, - 7 => E2BIG, - 8 => ENOEXEC, - 9 => EBADF, - 10 => ECHILD, - 11 => EDEADLK, - 12 => ENOMEM, - 13 => EACCES, - 14 => EFAULT, - 15 => ENOTBLK, - 16 => EBUSY, - 17 => EEXIST, - 18 => EXDEV, - 19 => ENODEV, - 20 => ENOTDIR, - 21 => EISDIR, - 22 => EINVAL, - 23 => ENFILE, - 24 => EMFILE, - 25 => ENOTTY, - 26 => ETXTBSY, - 27 => EFBIG, - 28 => ENOSPC, - 29 => ESPIPE, - 30 => EROFS, - 31 => EMLINK, - 32 => EPIPE, - 33 => EDOM, - 34 => ERANGE, - 35 => EAGAIN, - 36 => EINPROGRESS, - 37 => EALREADY, - 38 => ENOTSOCK, - 39 => EDESTADDRREQ, - 40 => EMSGSIZE, - 41 => EPROTOTYPE, - 42 => ENOPROTOOPT, - 43 => EPROTONOSUPPORT, - 44 => ESOCKTNOSUPPORT, - 45 => ENOTSUP, - 46 => EPFNOSUPPORT, - 47 => EAFNOSUPPORT, - 48 => EADDRINUSE, - 49 => EADDRNOTAVAIL, - 50 => ENETDOWN, - 51 => ENETUNREACH, - 52 => ENETRESET, - 53 => ECONNABORTED, - 54 => ECONNRESET, - 55 => ENOBUFS, - 56 => EISCONN, - 57 => ENOTCONN, - 58 => ESHUTDOWN, - 59 => ETOOMANYREFS, - 60 => ETIMEDOUT, - 61 => ECONNREFUSED, - 62 => ELOOP, - 63 => ENAMETOOLONG, - 64 => EHOSTDOWN, - 65 => EHOSTUNREACH, - 66 => ENOTEMPTY, - 67 => EPROCLIM, - 68 => EUSERS, - 69 => EDQUOT, - 70 => ESTALE, - 71 => EREMOTE, - 72 => EBADRPC, - 73 => ERPCMISMATCH, - 74 => EPROGUNAVAIL, - 75 => EPROGMISMATCH, - 76 => EPROCUNAVAIL, - 77 => ENOLCK, - 78 => ENOSYS, - 79 => EFTYPE, - 80 => EAUTH, - 81 => ENEEDAUTH, - 82 => EPWROFF, - 83 => EDEVERR, - 84 => EOVERFLOW, - 85 => EBADEXEC, - 86 => EBADARCH, - 87 => ESHLIBVERS, - 88 => EBADMACHO, - 89 => ECANCELED, - 90 => EIDRM, - 91 => ENOMSG, - 92 => EILSEQ, - 93 => ENOATTR, - 94 => EBADMSG, - 95 => EMULTIHOP, - 96 => ENODATA, - 97 => ENOLINK, - 98 => ENOSR, - 99 => ENOSTR, - 100 => EPROTO, - 101 => ETIME, - 102 => EOPNOTSUPP, - 103 => ENOPOLICY, - 104 => ENOTRECOVERABLE, - 105 => EOWNERDEAD, - 106 => EQFULL, + 0 => UnknownErrno, + libc::EPERM => EPERM, + libc::ENOENT => ENOENT, + libc::ESRCH => ESRCH, + libc::EINTR => EINTR, + libc::EIO => EIO, + libc::ENXIO => ENXIO, + libc::E2BIG => E2BIG, + libc::ENOEXEC => ENOEXEC, + libc::EBADF => EBADF, + libc::ECHILD => ECHILD, + libc::EDEADLK => EDEADLK, + libc::ENOMEM => ENOMEM, + libc::EACCES => EACCES, + libc::EFAULT => EFAULT, + libc::ENOTBLK => ENOTBLK, + libc::EBUSY => EBUSY, + libc::EEXIST => EEXIST, + libc::EXDEV => EXDEV, + libc::ENODEV => ENODEV, + libc::ENOTDIR => ENOTDIR, + libc::EISDIR => EISDIR, + libc::EINVAL => EINVAL, + libc::ENFILE => ENFILE, + libc::EMFILE => EMFILE, + libc::ENOTTY => ENOTTY, + libc::ETXTBSY => ETXTBSY, + libc::EFBIG => EFBIG, + libc::ENOSPC => ENOSPC, + libc::ESPIPE => ESPIPE, + libc::EROFS => EROFS, + libc::EMLINK => EMLINK, + libc::EPIPE => EPIPE, + libc::EDOM => EDOM, + libc::ERANGE => ERANGE, + libc::EAGAIN => EAGAIN, + libc::EINPROGRESS => EINPROGRESS, + libc::EALREADY => EALREADY, + libc::ENOTSOCK => ENOTSOCK, + libc::EDESTADDRREQ => EDESTADDRREQ, + libc::EMSGSIZE => EMSGSIZE, + libc::EPROTOTYPE => EPROTOTYPE, + libc::ENOPROTOOPT => ENOPROTOOPT, + libc::EPROTONOSUPPORT => EPROTONOSUPPORT, + libc::ESOCKTNOSUPPORT => ESOCKTNOSUPPORT, + libc::ENOTSUP => ENOTSUP, + libc::EPFNOSUPPORT => EPFNOSUPPORT, + libc::EAFNOSUPPORT => EAFNOSUPPORT, + libc::EADDRINUSE => EADDRINUSE, + libc::EADDRNOTAVAIL => EADDRNOTAVAIL, + libc::ENETDOWN => ENETDOWN, + libc::ENETUNREACH => ENETUNREACH, + libc::ENETRESET => ENETRESET, + libc::ECONNABORTED => ECONNABORTED, + libc::ECONNRESET => ECONNRESET, + libc::ENOBUFS => ENOBUFS, + libc::EISCONN => EISCONN, + libc::ENOTCONN => ENOTCONN, + libc::ESHUTDOWN => ESHUTDOWN, + libc::ETOOMANYREFS => ETOOMANYREFS, + libc::ETIMEDOUT => ETIMEDOUT, + libc::ECONNREFUSED => ECONNREFUSED, + libc::ELOOP => ELOOP, + libc::ENAMETOOLONG => ENAMETOOLONG, + libc::EHOSTDOWN => EHOSTDOWN, + libc::EHOSTUNREACH => EHOSTUNREACH, + libc::ENOTEMPTY => ENOTEMPTY, + libc::EPROCLIM => EPROCLIM, + libc::EUSERS => EUSERS, + libc::EDQUOT => EDQUOT, + libc::ESTALE => ESTALE, + libc::EREMOTE => EREMOTE, + libc::EBADRPC => EBADRPC, + libc::ERPCMISMATCH => ERPCMISMATCH, + libc::EPROGUNAVAIL => EPROGUNAVAIL, + libc::EPROGMISMATCH => EPROGMISMATCH, + libc::EPROCUNAVAIL => EPROCUNAVAIL, + libc::ENOLCK => ENOLCK, + libc::ENOSYS => ENOSYS, + libc::EFTYPE => EFTYPE, + libc::EAUTH => EAUTH, + libc::ENEEDAUTH => ENEEDAUTH, + libc::EPWROFF => EPWROFF, + libc::EDEVERR => EDEVERR, + libc::EOVERFLOW => EOVERFLOW, + libc::EBADEXEC => EBADEXEC, + libc::EBADARCH => EBADARCH, + libc::ESHLIBVERS => ESHLIBVERS, + libc::EBADMACHO => EBADMACHO, + libc::ECANCELED => ECANCELED, + libc::EIDRM => EIDRM, + libc::ENOMSG => ENOMSG, + libc::EILSEQ => EILSEQ, + libc::ENOATTR => ENOATTR, + libc::EBADMSG => EBADMSG, + libc::EMULTIHOP => EMULTIHOP, + libc::ENODATA => ENODATA, + libc::ENOLINK => ENOLINK, + libc::ENOSR => ENOSR, + libc::ENOSTR => ENOSTR, + libc::EPROTO => EPROTO, + libc::ETIME => ETIME, + libc::EOPNOTSUPP => EOPNOTSUPP, + libc::ENOPOLICY => ENOPOLICY, + libc::ENOTRECOVERABLE => ENOTRECOVERABLE, + libc::EOWNERDEAD => EOWNERDEAD, + libc::EQFULL => EQFULL, _ => UnknownErrno, } } @@ -1052,106 +1054,108 @@ mod consts { #[cfg(target_os = "freebsd")] mod consts { - #[derive(Copy, Debug, Clone, PartialEq)] + use libc; + + #[derive(Clone, Copy, Debug, Eq, PartialEq)] + #[repr(i32)] pub enum Errno { UnknownErrno = 0, - EPERM = 1, - ENOENT = 2, - ESRCH = 3, - EINTR = 4, - EIO = 5, - ENXIO = 6, - E2BIG = 7, - ENOEXEC = 8, - EBADF = 9, - ECHILD = 10, - EDEADLK = 11, - ENOMEM = 12, - EACCES = 13, - EFAULT = 14, - ENOTBLK = 15, - EBUSY = 16, - EEXIST = 17, - EXDEV = 18, - ENODEV = 19, - ENOTDIR = 20, - EISDIR = 21, - EINVAL = 22, - ENFILE = 23, - EMFILE = 24, - ENOTTY = 25, - ETXTBSY = 26, - EFBIG = 27, - ENOSPC = 28, - ESPIPE = 29, - EROFS = 30, - EMLINK = 31, - EPIPE = 32, - EDOM = 33, - ERANGE = 34, - EAGAIN = 35, - EINPROGRESS = 36, - EALREADY = 37, - ENOTSOCK = 38, - EDESTADDRREQ = 39, - EMSGSIZE = 40, - EPROTOTYPE = 41, - ENOPROTOOPT = 42, - EPROTONOSUPPORT = 43, - ESOCKTNOSUPPORT = 44, - ENOTSUP = 45, - EPFNOSUPPORT = 46, - EAFNOSUPPORT = 47, - EADDRINUSE = 48, - EADDRNOTAVAIL = 49, - ENETDOWN = 50, - ENETUNREACH = 51, - ENETRESET = 52, - ECONNABORTED = 53, - ECONNRESET = 54, - ENOBUFS = 55, - EISCONN = 56, - ENOTCONN = 57, - ESHUTDOWN = 58, - ETOOMANYREFS = 59, - ETIMEDOUT = 60, - ECONNREFUSED = 61, - ELOOP = 62, - ENAMETOOLONG = 63, - EHOSTDOWN = 64, - EHOSTUNREACH = 65, - ENOTEMPTY = 66, - EPROCLIM = 67, - EUSERS = 68, - EDQUOT = 69, - ESTALE = 70, - EREMOTE = 71, - EBADRPC = 72, - ERPCMISMATCH = 73, - EPROGUNAVAIL = 74, - EPROGMISMATCH = 75, - EPROCUNAVAIL = 76, - ENOLCK = 77, - ENOSYS = 78, - EFTYPE = 79, - EAUTH = 80, - ENEEDAUTH = 81, - EIDRM = 82, - ENOMSG = 83, - EOVERFLOW = 84, - ECANCELED = 85, - EILSEQ = 86, - ENOATTR = 87, - EDOOFUS = 88, - EBADMSG = 89, - EMULTIHOP = 90, - ENOLINK = 91, - EPROTO = 92, - ENOTCAPABLE = 93, - ECAPMODE = 94, - ENOTRECOVERABLE = 95, - EOWNERDEAD = 96 - + EPERM = libc::EPERM, + ENOENT = libc::ENOENT, + ESRCH = libc::ESRCH, + EINTR = libc::EINTR, + EIO = libc::EIO, + ENXIO = libc::ENXIO, + E2BIG = libc::E2BIG, + ENOEXEC = libc::ENOEXEC, + EBADF = libc::EBADF, + ECHILD = libc::ECHILD, + EDEADLK = libc::EDEADLK, + ENOMEM = libc::ENOMEM, + EACCES = libc::EACCES, + EFAULT = libc::EFAULT, + ENOTBLK = libc::ENOTBLK, + EBUSY = libc::EBUSY, + EEXIST = libc::EEXIST, + EXDEV = libc::EXDEV, + ENODEV = libc::ENODEV, + ENOTDIR = libc::ENOTDIR, + EISDIR = libc::EISDIR, + EINVAL = libc::EINVAL, + ENFILE = libc::ENFILE, + EMFILE = libc::EMFILE, + ENOTTY = libc::ENOTTY, + ETXTBSY = libc::ETXTBSY, + EFBIG = libc::EFBIG, + ENOSPC = libc::ENOSPC, + ESPIPE = libc::ESPIPE, + EROFS = libc::EROFS, + EMLINK = libc::EMLINK, + EPIPE = libc::EPIPE, + EDOM = libc::EDOM, + ERANGE = libc::ERANGE, + EAGAIN = libc::EAGAIN, + EINPROGRESS = libc::EINPROGRESS, + EALREADY = libc::EALREADY, + ENOTSOCK = libc::ENOTSOCK, + EDESTADDRREQ = libc::EDESTADDRREQ, + EMSGSIZE = libc::EMSGSIZE, + EPROTOTYPE = libc::EPROTOTYPE, + ENOPROTOOPT = libc::ENOPROTOOPT, + EPROTONOSUPPORT = libc::EPROTONOSUPPORT, + ESOCKTNOSUPPORT = libc::ESOCKTNOSUPPORT, + ENOTSUP = libc::ENOTSUP, + EPFNOSUPPORT = libc::EPFNOSUPPORT, + EAFNOSUPPORT = libc::EAFNOSUPPORT, + EADDRINUSE = libc::EADDRINUSE, + EADDRNOTAVAIL = libc::EADDRNOTAVAIL, + ENETDOWN = libc::ENETDOWN, + ENETUNREACH = libc::ENETUNREACH, + ENETRESET = libc::ENETRESET, + ECONNABORTED = libc::ECONNABORTED, + ECONNRESET = libc::ECONNRESET, + ENOBUFS = libc::ENOBUFS, + EISCONN = libc::EISCONN, + ENOTCONN = libc::ENOTCONN, + ESHUTDOWN = libc::ESHUTDOWN, + ETOOMANYREFS = libc::ETOOMANYREFS, + ETIMEDOUT = libc::ETIMEDOUT, + ECONNREFUSED = libc::ECONNREFUSED, + ELOOP = libc::ELOOP, + ENAMETOOLONG = libc::ENAMETOOLONG, + EHOSTDOWN = libc::EHOSTDOWN, + EHOSTUNREACH = libc::EHOSTUNREACH, + ENOTEMPTY = libc::ENOTEMPTY, + EPROCLIM = libc::EPROCLIM, + EUSERS = libc::EUSERS, + EDQUOT = libc::EDQUOT, + ESTALE = libc::ESTALE, + EREMOTE = libc::EREMOTE, + EBADRPC = libc::EBADRPC, + ERPCMISMATCH = libc::ERPCMISMATCH, + EPROGUNAVAIL = libc::EPROGUNAVAIL, + EPROGMISMATCH = libc::EPROGMISMATCH, + EPROCUNAVAIL = libc::EPROCUNAVAIL, + ENOLCK = libc::ENOLCK, + ENOSYS = libc::ENOSYS, + EFTYPE = libc::EFTYPE, + EAUTH = libc::EAUTH, + ENEEDAUTH = libc::ENEEDAUTH, + EIDRM = libc::EIDRM, + ENOMSG = libc::ENOMSG, + EOVERFLOW = libc::EOVERFLOW, + ECANCELED = libc::ECANCELED, + EILSEQ = libc::EILSEQ, + ENOATTR = libc::ENOATTR, + EDOOFUS = libc::EDOOFUS, + EBADMSG = libc::EBADMSG, + EMULTIHOP = libc::EMULTIHOP, + ENOLINK = libc::ENOLINK, + EPROTO = libc::EPROTO, + ENOTCAPABLE = libc::ENOTCAPABLE, + ECAPMODE = libc::ECAPMODE, + ENOTRECOVERABLE = libc::ENOTRECOVERABLE, + EOWNERDEAD = libc::EOWNERDEAD, } pub const ELAST: Errno = Errno::EOWNERDEAD; @@ -1164,103 +1168,103 @@ mod consts { use self::Errno::*; match e { - 0 => UnknownErrno, - 1 => EPERM, - 2 => ENOENT, - 3 => ESRCH, - 4 => EINTR, - 5 => EIO, - 6 => ENXIO, - 7 => E2BIG, - 8 => ENOEXEC, - 9 => EBADF, - 10 => ECHILD, - 11 => EDEADLK, - 12 => ENOMEM, - 13 => EACCES, - 14 => EFAULT, - 15 => ENOTBLK, - 16 => EBUSY, - 17 => EEXIST, - 18 => EXDEV, - 19 => ENODEV, - 20 => ENOTDIR, - 21 => EISDIR, - 22 => EINVAL, - 23 => ENFILE, - 24 => EMFILE, - 25 => ENOTTY, - 26 => ETXTBSY, - 27 => EFBIG, - 28 => ENOSPC, - 29 => ESPIPE, - 30 => EROFS, - 31 => EMLINK, - 32 => EPIPE, - 33 => EDOM, - 34 => ERANGE, - 35 => EAGAIN, - 36 => EINPROGRESS, - 37 => EALREADY, - 38 => ENOTSOCK, - 39 => EDESTADDRREQ, - 40 => EMSGSIZE, - 41 => EPROTOTYPE, - 42 => ENOPROTOOPT, - 43 => EPROTONOSUPPORT, - 44 => ESOCKTNOSUPPORT, - 45 => ENOTSUP, - 46 => EPFNOSUPPORT, - 47 => EAFNOSUPPORT, - 48 => EADDRINUSE, - 49 => EADDRNOTAVAIL, - 50 => ENETDOWN, - 51 => ENETUNREACH, - 52 => ENETRESET, - 53 => ECONNABORTED, - 54 => ECONNRESET, - 55 => ENOBUFS, - 56 => EISCONN, - 57 => ENOTCONN, - 58 => ESHUTDOWN, - 59 => ETOOMANYREFS, - 60 => ETIMEDOUT, - 61 => ECONNREFUSED, - 62 => ELOOP, - 63 => ENAMETOOLONG, - 64 => EHOSTDOWN, - 65 => EHOSTUNREACH, - 66 => ENOTEMPTY, - 67 => EPROCLIM, - 68 => EUSERS, - 69 => EDQUOT, - 70 => ESTALE, - 71 => EREMOTE, - 72 => EBADRPC, - 73 => ERPCMISMATCH, - 74 => EPROGUNAVAIL, - 75 => EPROGMISMATCH, - 76 => EPROCUNAVAIL, - 77 => ENOLCK, - 78 => ENOSYS, - 79 => EFTYPE, - 80 => EAUTH, - 81 => ENEEDAUTH, - 82 => EIDRM, - 83 => ENOMSG, - 84 => EOVERFLOW, - 85 => ECANCELED, - 86 => EILSEQ, - 87 => ENOATTR, - 88 => EDOOFUS, - 89 => EBADMSG, - 90 => EMULTIHOP, - 91 => ENOLINK, - 92 => EPROTO, - 93 => ENOTCAPABLE, - 94 => ECAPMODE, - 95 => ENOTRECOVERABLE, - 96 => EOWNERDEAD, + 0 => UnknownErrno, + libc::EPERM => EPERM, + libc::ENOENT => ENOENT, + libc::ESRCH => ESRCH, + libc::EINTR => EINTR, + libc::EIO => EIO, + libc::ENXIO => ENXIO, + libc::E2BIG => E2BIG, + libc::ENOEXEC => ENOEXEC, + libc::EBADF => EBADF, + libc::ECHILD => ECHILD, + libc::EDEADLK => EDEADLK, + libc::ENOMEM => ENOMEM, + libc::EACCES => EACCES, + libc::EFAULT => EFAULT, + libc::ENOTBLK => ENOTBLK, + libc::EBUSY => EBUSY, + libc::EEXIST => EEXIST, + libc::EXDEV => EXDEV, + libc::ENODEV => ENODEV, + libc::ENOTDIR => ENOTDIR, + libc::EISDIR => EISDIR, + libc::EINVAL => EINVAL, + libc::ENFILE => ENFILE, + libc::EMFILE => EMFILE, + libc::ENOTTY => ENOTTY, + libc::ETXTBSY => ETXTBSY, + libc::EFBIG => EFBIG, + libc::ENOSPC => ENOSPC, + libc::ESPIPE => ESPIPE, + libc::EROFS => EROFS, + libc::EMLINK => EMLINK, + libc::EPIPE => EPIPE, + libc::EDOM => EDOM, + libc::ERANGE => ERANGE, + libc::EAGAIN => EAGAIN, + libc::EINPROGRESS => EINPROGRESS, + libc::EALREADY => EALREADY, + libc::ENOTSOCK => ENOTSOCK, + libc::EDESTADDRREQ => EDESTADDRREQ, + libc::EMSGSIZE => EMSGSIZE, + libc::EPROTOTYPE => EPROTOTYPE, + libc::ENOPROTOOPT => ENOPROTOOPT, + libc::EPROTONOSUPPORT => EPROTONOSUPPORT, + libc::ESOCKTNOSUPPORT => ESOCKTNOSUPPORT, + libc::ENOTSUP => ENOTSUP, + libc::EPFNOSUPPORT => EPFNOSUPPORT, + libc::EAFNOSUPPORT => EAFNOSUPPORT, + libc::EADDRINUSE => EADDRINUSE, + libc::EADDRNOTAVAIL => EADDRNOTAVAIL, + libc::ENETDOWN => ENETDOWN, + libc::ENETUNREACH => ENETUNREACH, + libc::ENETRESET => ENETRESET, + libc::ECONNABORTED => ECONNABORTED, + libc::ECONNRESET => ECONNRESET, + libc::ENOBUFS => ENOBUFS, + libc::EISCONN => EISCONN, + libc::ENOTCONN => ENOTCONN, + libc::ESHUTDOWN => ESHUTDOWN, + libc::ETOOMANYREFS => ETOOMANYREFS, + libc::ETIMEDOUT => ETIMEDOUT, + libc::ECONNREFUSED => ECONNREFUSED, + libc::ELOOP => ELOOP, + libc::ENAMETOOLONG => ENAMETOOLONG, + libc::EHOSTDOWN => EHOSTDOWN, + libc::EHOSTUNREACH => EHOSTUNREACH, + libc::ENOTEMPTY => ENOTEMPTY, + libc::EPROCLIM => EPROCLIM, + libc::EUSERS => EUSERS, + libc::EDQUOT => EDQUOT, + libc::ESTALE => ESTALE, + libc::EREMOTE => EREMOTE, + libc::EBADRPC => EBADRPC, + libc::ERPCMISMATCH => ERPCMISMATCH, + libc::EPROGUNAVAIL => EPROGUNAVAIL, + libc::EPROGMISMATCH => EPROGMISMATCH, + libc::EPROCUNAVAIL => EPROCUNAVAIL, + libc::ENOLCK => ENOLCK, + libc::ENOSYS => ENOSYS, + libc::EFTYPE => EFTYPE, + libc::EAUTH => EAUTH, + libc::ENEEDAUTH => ENEEDAUTH, + libc::EIDRM => EIDRM, + libc::ENOMSG => ENOMSG, + libc::EOVERFLOW => EOVERFLOW, + libc::ECANCELED => ECANCELED, + libc::EILSEQ => EILSEQ, + libc::ENOATTR => ENOATTR, + libc::EDOOFUS => EDOOFUS, + libc::EBADMSG => EBADMSG, + libc::EMULTIHOP => EMULTIHOP, + libc::ENOLINK => ENOLINK, + libc::EPROTO => EPROTO, + libc::ENOTCAPABLE => ENOTCAPABLE, + libc::ECAPMODE => ECAPMODE, + libc::ENOTRECOVERABLE => ENOTRECOVERABLE, + libc::EOWNERDEAD => EOWNERDEAD, _ => UnknownErrno, } } @@ -1269,109 +1273,111 @@ mod consts { #[cfg(target_os = "dragonfly")] mod consts { - #[derive(Copy, Debug, Clone, PartialEq)] + use libc; + + #[derive(Clone, Copy, Debug, Eq, PartialEq)] + #[repr(i32)] pub enum Errno { UnknownErrno = 0, - EPERM = 1, - ENOENT = 2, - ESRCH = 3, - EINTR = 4, - EIO = 5, - ENXIO = 6, - E2BIG = 7, - ENOEXEC = 8, - EBADF = 9, - ECHILD = 10, - EDEADLK = 11, - ENOMEM = 12, - EACCES = 13, - EFAULT = 14, - ENOTBLK = 15, - EBUSY = 16, - EEXIST = 17, - EXDEV = 18, - ENODEV = 19, - ENOTDIR = 20, - EISDIR = 21, - EINVAL = 22, - ENFILE = 23, - EMFILE = 24, - ENOTTY = 25, - ETXTBSY = 26, - EFBIG = 27, - ENOSPC = 28, - ESPIPE = 29, - EROFS = 30, - EMLINK = 31, - EPIPE = 32, - EDOM = 33, - ERANGE = 34, - EAGAIN = 35, - EINPROGRESS = 36, - EALREADY = 37, - ENOTSOCK = 38, - EDESTADDRREQ = 39, - EMSGSIZE = 40, - EPROTOTYPE = 41, - ENOPROTOOPT = 42, - EPROTONOSUPPORT = 43, - ESOCKTNOSUPPORT = 44, - ENOTSUP = 45, - EPFNOSUPPORT = 46, - EAFNOSUPPORT = 47, - EADDRINUSE = 48, - EADDRNOTAVAIL = 49, - ENETDOWN = 50, - ENETUNREACH = 51, - ENETRESET = 52, - ECONNABORTED = 53, - ECONNRESET = 54, - ENOBUFS = 55, - EISCONN = 56, - ENOTCONN = 57, - ESHUTDOWN = 58, - ETOOMANYREFS = 59, - ETIMEDOUT = 60, - ECONNREFUSED = 61, - ELOOP = 62, - ENAMETOOLONG = 63, - EHOSTDOWN = 64, - EHOSTUNREACH = 65, - ENOTEMPTY = 66, - EPROCLIM = 67, - EUSERS = 68, - EDQUOT = 69, - ESTALE = 70, - EREMOTE = 71, - EBADRPC = 72, - ERPCMISMATCH = 73, - EPROGUNAVAIL = 74, - EPROGMISMATCH = 75, - EPROCUNAVAIL = 76, - ENOLCK = 77, - ENOSYS = 78, - EFTYPE = 79, - EAUTH = 80, - ENEEDAUTH = 81, - EIDRM = 82, - ENOMSG = 83, - EOVERFLOW = 84, - ECANCELED = 85, - EILSEQ = 86, - ENOATTR = 87, - EDOOFUS = 88, - EBADMSG = 89, - EMULTIHOP = 90, - ENOLINK = 91, - EPROTO = 92, - - ENOMEDIUM = 93, - EUNUSED94 = 94, - EUNUSED95 = 95, - EUNUSED96 = 96, - EUNUSED97 = 97, - EUNUSED98 = 98, - EASYNC = 99, + EPERM = libc::EPERM, + ENOENT = libc::ENOENT, + ESRCH = libc::ESRCH, + EINTR = libc::EINTR, + EIO = libc::EIO, + ENXIO = libc::ENXIO, + E2BIG = libc::E2BIG, + ENOEXEC = libc::ENOEXEC, + EBADF = libc::EBADF, + ECHILD = libc::ECHILD, + EDEADLK = libc::EDEADLK, + ENOMEM = libc::ENOMEM, + EACCES = libc::EACCES, + EFAULT = libc::EFAULT, + ENOTBLK = libc::ENOTBLK, + EBUSY = libc::EBUSY, + EEXIST = libc::EEXIST, + EXDEV = libc::EXDEV, + ENODEV = libc::ENODEV, + ENOTDIR = libc::ENOTDIR, + EISDIR = libc::EISDIR, + EINVAL = libc::EINVAL, + ENFILE = libc::ENFILE, + EMFILE = libc::EMFILE, + ENOTTY = libc::ENOTTY, + ETXTBSY = libc::ETXTBSY, + EFBIG = libc::EFBIG, + ENOSPC = libc::ENOSPC, + ESPIPE = libc::ESPIPE, + EROFS = libc::EROFS, + EMLINK = libc::EMLINK, + EPIPE = libc::EPIPE, + EDOM = libc::EDOM, + ERANGE = libc::ERANGE, + EAGAIN = libc::EAGAIN, + EINPROGRESS = libc::EINPROGRESS, + EALREADY = libc::EALREADY, + ENOTSOCK = libc::ENOTSOCK, + EDESTADDRREQ = libc::EDESTADDRREQ, + EMSGSIZE = libc::EMSGSIZE, + EPROTOTYPE = libc::EPROTOTYPE, + ENOPROTOOPT = libc::ENOPROTOOPT, + EPROTONOSUPPORT = libc::EPROTONOSUPPORT, + ESOCKTNOSUPPORT = libc::ESOCKTNOSUPPORT, + ENOTSUP = libc::ENOTSUP, + EPFNOSUPPORT = libc::EPFNOSUPPORT, + EAFNOSUPPORT = libc::EAFNOSUPPORT, + EADDRINUSE = libc::EADDRINUSE, + EADDRNOTAVAIL = libc::EADDRNOTAVAIL, + ENETDOWN = libc::ENETDOWN, + ENETUNREACH = libc::ENETUNREACH, + ENETRESET = libc::ENETRESET, + ECONNABORTED = libc::ECONNABORTED, + ECONNRESET = libc::ECONNRESET, + ENOBUFS = libc::ENOBUFS, + EISCONN = libc::EISCONN, + ENOTCONN = libc::ENOTCONN, + ESHUTDOWN = libc::ESHUTDOWN, + ETOOMANYREFS = libc::ETOOMANYREFS, + ETIMEDOUT = libc::ETIMEDOUT, + ECONNREFUSED = libc::ECONNREFUSED, + ELOOP = libc::ELOOP, + ENAMETOOLONG = libc::ENAMETOOLONG, + EHOSTDOWN = libc::EHOSTDOWN, + EHOSTUNREACH = libc::EHOSTUNREACH, + ENOTEMPTY = libc::ENOTEMPTY, + EPROCLIM = libc::EPROCLIM, + EUSERS = libc::EUSERS, + EDQUOT = libc::EDQUOT, + ESTALE = libc::ESTALE, + EREMOTE = libc::EREMOTE, + EBADRPC = libc::EBADRPC, + ERPCMISMATCH = libc::ERPCMISMATCH, + EPROGUNAVAIL = libc::EPROGUNAVAIL, + EPROGMISMATCH = libc::EPROGMISMATCH, + EPROCUNAVAIL = libc::EPROCUNAVAIL, + ENOLCK = libc::ENOLCK, + ENOSYS = libc::ENOSYS, + EFTYPE = libc::EFTYPE, + EAUTH = libc::EAUTH, + ENEEDAUTH = libc::ENEEDAUTH, + EIDRM = libc::EIDRM, + ENOMSG = libc::ENOMSG, + EOVERFLOW = libc::EOVERFLOW, + ECANCELED = libc::ECANCELED, + EILSEQ = libc::EILSEQ, + ENOATTR = libc::ENOATTR, + EDOOFUS = libc::EDOOFUS, + EBADMSG = libc::EBADMSG, + EMULTIHOP = libc::EMULTIHOP, + ENOLINK = libc::ENOLINK, + EPROTO = libc::EPROTO, + ENOMEDIUM = libc::ENOMEDIUM, + EUNUSED94 = libc::EUNUSED94, + EUNUSED95 = libc::EUNUSED95, + EUNUSED96 = libc::EUNUSED96, + EUNUSED97 = libc::EUNUSED97, + EUNUSED98 = libc::EUNUSED98, + EASYNC = libc::EASYNC, } pub const ELAST: Errno = Errno::EASYNC; @@ -1385,106 +1391,106 @@ mod consts { use self::Errno::*; match e { - 0 => UnknownErrno, - 1 => EPERM, - 2 => ENOENT, - 3 => ESRCH, - 4 => EINTR, - 5 => EIO, - 6 => ENXIO, - 7 => E2BIG, - 8 => ENOEXEC, - 9 => EBADF, - 10 => ECHILD, - 11 => EDEADLK, - 12 => ENOMEM, - 13 => EACCES, - 14 => EFAULT, - 15 => ENOTBLK, - 16 => EBUSY, - 17 => EEXIST, - 18 => EXDEV, - 19 => ENODEV, - 20 => ENOTDIR, - 21 => EISDIR, - 22 => EINVAL, - 23 => ENFILE, - 24 => EMFILE, - 25 => ENOTTY, - 26 => ETXTBSY, - 27 => EFBIG, - 28 => ENOSPC, - 29 => ESPIPE, - 30 => EROFS, - 31 => EMLINK, - 32 => EPIPE, - 33 => EDOM, - 34 => ERANGE, - 35 => EAGAIN, - 36 => EINPROGRESS, - 37 => EALREADY, - 38 => ENOTSOCK, - 39 => EDESTADDRREQ, - 40 => EMSGSIZE, - 41 => EPROTOTYPE, - 42 => ENOPROTOOPT, - 43 => EPROTONOSUPPORT, - 44 => ESOCKTNOSUPPORT, - 45 => ENOTSUP, - 46 => EPFNOSUPPORT, - 47 => EAFNOSUPPORT, - 48 => EADDRINUSE, - 49 => EADDRNOTAVAIL, - 50 => ENETDOWN, - 51 => ENETUNREACH, - 52 => ENETRESET, - 53 => ECONNABORTED, - 54 => ECONNRESET, - 55 => ENOBUFS, - 56 => EISCONN, - 57 => ENOTCONN, - 58 => ESHUTDOWN, - 59 => ETOOMANYREFS, - 60 => ETIMEDOUT, - 61 => ECONNREFUSED, - 62 => ELOOP, - 63 => ENAMETOOLONG, - 64 => EHOSTDOWN, - 65 => EHOSTUNREACH, - 66 => ENOTEMPTY, - 67 => EPROCLIM, - 68 => EUSERS, - 69 => EDQUOT, - 70 => ESTALE, - 71 => EREMOTE, - 72 => EBADRPC, - 73 => ERPCMISMATCH, - 74 => EPROGUNAVAIL, - 75 => EPROGMISMATCH, - 76 => EPROCUNAVAIL, - 77 => ENOLCK, - 78 => ENOSYS, - 79 => EFTYPE, - 80 => EAUTH, - 81 => ENEEDAUTH, - 82 => EIDRM, - 83 => ENOMSG, - 84 => EOVERFLOW, - 85 => ECANCELED, - 86 => EILSEQ, - 87 => ENOATTR, - 88 => EDOOFUS, - 89 => EBADMSG, - 90 => EMULTIHOP, - 91 => ENOLINK, - 92 => EPROTO, - 93 => ENOMEDIUM, - 94 => EUNUSED94, - 95 => EUNUSED95, - 96 => EUNUSED96, - 97 => EUNUSED97, - 98 => EUNUSED98, - 99 => EASYNC, + 0 => UnknownErrno, + libc::EPERM => EPERM, + libc::ENOENT => ENOENT, + libc::ESRCH => ESRCH, + libc::EINTR => EINTR, + libc::EIO => EIO, + libc::ENXIO => ENXIO, + libc::E2BIG => E2BIG, + libc::ENOEXEC => ENOEXEC, + libc::EBADF => EBADF, + libc::ECHILD => ECHILD, + libc::EDEADLK => EDEADLK, + libc::ENOMEM => ENOMEM, + libc::EACCES => EACCES, + libc::EFAULT => EFAULT, + libc::ENOTBLK => ENOTBLK, + libc::EBUSY => EBUSY, + libc::EEXIST => EEXIST, + libc::EXDEV => EXDEV, + libc::ENODEV => ENODEV, + libc::ENOTDIR => ENOTDIR, + libc::EISDIR=> EISDIR, + libc::EINVAL => EINVAL, + libc::ENFILE => ENFILE, + libc::EMFILE => EMFILE, + libc::ENOTTY => ENOTTY, + libc::ETXTBSY => ETXTBSY, + libc::EFBIG => EFBIG, + libc::ENOSPC => ENOSPC, + libc::ESPIPE => ESPIPE, + libc::EROFS => EROFS, + libc::EMLINK => EMLINK, + libc::EPIPE => EPIPE, + libc::EDOM => EDOM, + libc::ERANGE => ERANGE, + libc::EAGAIN => EAGAIN, + libc::EINPROGRESS => EINPROGRESS, + libc::EALREADY => EALREADY, + libc::ENOTSOCK => ENOTSOCK, + libc::EDESTADDRREQ => EDESTADDRREQ, + libc::EMSGSIZE => EMSGSIZE, + libc::EPROTOTYPE => EPROTOTYPE, + libc::ENOPROTOOPT => ENOPROTOOPT, + libc::EPROTONOSUPPORT => EPROTONOSUPPORT, + libc::ESOCKTNOSUPPORT => ESOCKTNOSUPPORT, + libc::ENOTSUP => ENOTSUP, + libc::EPFNOSUPPORT => EPFNOSUPPORT, + libc::EAFNOSUPPORT => EAFNOSUPPORT, + libc::EADDRINUSE => EADDRINUSE, + libc::EADDRNOTAVAIL => EADDRNOTAVAIL, + libc::ENETDOWN => ENETDOWN, + libc::ENETUNREACH => ENETUNREACH, + libc::ENETRESET => ENETRESET, + libc::ECONNABORTED => ECONNABORTED, + libc::ECONNRESET => ECONNRESET, + libc::ENOBUFS => ENOBUFS, + libc::EISCONN => EISCONN, + libc::ENOTCONN => ENOTCONN, + libc::ESHUTDOWN => ESHUTDOWN, + libc::ETOOMANYREFS => ETOOMANYREFS, + libc::ETIMEDOUT => ETIMEDOUT, + libc::ECONNREFUSED => ECONNREFUSED, + libc::ELOOP => ELOOP, + libc::ENAMETOOLONG => ENAMETOOLONG, + libc::EHOSTDOWN => EHOSTDOWN, + libc::EHOSTUNREACH => EHOSTUNREACH, + libc::ENOTEMPTY => ENOTEMPTY, + libc::EPROCLIM => EPROCLIM, + libc::EUSERS => EUSERS, + libc::EDQUOT => EDQUOT, + libc::ESTALE => ESTALE, + libc::EREMOTE => EREMOTE, + libc::EBADRPC => EBADRPC, + libc::ERPCMISMATCH => ERPCMISMATCH, + libc::EPROGUNAVAIL => EPROGUNAVAIL, + libc::EPROGMISMATCH => EPROGMISMATCH, + libc::EPROCUNAVAIL => EPROCUNAVAIL, + libc::ENOLCK => ENOLCK, + libc::ENOSYS => ENOSYS, + libc::EFTYPE => EFTYPE, + libc::EAUTH => EAUTH, + libc::ENEEDAUTH => ENEEDAUTH, + libc::EIDRM => EIDRM, + libc::ENOMSG => ENOMSG, + libc::EOVERFLOW => EOVERFLOW, + libc::ECANCELED => ECANCELED, + libc::EILSEQ => EILSEQ, + libc::ENOATTR => ENOATTR, + libc::EDOOFUS => EDOOFUS, + libc::EBADMSG => EBADMSG, + libc::EMULTIHOP => EMULTIHOP, + libc::ENOLINK => ENOLINK, + libc::EPROTO => EPROTO, + libc::ENOMEDIUM => ENOMEDIUM, + libc::EUNUSED94 => EUNUSED94, + libc::EUNUSED95 => EUNUSED95, + libc::EUNUSED96 => EUNUSED96, + libc::EUNUSED97 => EUNUSED97, + libc::EUNUSED98 => EUNUSED98, + libc::EASYNC => EASYNC, _ => UnknownErrno, } } @@ -1493,100 +1499,103 @@ mod consts { #[cfg(target_os = "openbsd")] mod consts { - #[derive(Copy, Debug, Clone, PartialEq)] + use libc; + + #[derive(Clone, Copy, Debug, Eq, PartialEq)] + #[repr(i32)] pub enum Errno { UnknownErrno = 0, - EPERM = 1, - ENOENT = 2, - ESRCH = 3, - EINTR = 4, - EIO = 5, - ENXIO = 6, - E2BIG = 7, - ENOEXEC = 8, - EBADF = 9, - ECHILD = 10, - EDEADLK = 11, - ENOMEM = 12, - EACCES = 13, - EFAULT = 14, - ENOTBLK = 15, - EBUSY = 16, - EEXIST = 17, - EXDEV = 18, - ENODEV = 19, - ENOTDIR = 20, - EISDIR = 21, - EINVAL = 22, - ENFILE = 23, - EMFILE = 24, - ENOTTY = 25, - ETXTBSY = 26, - EFBIG = 27, - ENOSPC = 28, - ESPIPE = 29, - EROFS = 30, - EMLINK = 31, - EPIPE = 32, - EDOM = 33, - ERANGE = 34, - EAGAIN = 35, - EINPROGRESS = 36, - EALREADY = 37, - ENOTSOCK = 38, - EDESTADDRREQ = 39, - EMSGSIZE = 40, - EPROTOTYPE = 41, - ENOPROTOOPT = 42, - EPROTONOSUPPORT = 43, - ESOCKTNOSUPPORT = 44, - EOPNOTSUPP = 45, - EPFNOSUPPORT = 46, - EAFNOSUPPORT = 47, - EADDRINUSE = 48, - EADDRNOTAVAIL = 49, - ENETDOWN = 50, - ENETUNREACH = 51, - ENETRESET = 52, - ECONNABORTED = 53, - ECONNRESET = 54, - ENOBUFS = 55, - EISCONN = 56, - ENOTCONN = 57, - ESHUTDOWN = 58, - ETOOMANYREFS = 59, - ETIMEDOUT = 60, - ECONNREFUSED = 61, - ELOOP = 62, - ENAMETOOLONG = 63, - EHOSTDOWN = 64, - EHOSTUNREACH = 65, - ENOTEMPTY = 66, - EPROCLIM = 67, - EUSERS = 68, - EDQUOT = 69, - ESTALE = 70, - EREMOTE = 71, - EBADRPC = 72, - ERPCMISMATCH = 73, - EPROGUNAVAIL = 74, - EPROGMISMATCH = 75, - EPROCUNAVAIL = 76, - ENOLCK = 77, - ENOSYS = 78, - EFTYPE = 79, - EAUTH = 80, - ENEEDAUTH = 81, - EIPSEC = 82, - ENOATTR = 83, - EILSEQ = 84, - ENOMEDIUM = 85, - EMEDIUMTYPE = 86, - EOVERFLOW = 87, - ECANCELED = 88, - EIDRM = 89, - ENOMSG = 90, - ENOTSUP = 91, + EPERM = libc::EPERM, + ENOENT = libc::ENOENT, + ESRCH = libc::ESRCH, + EINTR = libc::EINTR, + EIO = libc::EIO, + ENXIO = libc::ENXIO, + E2BIG = libc::E2BIG, + ENOEXEC = libc::ENOEXEC, + EBADF = libc::EBADF, + ECHILD = libc::ECHILD, + EDEADLK = libc::EDEADLK, + ENOMEM = libc::ENOMEM, + EACCES = libc::EACCES, + EFAULT = libc::EFAULT, + ENOTBLK = libc::ENOTBLK, + EBUSY = libc::EBUSY, + EEXIST = libc::EEXIST, + EXDEV = libc::EXDEV, + ENODEV = libc::ENODEV, + ENOTDIR = libc::ENOTDIR, + EISDIR = libc::EISDIR, + EINVAL = libc::EINVAL, + ENFILE = libc::ENFILE, + EMFILE = libc::EMFILE, + ENOTTY = libc::ENOTTY, + ETXTBSY = libc::ETXTBSY, + EFBIG = libc::EFBIG, + ENOSPC = libc::ENOSPC, + ESPIPE = libc::ESPIPE, + EROFS = libc::EROFS, + EMLINK = libc::EMLINK, + EPIPE = libc::EPIPE, + EDOM = libc::EDOM, + ERANGE = libc::ERANGE, + EAGAIN = libc::EAGAIN, + EINPROGRESS = libc::EINPROGRESS, + EALREADY = libc::EALREADY, + ENOTSOCK = libc::ENOTSOCK, + EDESTADDRREQ = libc::EDESTADDRREQ, + EMSGSIZE = libc::EMSGSIZE, + EPROTOTYPE = libc::EPROTOTYPE, + ENOPROTOOPT = libc::ENOPROTOOPT, + EPROTONOSUPPORT = libc::EPROTONOSUPPORT, + ESOCKTNOSUPPORT = libc::ESOCKTNOSUPPORT, + EOPNOTSUPP = libc::EOPNOTSUPP, + EPFNOSUPPORT = libc::EPFNOSUPPORT, + EAFNOSUPPORT = libc::EAFNOSUPPORT, + EADDRINUSE = libc::EADDRINUSE, + EADDRNOTAVAIL = libc::EADDRNOTAVAIL, + ENETDOWN = libc::ENETDOWN, + ENETUNREACH = libc::ENETUNREACH, + ENETRESET = libc::ENETRESET, + ECONNABORTED = libc::ECONNABORTED, + ECONNRESET = libc::ECONNRESET, + ENOBUFS = libc::ENOBUFS, + EISCONN = libc::EISCONN, + ENOTCONN = libc::ENOTCONN, + ESHUTDOWN = libc::ESHUTDOWN, + ETOOMANYREFS = libc::ETOOMANYREFS, + ETIMEDOUT = libc::ETIMEDOUT, + ECONNREFUSED = libc::ECONNREFUSED, + ELOOP = libc::ELOOP, + ENAMETOOLONG = libc::ENAMETOOLONG, + EHOSTDOWN = libc::EHOSTDOWN, + EHOSTUNREACH = libc::EHOSTUNREACH, + ENOTEMPTY = libc::ENOTEMPTY, + EPROCLIM = libc::EPROCLIM, + EUSERS = libc::EUSERS, + EDQUOT = libc::EDQUOT, + ESTALE = libc::ESTALE, + EREMOTE = libc::EREMOTE, + EBADRPC = libc::EBADRPC, + ERPCMISMATCH = libc::ERPCMISMATCH, + EPROGUNAVAIL = libc::EPROGUNAVAIL, + EPROGMISMATCH = libc::EPROGMISMATCH, + EPROCUNAVAIL = libc::EPROCUNAVAIL, + ENOLCK = libc::ENOLCK, + ENOSYS = libc::ENOSYS, + EFTYPE = libc::EFTYPE, + EAUTH = libc::EAUTH, + ENEEDAUTH = libc::ENEEDAUTH, + EIPSEC = libc::EIPSEC, + ENOATTR = libc::ENOATTR, + EILSEQ = libc::EILSEQ, + ENOMEDIUM = libc::ENOMEDIUM, + EMEDIUMTYPE = libc::EMEDIUMTYPE, + EOVERFLOW = libc::EOVERFLOW, + ECANCELED = libc::ECANCELED, + EIDRM = libc::EIDRM, + ENOMSG = libc::ENOMSG, + ENOTSUP = libc::ENOTSUP, } pub const ELAST: Errno = Errno::ENOTSUP; @@ -1598,98 +1607,98 @@ mod consts { use self::Errno::*; match e { - 0 => UnknownErrno, - 1 => EPERM, - 2 => ENOENT, - 3 => ESRCH, - 4 => EINTR, - 5 => EIO, - 6 => ENXIO, - 7 => E2BIG, - 8 => ENOEXEC, - 9 => EBADF, - 10 => ECHILD, - 11 => EDEADLK, - 12 => ENOMEM, - 13 => EACCES, - 14 => EFAULT, - 15 => ENOTBLK, - 16 => EBUSY, - 17 => EEXIST, - 18 => EXDEV, - 19 => ENODEV, - 20 => ENOTDIR, - 21 => EISDIR, - 22 => EINVAL, - 23 => ENFILE, - 24 => EMFILE, - 25 => ENOTTY, - 26 => ETXTBSY, - 27 => EFBIG, - 28 => ENOSPC, - 29 => ESPIPE, - 30 => EROFS, - 31 => EMLINK, - 32 => EPIPE, - 33 => EDOM, - 34 => ERANGE, - 35 => EAGAIN, - 36 => EINPROGRESS, - 37 => EALREADY, - 38 => ENOTSOCK, - 39 => EDESTADDRREQ, - 40 => EMSGSIZE, - 41 => EPROTOTYPE, - 42 => ENOPROTOOPT, - 43 => EPROTONOSUPPORT, - 44 => ESOCKTNOSUPPORT, - 45 => EOPNOTSUPP, - 46 => EPFNOSUPPORT, - 47 => EAFNOSUPPORT, - 48 => EADDRINUSE, - 49 => EADDRNOTAVAIL, - 50 => ENETDOWN, - 51 => ENETUNREACH, - 52 => ENETRESET, - 53 => ECONNABORTED, - 54 => ECONNRESET, - 55 => ENOBUFS, - 56 => EISCONN, - 57 => ENOTCONN, - 58 => ESHUTDOWN, - 59 => ETOOMANYREFS, - 60 => ETIMEDOUT, - 61 => ECONNREFUSED, - 62 => ELOOP, - 63 => ENAMETOOLONG, - 64 => EHOSTDOWN, - 65 => EHOSTUNREACH, - 66 => ENOTEMPTY, - 67 => EPROCLIM, - 68 => EUSERS, - 69 => EDQUOT, - 70 => ESTALE, - 71 => EREMOTE, - 72 => EBADRPC, - 73 => ERPCMISMATCH, - 74 => EPROGUNAVAIL, - 75 => EPROGMISMATCH, - 76 => EPROCUNAVAIL, - 77 => ENOLCK, - 78 => ENOSYS, - 79 => EFTYPE, - 80 => EAUTH, - 81 => ENEEDAUTH, - 82 => EIPSEC, - 83 => ENOATTR, - 84 => EILSEQ, - 85 => ENOMEDIUM, - 86 => EMEDIUMTYPE, - 87 => EOVERFLOW, - 88 => ECANCELED, - 89 => EIDRM, - 90 => ENOMSG, - 91 => ENOTSUP, + 0 => UnknownErrno, + libc::EPERM => EPERM, + libc::ENOENT => ENOENT, + libc::ESRCH => ESRCH, + libc::EINTR => EINTR, + libc::EIO => EIO, + libc::ENXIO => ENXIO, + libc::E2BIG => E2BIG, + libc::ENOEXEC => ENOEXEC, + libc::EBADF => EBADF, + libc::ECHILD => ECHILD, + libc::EDEADLK => EDEADLK, + libc::ENOMEM => ENOMEM, + libc::EACCES => EACCES, + libc::EFAULT => EFAULT, + libc::ENOTBLK => ENOTBLK, + libc::EBUSY => EBUSY, + libc::EEXIST => EEXIST, + libc::EXDEV => EXDEV, + libc::ENODEV => ENODEV, + libc::ENOTDIR => ENOTDIR, + libc::EISDIR => EISDIR, + libc::EINVAL => EINVAL, + libc::ENFILE => ENFILE, + libc::EMFILE => EMFILE, + libc::ENOTTY => ENOTTY, + libc::ETXTBSY => ETXTBSY, + libc::EFBIG => EFBIG, + libc::ENOSPC => ENOSPC, + libc::ESPIPE => ESPIPE, + libc::EROFS => EROFS, + libc::EMLINK => EMLINK, + libc::EPIPE => EPIPE, + libc::EDOM => EDOM, + libc::ERANGE => ERANGE, + libc::EAGAIN => EAGAIN, + libc::EINPROGRESS => EINPROGRESS, + libc::EALREADY => EALREADY, + libc::ENOTSOCK => ENOTSOCK, + libc::EDESTADDRREQ => EDESTADDRREQ, + libc::EMSGSIZE => EMSGSIZE, + libc::EPROTOTYPE => EPROTOTYPE, + libc::ENOPROTOOPT => ENOPROTOOPT, + libc::EPROTONOSUPPORT => EPROTONOSUPPORT, + libc::ESOCKTNOSUPPORT => ESOCKTNOSUPPORT, + libc::EOPNOTSUPP => EOPNOTSUPP, + libc::EPFNOSUPPORT => EPFNOSUPPORT, + libc::EAFNOSUPPORT => EAFNOSUPPORT, + libc::EADDRINUSE => EADDRINUSE, + libc::EADDRNOTAVAIL => EADDRNOTAVAIL, + libc::ENETDOWN => ENETDOWN, + libc::ENETUNREACH => ENETUNREACH, + libc::ENETRESET => ENETRESET, + libc::ECONNABORTED => ECONNABORTED, + libc::ECONNRESET => ECONNRESET, + libc::ENOBUFS => ENOBUFS, + libc::EISCONN => EISCONN, + libc::ENOTCONN => ENOTCONN, + libc::ESHUTDOWN => ESHUTDOWN, + libc::ETOOMANYREFS => ETOOMANYREFS, + libc::ETIMEDOUT => ETIMEDOUT, + libc::ECONNREFUSED => ECONNREFUSED, + libc::ELOOP => ELOOP, + libc::ENAMETOOLONG => ENAMETOOLONG, + libc::EHOSTDOWN => EHOSTDOWN, + libc::EHOSTUNREACH => EHOSTUNREACH, + libc::ENOTEMPTY => ENOTEMPTY, + libc::EPROCLIM => EPROCLIM, + libc::EUSERS => EUSERS, + libc::EDQUOT => EDQUOT, + libc::ESTALE => ESTALE, + libc::EREMOTE => EREMOTE, + libc::EBADRPC => EBADRPC, + libc::ERPCMISMATCH => ERPCMISMATCH, + libc::EPROGUNAVAIL => EPROGUNAVAIL, + libc::EPROGMISMATCH => EPROGMISMATCH, + libc::EPROCUNAVAIL => EPROCUNAVAIL, + libc::ENOLCK => ENOLCK, + libc::ENOSYS => ENOSYS, + libc::EFTYPE => EFTYPE, + libc::EAUTH => EAUTH, + libc::ENEEDAUTH => ENEEDAUTH, + libc::EIPSEC => EIPSEC, + libc::ENOATTR => ENOATTR, + libc::EILSEQ => EILSEQ, + libc::ENOMEDIUM => ENOMEDIUM, + libc::EMEDIUMTYPE => EMEDIUMTYPE, + libc::EOVERFLOW => EOVERFLOW, + libc::ECANCELED => ECANCELED, + libc::EIDRM => EIDRM, + libc::ENOMSG => ENOMSG, + libc::ENOTSUP => ENOTSUP, _ => UnknownErrno, } } @@ -1697,105 +1706,108 @@ mod consts { #[cfg(target_os = "netbsd")] mod consts { - #[derive(Copy, Debug, Clone, PartialEq)] + use libc; + + #[derive(Clone, Copy, Debug, Eq, PartialEq)] + #[repr(i32)] pub enum Errno { UnknownErrno = 0, - EPERM = 1, - ENOENT = 2, - ESRCH = 3, - EINTR = 4, - EIO = 5, - ENXIO = 6, - E2BIG = 7, - ENOEXEC = 8, - EBADF = 9, - ECHILD = 10, - EDEADLK = 11, - ENOMEM = 12, - EACCES = 13, - EFAULT = 14, - ENOTBLK = 15, - EBUSY = 16, - EEXIST = 17, - EXDEV = 18, - ENODEV = 19, - ENOTDIR = 20, - EISDIR = 21, - EINVAL = 22, - ENFILE = 23, - EMFILE = 24, - ENOTTY = 25, - ETXTBSY = 26, - EFBIG = 27, - ENOSPC = 28, - ESPIPE = 29, - EROFS = 30, - EMLINK = 31, - EPIPE = 32, - EDOM = 33, - ERANGE = 34, - EAGAIN = 35, - EINPROGRESS = 36, - EALREADY = 37, - ENOTSOCK = 38, - EDESTADDRREQ = 39, - EMSGSIZE = 40, - EPROTOTYPE = 41, - ENOPROTOOPT = 42, - EPROTONOSUPPORT = 43, - ESOCKTNOSUPPORT = 44, - EOPNOTSUPP = 45, - EPFNOSUPPORT = 46, - EAFNOSUPPORT = 47, - EADDRINUSE = 48, - EADDRNOTAVAIL = 49, - ENETDOWN = 50, - ENETUNREACH = 51, - ENETRESET = 52, - ECONNABORTED = 53, - ECONNRESET = 54, - ENOBUFS = 55, - EISCONN = 56, - ENOTCONN = 57, - ESHUTDOWN = 58, - ETOOMANYREFS = 59, - ETIMEDOUT = 60, - ECONNREFUSED = 61, - ELOOP = 62, - ENAMETOOLONG = 63, - EHOSTDOWN = 64, - EHOSTUNREACH = 65, - ENOTEMPTY = 66, - EPROCLIM = 67, - EUSERS = 68, - EDQUOT = 69, - ESTALE = 70, - EREMOTE = 71, - EBADRPC = 72, - ERPCMISMATCH = 73, - EPROGUNAVAIL = 74, - EPROGMISMATCH = 75, - EPROCUNAVAIL = 76, - ENOLCK = 77, - ENOSYS = 78, - EFTYPE = 79, - EAUTH = 80, - ENEEDAUTH = 81, - EIDRM = 82, - ENOMSG = 83, - EOVERFLOW = 84, - EILSEQ = 85, - ENOTSUP = 86, - ECANCELED = 87, - EBADMSG = 88, - ENODATA = 89, - ENOSR = 90, - ENOSTR = 91, - ETIME = 92, - ENOATTR = 93, - EMULTIHOP = 94, - ENOLINK = 95, - EPROTO = 96, + EPERM = libc::EPERM, + ENOENT = libc::ENOENT, + ESRCH = libc::ESRCH, + EINTR = libc::EINTR, + EIO = libc::EIO, + ENXIO = libc::ENXIO, + E2BIG = libc::E2BIG, + ENOEXEC = libc::ENOEXEC, + EBADF = libc::EBADF, + ECHILD = libc::ECHILD, + EDEADLK = libc::EDEADLK, + ENOMEM = libc::ENOMEM, + EACCES = libc::EACCES, + EFAULT = libc::EFAULT, + ENOTBLK = libc::ENOTBLK, + EBUSY = libc::EBUSY, + EEXIST = libc::EEXIST, + EXDEV = libc::EXDEV, + ENODEV = libc::ENODEV, + ENOTDIR = libc::ENOTDIR, + EISDIR = libc::EISDIR, + EINVAL = libc::EINVAL, + ENFILE = libc::ENFILE, + EMFILE = libc::EMFILE, + ENOTTY = libc::ENOTTY, + ETXTBSY = libc::ETXTBSY, + EFBIG = libc::EFBIG, + ENOSPC = libc::ENOSPC, + ESPIPE = libc::ESPIPE, + EROFS = libc::EROFS, + EMLINK = libc::EMLINK, + EPIPE = libc::EPIPE, + EDOM = libc::EDOM, + ERANGE = libc::ERANGE, + EAGAIN = libc::EAGAIN, + EINPROGRESS = libc::EINPROGRESS, + EALREADY = libc::EALREADY, + ENOTSOCK = libc::ENOTSOCK, + EDESTADDRREQ = libc::EDESTADDRREQ, + EMSGSIZE = libc::EMSGSIZE, + EPROTOTYPE = libc::EPROTOTYPE, + ENOPROTOOPT = libc::ENOPROTOOPT, + EPROTONOSUPPORT = libc::EPROTONOSUPPORT, + ESOCKTNOSUPPORT = libc::ESOCKTNOSUPPORT, + EOPNOTSUPP = libc::EOPNOTSUPP, + EPFNOSUPPORT = libc::EPFNOSUPPORT, + EAFNOSUPPORT = libc::EAFNOSUPPORT, + EADDRINUSE = libc::EADDRINUSE, + EADDRNOTAVAIL = libc::EADDRNOTAVAIL, + ENETDOWN = libc::ENETDOWN, + ENETUNREACH = libc::ENETUNREACH, + ENETRESET = libc::ENETRESET, + ECONNABORTED = libc::ECONNABORTED, + ECONNRESET = libc::ECONNRESET, + ENOBUFS = libc::ENOBUFS, + EISCONN = libc::EISCONN, + ENOTCONN = libc::ENOTCONN, + ESHUTDOWN = libc::ESHUTDOWN, + ETOOMANYREFS = libc::ETOOMANYREFS, + ETIMEDOUT = libc::ETIMEDOUT, + ECONNREFUSED = libc::ECONNREFUSED, + ELOOP = libc::ELOOP, + ENAMETOOLONG = libc::ENAMETOOLONG, + EHOSTDOWN = libc::EHOSTDOWN, + EHOSTUNREACH = libc::EHOSTUNREACH, + ENOTEMPTY = libc::ENOTEMPTY, + EPROCLIM = libc::EPROCLIM, + EUSERS = libc::EUSERS, + EDQUOT = libc::EDQUOT, + ESTALE = libc::ESTALE, + EREMOTE = libc::EREMOTE, + EBADRPC = libc::EBADRPC, + ERPCMISMATCH = libc::ERPCMISMATCH, + EPROGUNAVAIL = libc::EPROGUNAVAIL, + EPROGMISMATCH = libc::EPROGMISMATCH, + EPROCUNAVAIL = libc::EPROCUNAVAIL, + ENOLCK = libc::ENOLCK, + ENOSYS = libc::ENOSYS, + EFTYPE = libc::EFTYPE, + EAUTH = libc::EAUTH, + ENEEDAUTH = libc::ENEEDAUTH, + EIDRM = libc::EIDRM, + ENOMSG = libc::ENOMSG, + EOVERFLOW = libc::EOVERFLOW, + EILSEQ = libc::EILSEQ, + ENOTSUP = libc::ENOTSUP, + ECANCELED = libc::ECANCELED, + EBADMSG = libc::EBADMSG, + ENODATA = libc::ENODATA, + ENOSR = libc::ENOSR, + ENOSTR = libc::ENOSTR, + ETIME = libc::ETIME, + ENOATTR = libc::ENOATTR, + EMULTIHOP = libc::EMULTIHOP, + ENOLINK = libc::ENOLINK, + EPROTO = libc::EPROTO, } pub const ELAST: Errno = Errno::ENOTSUP; @@ -1807,424 +1819,104 @@ mod consts { use self::Errno::*; match e { - 0 => UnknownErrno, - 1 => EPERM, - 2 => ENOENT, - 3 => ESRCH, - 4 => EINTR, - 5 => EIO, - 6 => ENXIO, - 7 => E2BIG, - 8 => ENOEXEC, - 9 => EBADF, - 10 => ECHILD, - 11 => EDEADLK, - 12 => ENOMEM, - 13 => EACCES, - 14 => EFAULT, - 15 => ENOTBLK, - 16 => EBUSY, - 17 => EEXIST, - 18 => EXDEV, - 19 => ENODEV, - 20 => ENOTDIR, - 21 => EISDIR, - 22 => EINVAL, - 23 => ENFILE, - 24 => EMFILE, - 25 => ENOTTY, - 26 => ETXTBSY, - 27 => EFBIG, - 28 => ENOSPC, - 29 => ESPIPE, - 30 => EROFS, - 31 => EMLINK, - 32 => EPIPE, - 33 => EDOM, - 34 => ERANGE, - 35 => EAGAIN, - 36 => EINPROGRESS, - 37 => EALREADY, - 38 => ENOTSOCK, - 39 => EDESTADDRREQ, - 40 => EMSGSIZE, - 41 => EPROTOTYPE, - 42 => ENOPROTOOPT, - 43 => EPROTONOSUPPORT, - 44 => ESOCKTNOSUPPORT, - 45 => EOPNOTSUPP, - 46 => EPFNOSUPPORT, - 47 => EAFNOSUPPORT, - 48 => EADDRINUSE, - 49 => EADDRNOTAVAIL, - 50 => ENETDOWN, - 51 => ENETUNREACH, - 52 => ENETRESET, - 53 => ECONNABORTED, - 54 => ECONNRESET, - 55 => ENOBUFS, - 56 => EISCONN, - 57 => ENOTCONN, - 58 => ESHUTDOWN, - 59 => ETOOMANYREFS, - 60 => ETIMEDOUT, - 61 => ECONNREFUSED, - 62 => ELOOP, - 63 => ENAMETOOLONG, - 64 => EHOSTDOWN, - 65 => EHOSTUNREACH, - 66 => ENOTEMPTY, - 67 => EPROCLIM, - 68 => EUSERS, - 69 => EDQUOT, - 70 => ESTALE, - 71 => EREMOTE, - 72 => EBADRPC, - 73 => ERPCMISMATCH, - 74 => EPROGUNAVAIL, - 75 => EPROGMISMATCH, - 76 => EPROCUNAVAIL, - 77 => ENOLCK, - 78 => ENOSYS, - 79 => EFTYPE, - 80 => EAUTH, - 81 => ENEEDAUTH, - 82 => EIDRM, - 83 => ENOMSG, - 84 => EOVERFLOW, - 85 => EILSEQ, - 86 => ENOTSUP, - 87 => ECANCELED, - 88 => EBADMSG, - 89 => ENODATA, - 90 => ENOSR, - 91 => ENOSTR, - 92 => ETIME, - 93 => ENOATTR, - 94 => EMULTIHOP, - 95 => ENOLINK, - 96 => EPROTO, + 0 => UnknownErrno, + libc::EPERM => EPERM, + libc::ENOENT => ENOENT, + libc::ESRCH => ESRCH, + libc::EINTR => EINTR, + libc::EIO => EIO, + libc::ENXIO => ENXIO, + libc::E2BIG => E2BIG, + libc::ENOEXEC => ENOEXEC, + libc::EBADF => EBADF, + libc::ECHILD => ECHILD, + libc::EDEADLK => EDEADLK, + libc::ENOMEM => ENOMEM, + libc::EACCES => EACCES, + libc::EFAULT => EFAULT, + libc::ENOTBLK => ENOTBLK, + libc::EBUSY => EBUSY, + libc::EEXIST => EEXIST, + libc::EXDEV => EXDEV, + libc::ENODEV => ENODEV, + libc::ENOTDIR => ENOTDIR, + libc::EISDIR => EISDIR, + libc::EINVAL => EINVAL, + libc::ENFILE => ENFILE, + libc::EMFILE => EMFILE, + libc::ENOTTY => ENOTTY, + libc::ETXTBSY => ETXTBSY, + libc::EFBIG => EFBIG, + libc::ENOSPC => ENOSPC, + libc::ESPIPE => ESPIPE, + libc::EROFS => EROFS, + libc::EMLINK => EMLINK, + libc::EPIPE => EPIPE, + libc::EDOM => EDOM, + libc::ERANGE => ERANGE, + libc::EAGAIN => EAGAIN, + libc::EINPROGRESS => EINPROGRESS, + libc::EALREADY => EALREADY, + libc::ENOTSOCK => ENOTSOCK, + libc::EDESTADDRREQ => EDESTADDRREQ, + libc::EMSGSIZE => EMSGSIZE, + libc::EPROTOTYPE => EPROTOTYPE, + libc::ENOPROTOOPT => ENOPROTOOPT, + libc::EPROTONOSUPPORT => EPROTONOSUPPORT, + libc::ESOCKTNOSUPPORT => ESOCKTNOSUPPORT, + libc::EOPNOTSUPP => EOPNOTSUPP, + libc::EPFNOSUPPORT => EPFNOSUPPORT, + libc::EAFNOSUPPORT => EAFNOSUPPORT, + libc::EADDRINUSE => EADDRINUSE, + libc::EADDRNOTAVAIL => EADDRNOTAVAIL, + libc::ENETDOWN => ENETDOWN, + libc::ENETUNREACH => ENETUNREACH, + libc::ENETRESET => ENETRESET, + libc::ECONNABORTED => ECONNABORTED, + libc::ECONNRESET => ECONNRESET, + libc::ENOBUFS => ENOBUFS, + libc::EISCONN => EISCONN, + libc::ENOTCONN => ENOTCONN, + libc::ESHUTDOWN => ESHUTDOWN, + libc::ETOOMANYREFS => ETOOMANYREFS, + libc::ETIMEDOUT => ETIMEDOUT, + libc::ECONNREFUSED => ECONNREFUSED, + libc::ELOOP => ELOOP, + libc::ENAMETOOLONG => ENAMETOOLONG, + libc::EHOSTDOWN => EHOSTDOWN, + libc::EHOSTUNREACH => EHOSTUNREACH, + libc::ENOTEMPTY => ENOTEMPTY, + libc::EPROCLIM => EPROCLIM, + libc::EUSERS => EUSERS, + libc::EDQUOT => EDQUOT, + libc::ESTALE => ESTALE, + libc::EREMOTE => EREMOTE, + libc::EBADRPC => EBADRPC, + libc::ERPCMISMATCH => ERPCMISMATCH, + libc::EPROGUNAVAIL => EPROGUNAVAIL, + libc::EPROGMISMATCH => EPROGMISMATCH, + libc::EPROCUNAVAIL => EPROCUNAVAIL, + libc::ENOLCK => ENOLCK, + libc::ENOSYS => ENOSYS, + libc::EFTYPE => EFTYPE, + libc::EAUTH => EAUTH, + libc::ENEEDAUTH => ENEEDAUTH, + libc::EIDRM => EIDRM, + libc::ENOMSG => ENOMSG, + libc::EOVERFLOW => EOVERFLOW, + libc::EILSEQ => EILSEQ, + libc::ENOTSUP => ENOTSUP, + libc::ECANCELED => ECANCELED, + libc::EBADMSG => EBADMSG, + libc::ENODATA => ENODATA, + libc::ENOSR => ENOSR, + libc::ENOSTR => ENOSTR, + libc::ETIME => ETIME, + libc::ENOATTR => ENOATTR, + libc::EMULTIHOP => EMULTIHOP, + libc::ENOLINK => ENOLINK, + libc::EPROTO => EPROTO, _ => UnknownErrno, } } } - - -#[cfg(test)] -mod test { - use super::Errno::*; - use nixtest::assert_const_eq; - use libc::c_int; - - macro_rules! check_errno { - ($($errno:ident),+) => {{ - $(assert_const_eq(stringify!($errno), $errno as c_int);)+ - }}; - } - - #[test] - pub fn test_errno_values() { - check_errno!( - EPERM, - ENOENT, - ESRCH, - EINTR, - EIO, - ENXIO, - E2BIG, - ENOEXEC, - EBADF, - ECHILD, - EAGAIN, - ENOMEM, - EACCES, - EFAULT, - ENOTBLK, - EBUSY, - EEXIST, - EXDEV, - ENODEV, - ENOTDIR, - EISDIR, - EINVAL, - ENFILE, - EMFILE, - ENOTTY, - ETXTBSY, - EFBIG, - ENOSPC, - ESPIPE, - EROFS, - EMLINK, - EPIPE, - EDOM, - ERANGE, - EDEADLK, - ENAMETOOLONG, - ENOLCK, - ENOSYS, - ENOTEMPTY, - ELOOP, - ENOMSG, - EIDRM); - - check_errno!( - EINPROGRESS, - EALREADY, - ENOTSOCK, - EDESTADDRREQ, - EMSGSIZE, - EPROTOTYPE, - ENOPROTOOPT, - EPROTONOSUPPORT, - ESOCKTNOSUPPORT, - EPFNOSUPPORT, - EAFNOSUPPORT, - EADDRINUSE, - EADDRNOTAVAIL, - ENETDOWN, - ENETUNREACH, - ENETRESET, - ECONNABORTED, - ECONNRESET, - ENOBUFS, - EISCONN, - ENOTCONN, - ESHUTDOWN, - ETOOMANYREFS, - ETIMEDOUT, - ECONNREFUSED, - EHOSTDOWN, - EHOSTUNREACH); - } - - #[test] - #[cfg(any(target_os = "linux", target_os = "android"))] - pub fn test_linux_errnos() { - check_errno!( - ECHRNG, - EL2NSYNC, - EL3HLT, - EL3RST, - ELNRNG, - EUNATCH, - ENOCSI, - EL2HLT, - EBADE, - EBADR, - EXFULL, - ENOANO, - EBADRQC, - EBADSLT, - EBFONT, - ENOSTR, - ENODATA, - ETIME, - ENOSR, - ENONET, - ENOPKG, - EREMOTE, - ENOLINK, - EADV, - ESRMNT, - ECOMM, - EPROTO, - EMULTIHOP, - EDOTDOT, - EBADMSG, - EOVERFLOW, - ENOTUNIQ, - EBADFD, - EREMCHG, - ELIBACC, - ELIBBAD, - ELIBSCN, - ELIBMAX, - ELIBEXEC, - EILSEQ, - ERESTART, - ESTRPIPE, - EUSERS, - EOPNOTSUPP, - ESTALE, - EUCLEAN, - ENOTNAM, - ENAVAIL, - EISNAM, - EREMOTEIO, - EDQUOT, - ENOMEDIUM, - EMEDIUMTYPE, - ECANCELED, - ENOKEY, - EKEYEXPIRED, - EKEYREVOKED, - EKEYREJECTED, - EOWNERDEAD, - ENOTRECOVERABLE); - } - - #[test] - #[cfg(all(target_os = "linux", not(target_arch = "mips")))] - pub fn test_linux_not_android_errnos() { - check_errno!( - ERFKILL /*, - EHWPOISON */); - } - - #[test] - #[cfg(target_os = "freebsd")] - pub fn test_freebsd_errnos() { - check_errno!( - EDOOFUS, - EMULTIHOP, - ENOLINK, - ENOTCAPABLE, - ECAPMODE, - ENEEDAUTH, - EOVERFLOW, - EILSEQ, - ENOATTR, - EBADMSG, - EPROTO, - ENOTRECOVERABLE, - EOWNERDEAD, - ENOTSUP, - EPROCLIM, - EUSERS, - EDQUOT, - ESTALE, - EREMOTE, - EBADRPC, - ERPCMISMATCH, - EPROGUNAVAIL, - EPROGMISMATCH, - EPROCUNAVAIL, - EAUTH); - } - - #[test] - #[cfg(target_os = "dragonfly")] - pub fn test_dragonfly_errnos() { - check_errno!( - EDOOFUS, - EMULTIHOP, - ENOLINK, - ENEEDAUTH, - EOVERFLOW, - EILSEQ, - ENOATTR, - EBADMSG, - EPROTO, - ENOTSUP, - EPROCLIM, - EUSERS, - EDQUOT, - ESTALE, - EREMOTE, - EBADRPC, - ERPCMISMATCH, - EPROGUNAVAIL, - EPROGMISMATCH, - EPROCUNAVAIL, - EAUTH); - } - - #[test] - #[cfg(target_os = "openbsd")] - pub fn test_openbsd_errnos() { - check_errno!( - EADDRINUSE, - EADDRNOTAVAIL, - EAFNOSUPPORT, - EALREADY, - EAUTH, - EBADRPC, - ECANCELED, - ECONNABORTED, - ECONNREFUSED, - ECONNRESET, - EDESTADDRREQ, - EDQUOT, - EFTYPE, - EHOSTDOWN, - EHOSTUNREACH, - EILSEQ, - EINPROGRESS, - EIPSEC, - EISCONN, - EMEDIUMTYPE, - EMSGSIZE, - ENEEDAUTH, - ENETDOWN, - ENETRESET, - ENETUNREACH, - ENOATTR, - ENOBUFS, - ENOMEDIUM, - ENOPROTOOPT, - ENOTCONN, - ENOTSOCK, - ENOTSUP, - EOPNOTSUPP, - EOVERFLOW, - EPFNOSUPPORT, - EPROCLIM, - EPROCUNAVAIL, - EPROGMISMATCH, - EPROGUNAVAIL, - EPROTONOSUPPORT, - EPROTOTYPE, - EREMOTE, - ESHUTDOWN, - ESOCKTNOSUPPORT, - ESTALE, - ETIMEDOUT, - ETOOMANYREFS, - EUSERS); - } - - #[test] - #[cfg(any(target_os = "macos", target_os = "ios"))] - pub fn test_darwin_errnos() { - check_errno!( - ENOTSUP, - EPROCLIM, - EUSERS, - EDQUOT, - ESTALE, - EREMOTE, - EBADRPC, - ERPCMISMATCH, - EPROGUNAVAIL, - EPROGMISMATCH, - EPROCUNAVAIL, - EFTYPE, - EAUTH, - ENEEDAUTH, - EPWROFF, - EDEVERR, - EOVERFLOW, - EBADEXEC, - EBADARCH, - ESHLIBVERS, - EBADMACHO, - ECANCELED, - EILSEQ, - ENOATTR, - EBADMSG, - EMULTIHOP, - ENODATA, - ENOLINK, - ENOSR, - ENOSTR, - EPROTO, - ETIME, - EOPNOTSUPP, - ENOPOLICY, - ENOTRECOVERABLE, - EOWNERDEAD, - EQFULL - ); - } -} @@ -18,9 +18,6 @@ extern crate bitflags; extern crate cfg_if; extern crate void; -#[cfg(test)] -extern crate nix_test as nixtest; - #[macro_use] mod macros; pub extern crate libc; diff --git a/src/macros.rs b/src/macros.rs index 15f7505c..3d1b0e4b 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -90,7 +90,7 @@ macro_rules! libc_enum { } ) => { $($attrs)* - #[derive(Clone, Copy, Debug, PartialEq, Eq)] + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] enum $BitFlags { $($entries)* } @@ -106,7 +106,7 @@ macro_rules! libc_enum { } ) => { $($attrs)* - #[derive(Clone, Copy, Debug, PartialEq, Eq)] + #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] pub enum $BitFlags { $($entries)* } diff --git a/src/mount.rs b/src/mount.rs index fb43e24c..8fe99513 100644 --- a/src/mount.rs +++ b/src/mount.rs @@ -3,39 +3,47 @@ use libc; use {Result, NixPath}; use errno::Errno; -bitflags!( +libc_bitflags!( pub struct MsFlags: c_ulong { - const MS_RDONLY = libc::MS_RDONLY; // Mount read-only - const MS_NOSUID = libc::MS_NOSUID; // Ignore suid and sgid bits - const MS_NODEV = libc::MS_NODEV; // Disallow access to device special files - const MS_NOEXEC = libc::MS_NOEXEC; // Disallow program execution - const MS_SYNCHRONOUS = libc::MS_SYNCHRONOUS; // Writes are synced at once - const MS_REMOUNT = libc::MS_REMOUNT; // Alter flags of a mounted FS - const MS_MANDLOCK = libc::MS_MANDLOCK; // Allow mandatory locks on a FS - const MS_DIRSYNC = libc::MS_DIRSYNC; // Directory modifications are synchronous - const MS_NOATIME = libc::MS_NOATIME; // Do not update access times - const MS_NODIRATIME = libc::MS_NODIRATIME; // Do not update directory access times - const MS_BIND = libc::MS_BIND; // Linux 2.4.0 - Bind directory at different place - const MS_MOVE = libc::MS_MOVE; - const MS_REC = libc::MS_REC; - const MS_VERBOSE = 1 << 15; // Deprecated - const MS_SILENT = libc::MS_SILENT; - const MS_POSIXACL = libc::MS_POSIXACL; - const MS_UNBINDABLE = libc::MS_UNBINDABLE; - const MS_PRIVATE = libc::MS_PRIVATE; - const MS_SLAVE = libc::MS_SLAVE; - const MS_SHARED = libc::MS_SHARED; - const MS_RELATIME = libc::MS_RELATIME; - const MS_KERNMOUNT = libc::MS_KERNMOUNT; - const MS_I_VERSION = libc::MS_I_VERSION; - const MS_STRICTATIME = libc::MS_STRICTATIME; - const MS_NOSEC = 1 << 28; - const MS_BORN = 1 << 29; - const MS_ACTIVE = libc::MS_ACTIVE; - const MS_NOUSER = libc::MS_NOUSER; - const MS_RMT_MASK = libc::MS_RMT_MASK; - const MS_MGC_VAL = libc::MS_MGC_VAL; - const MS_MGC_MSK = libc::MS_MGC_MSK; + /// Mount read-only + MS_RDONLY; + /// Ignore suid and sgid bits + MS_NOSUID; + /// Disallow access to device special files + MS_NODEV; + /// Disallow program execution + MS_NOEXEC; + /// Writes are synced at once + MS_SYNCHRONOUS; + /// Alter flags of a mounted FS + MS_REMOUNT; + /// Allow mandatory locks on a FS + MS_MANDLOCK; + /// Directory modifications are synchronous + MS_DIRSYNC; + /// Do not update access times + MS_NOATIME; + /// Do not update directory access times + MS_NODIRATIME; + /// Linux 2.4.0 - Bind directory at different place + MS_BIND; + MS_MOVE; + MS_REC; + MS_SILENT; + MS_POSIXACL; + MS_UNBINDABLE; + MS_PRIVATE; + MS_SLAVE; + MS_SHARED; + MS_RELATIME; + MS_KERNMOUNT; + MS_I_VERSION; + MS_STRICTATIME; + MS_ACTIVE; + MS_NOUSER; + MS_RMT_MASK; + MS_MGC_VAL; + MS_MGC_MSK; } ); diff --git a/src/sys/aio.rs b/src/sys/aio.rs index fbae4443..909b59d7 100644 --- a/src/sys/aio.rs +++ b/src/sys/aio.rs @@ -98,6 +98,7 @@ impl<'a> AioCb<'a> { /// Constructs a new `AioCb` with no associated buffer. /// /// The resulting `AioCb` structure is suitable for use with `AioCb::fsync`. + /// /// * `fd` File descriptor. Required for all aio functions. /// * `prio` If POSIX Prioritized IO is supported, then the operation will /// be prioritized at the process's priority level minus `prio` diff --git a/src/sys/epoll.rs b/src/sys/epoll.rs index 43a543ab..c6c2eab3 100644 --- a/src/sys/epoll.rs +++ b/src/sys/epoll.rs @@ -28,7 +28,7 @@ libc_bitflags!( } ); -#[derive(Clone, Copy, Eq, PartialEq)] +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] #[repr(i32)] pub enum EpollOp { EpollCtlAdd = libc::EPOLL_CTL_ADD, diff --git a/src/sys/mman.rs b/src/sys/mman.rs index a32cd54a..65f6c59d 100644 --- a/src/sys/mman.rs +++ b/src/sys/mman.rs @@ -101,8 +101,7 @@ libc_bitflags!{ libc_enum!{ /// Usage information for a range of memory to allow for performance optimizations by the kernel. /// - /// Used by [`madvise`]. - /// [`madvise`]: ./fn.madvise.html + /// Used by [`madvise`](./fn.madvise.html). #[repr(i32)] pub enum MmapAdvise { /// No further special treatment. This is the default. diff --git a/src/sys/quota.rs b/src/sys/quota.rs index abe114f0..a85d9e30 100644 --- a/src/sys/quota.rs +++ b/src/sys/quota.rs @@ -60,11 +60,11 @@ libc_enum!{ QFMT_VFS_OLD, /// Use the standard VFS v0 quota format. /// - /// Handles 32-bit UIDs/GIDs and quota limits up to 2^42 bytes/2^32 inodes. + /// Handles 32-bit UIDs/GIDs and quota limits up to 2<sup>32</sup> bytes/2<sup>32</sup> inodes. QFMT_VFS_V0, /// Use the VFS v1 quota format. /// - /// Handles 32-bit UIDs/GIDs and quota limits of 2^64 bytes/2^64 inodes. + /// Handles 32-bit UIDs/GIDs and quota limits of 2<sup>64</sup> bytes/2<sup>64</sup> inodes. QFMT_VFS_V1, } } diff --git a/src/sys/select.rs b/src/sys/select.rs index 9a429103..6fe176ae 100644 --- a/src/sys/select.rs +++ b/src/sys/select.rs @@ -88,6 +88,7 @@ impl FdSet { /// # References /// /// [select(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/select.html) +/// /// [`FdSet::highest`]: struct.FdSet.html#method.highest pub fn select<'a, N, R, W, E, T>(nfds: N, readfds: R, diff --git a/src/sys/signalfd.rs b/src/sys/signalfd.rs index 7ea09ee3..0da9187e 100644 --- a/src/sys/signalfd.rs +++ b/src/sys/signalfd.rs @@ -79,7 +79,7 @@ pub fn signalfd(fd: RawFd, mask: &SigSet, flags: SfdFlags) -> Result<RawFd> { /// Err(err) => (), // some error happend /// } /// ``` -#[derive(Debug)] +#[derive(Clone, Debug, Eq, Hash, PartialEq)] pub struct SignalFd(RawFd); impl SignalFd { diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs index c7d6d581..6292bb02 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs @@ -4,15 +4,14 @@ use {Error, Result}; use errno::Errno; use features; -use libc::{self, c_void, c_int, socklen_t, size_t, pid_t, uid_t, gid_t}; -use std::{mem, ptr, slice}; +use libc::{self, c_void, c_int, socklen_t, size_t}; +use std::{fmt, mem, ptr, slice}; use std::os::unix::io::RawFd; use sys::time::TimeVal; use sys::uio::IoVec; mod addr; mod ffi; -mod multicast; pub mod sockopt; /* @@ -34,22 +33,14 @@ pub use self::addr::{ pub use ::sys::socket::addr::netlink::NetlinkAddr; pub use libc::{ - in_addr, - in6_addr, + sa_family_t, sockaddr, sockaddr_in, sockaddr_in6, + sockaddr_storage, sockaddr_un, - sa_family_t, -}; - -pub use self::multicast::{ - ip_mreq, - ipv6_mreq, }; -pub use libc::sockaddr_storage; - /// These constants are used to specify the communication semantics /// when creating a socket with [`socket()`](fn.socket.html) #[derive(Clone, Copy, PartialEq, Eq, Debug)] @@ -77,6 +68,7 @@ pub enum SockType { /// Constants used in [`socket`](fn.socket.html) and [`socketpair`](fn.socketpair.html) /// to specify the protocol to use. #[repr(i32)] +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] pub enum SockProtocol { /// TCP protocol ([ip(7)](http://man7.org/linux/man-pages/man7/ip.7.html)) Tcp = libc::IPPROTO_TCP, @@ -174,6 +166,121 @@ libc_bitflags!{ } } +cfg_if! { + if #[cfg(all(target_os = "linux", not(target_arch = "arm")))] { + /// Unix credentials of the sending process. + /// + /// This struct is used with the `SO_PEERCRED` ancillary message for UNIX sockets. + #[repr(C)] + #[derive(Clone, Copy)] + pub struct UnixCredentials(libc::ucred); + + impl UnixCredentials { + /// Returns the process identifier + pub fn pid(&self) -> libc::pid_t { + self.0.pid + } + + /// Returns the user identifier + pub fn uid(&self) -> libc::uid_t { + self.0.uid + } + + /// Returns the group identifier + pub fn gid(&self) -> libc::gid_t { + self.0.gid + } + } + + impl PartialEq for UnixCredentials { + fn eq(&self, other: &Self) -> bool { + self.0.pid == other.0.pid && self.0.uid == other.0.uid && self.0.gid == other.0.gid + } + } + impl Eq for UnixCredentials {} + + impl fmt::Debug for UnixCredentials { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("UnixCredentials") + .field("pid", &self.0.pid) + .field("uid", &self.0.uid) + .field("gid", &self.0.gid) + .finish() + } + } + } +} + +/// Request for multicast socket operations +/// +/// This is a wrapper type around `ip_mreq`. +#[repr(C)] +#[derive(Clone, Copy)] +pub struct IpMembershipRequest(libc::ip_mreq); + +impl IpMembershipRequest { + /// Instantiate a new `IpMembershipRequest` + /// + /// If `interface` is `None`, then `Ipv4Addr::any()` will be used for the interface. + pub fn new(group: Ipv4Addr, interface: Option<Ipv4Addr>) -> Self { + IpMembershipRequest(libc::ip_mreq { + imr_multiaddr: group.0, + imr_interface: interface.unwrap_or(Ipv4Addr::any()).0, + }) + } +} + +impl PartialEq for IpMembershipRequest { + fn eq(&self, other: &Self) -> bool { + self.0.imr_multiaddr.s_addr == other.0.imr_multiaddr.s_addr + && self.0.imr_interface.s_addr == other.0.imr_interface.s_addr + } +} +impl Eq for IpMembershipRequest {} + +impl fmt::Debug for IpMembershipRequest { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("IpMembershipRequest") + .field("imr_multiaddr", &self.0.imr_multiaddr.s_addr) + .field("imr_interface", &self.0.imr_interface.s_addr) + .finish() + } +} + +/// Request for ipv6 multicast socket operations +/// +/// This is a wrapper type around `ipv6_mreq`. +#[repr(C)] +#[derive(Clone, Copy)] +pub struct Ipv6MembershipRequest(libc::ipv6_mreq); + +impl Ipv6MembershipRequest { + /// Instantiate a new `Ipv6MembershipRequest` + pub fn new(group: Ipv6Addr) -> Self { + Ipv6MembershipRequest(libc::ipv6_mreq { + ipv6mr_multiaddr: group.0, + ipv6mr_interface: 0, + }) + } +} + +impl PartialEq for Ipv6MembershipRequest { + fn eq(&self, other: &Self) -> bool { + self.0.ipv6mr_multiaddr.s6_addr == other.0.ipv6mr_multiaddr.s6_addr && + self.0.ipv6mr_interface == other.0.ipv6mr_interface + } +} +impl Eq for Ipv6MembershipRequest {} + +impl fmt::Debug for Ipv6MembershipRequest { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Ipv6MembershipRequest") + .field("ipv6mr_multiaddr", &self.0.ipv6mr_multiaddr.s6_addr) + .field("ipv6mr_interface", &self.0.ipv6mr_interface) + .finish() + } +} + /// Copy the in-memory representation of src into the byte slice dst, /// updating the slice to point to the remainder of dst only. Unsafe /// because it exposes all bytes in src, which may be UB if some of them @@ -799,21 +906,6 @@ pub fn send(fd: RawFd, buf: &[u8], flags: MsgFlags) -> Result<usize> { Errno::result(ret).map(|r| r as usize) } -#[repr(C)] -#[derive(Clone, Copy, Debug)] -pub struct linger { - pub l_onoff: c_int, - pub l_linger: c_int -} - -#[repr(C)] -#[derive(Clone, Copy, PartialEq, Eq, Debug)] -pub struct ucred { - pid: pid_t, - uid: uid_t, - gid: gid_t, -} - /* * * ===== Socket Options ===== @@ -825,13 +917,14 @@ pub struct ucred { /// /// [Further reading](http://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html) #[repr(i32)] +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] pub enum SockLevel { Socket = libc::SOL_SOCKET, Tcp = libc::IPPROTO_TCP, Ip = libc::IPPROTO_IP, Ipv6 = libc::IPPROTO_IPV6, Udp = libc::IPPROTO_UDP, - #[cfg(any(target_os = "linux", target_os = "android"))] + #[cfg(any(target_os = "android", target_os = "linux"))] Netlink = libc::SOL_NETLINK, } @@ -938,7 +1031,7 @@ pub unsafe fn sockaddr_storage_to_addr( } -#[derive(Clone, Copy, PartialEq, Eq, Debug)] +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] pub enum Shutdown { /// Further receptions will be disallowed. Read, @@ -964,9 +1057,3 @@ pub fn shutdown(df: RawFd, how: Shutdown) -> Result<()> { Errno::result(shutdown(df, how)).map(drop) } } - -#[test] -pub fn test_struct_sizes() { - use nixtest; - nixtest::assert_size_of::<sockaddr_storage>("sockaddr_storage"); -} diff --git a/src/sys/socket/multicast.rs b/src/sys/socket/multicast.rs deleted file mode 100644 index 7561bb35..00000000 --- a/src/sys/socket/multicast.rs +++ /dev/null @@ -1,40 +0,0 @@ -use super::addr::{Ipv4Addr, Ipv6Addr}; -use libc::{in_addr, in6_addr, c_uint}; -use std::fmt; - -#[repr(C)] -#[derive(Clone, Copy)] -pub struct ip_mreq { - pub imr_multiaddr: in_addr, - pub imr_interface: in_addr, -} - -impl fmt::Debug for ip_mreq { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - write!(fmt, "ip_mreq {{ imr_multiaddr: {{ s_addr: 0x{:x} }}, imr_interface: {{ s_addr: 0x{:x} }} }}", - self.imr_multiaddr.s_addr, self.imr_interface.s_addr) - } -} - -impl ip_mreq { - pub fn new(group: Ipv4Addr, interface: Option<Ipv4Addr>) -> ip_mreq { - ip_mreq { - imr_multiaddr: group.0, - imr_interface: interface.unwrap_or(Ipv4Addr::any()).0 - } - } -} - -pub struct ipv6_mreq { - pub ipv6mr_multiaddr: in6_addr, - pub ipv6mr_interface: c_uint, -} - -impl ipv6_mreq { - pub fn new(group: Ipv6Addr) -> ipv6_mreq { - ipv6_mreq { - ipv6mr_multiaddr: group.0, - ipv6mr_interface: 0, - } - } -} diff --git a/src/sys/socket/sockopt.rs b/src/sys/socket/sockopt.rs index 4741ec66..065d3101 100644 --- a/src/sys/socket/sockopt.rs +++ b/src/sys/socket/sockopt.rs @@ -132,17 +132,23 @@ macro_rules! sockopt_impl { sockopt_impl!(Both, ReuseAddr, libc::SOL_SOCKET, libc::SO_REUSEADDR, bool); sockopt_impl!(Both, ReusePort, libc::SOL_SOCKET, libc::SO_REUSEPORT, bool); sockopt_impl!(Both, TcpNoDelay, libc::IPPROTO_TCP, libc::TCP_NODELAY, bool); -sockopt_impl!(Both, Linger, libc::SOL_SOCKET, libc::SO_LINGER, super::linger); -sockopt_impl!(SetOnly, IpAddMembership, libc::IPPROTO_IP, libc::IP_ADD_MEMBERSHIP, super::ip_mreq); -sockopt_impl!(SetOnly, IpDropMembership, libc::IPPROTO_IP, libc::IP_DROP_MEMBERSHIP, super::ip_mreq); -#[cfg(not(any(target_os = "dragonfly", target_os = "freebsd", target_os = "ios", target_os = "macos", target_os = "netbsd", target_os = "openbsd")))] -sockopt_impl!(SetOnly, Ipv6AddMembership, libc::IPPROTO_IPV6, libc::IPV6_ADD_MEMBERSHIP, super::ipv6_mreq); -#[cfg(not(any(target_os = "dragonfly", target_os = "freebsd", target_os = "ios", target_os = "macos", target_os = "netbsd", target_os = "openbsd")))] -sockopt_impl!(SetOnly, Ipv6DropMembership, libc::IPPROTO_IPV6, libc::IPV6_DROP_MEMBERSHIP, super::ipv6_mreq); -#[cfg(any(target_os = "dragonfly", target_os = "freebsd", target_os = "ios", target_os = "macos", target_os = "netbsd", target_os = "openbsd"))] -sockopt_impl!(SetOnly, Ipv6AddMembership, libc::IPPROTO_IPV6, libc::IPV6_JOIN_GROUP, super::ipv6_mreq); -#[cfg(any(target_os = "dragonfly", target_os = "freebsd", target_os = "ios", target_os = "macos", target_os = "netbsd", target_os = "openbsd"))] -sockopt_impl!(SetOnly, Ipv6DropMembership, libc::IPPROTO_IPV6, libc::IPV6_LEAVE_GROUP, super::ipv6_mreq); +sockopt_impl!(Both, Linger, libc::SOL_SOCKET, libc::SO_LINGER, libc::linger); +sockopt_impl!(SetOnly, IpAddMembership, libc::IPPROTO_IP, libc::IP_ADD_MEMBERSHIP, super::IpMembershipRequest); +sockopt_impl!(SetOnly, IpDropMembership, libc::IPPROTO_IP, libc::IP_DROP_MEMBERSHIP, super::IpMembershipRequest); +cfg_if! { + if #[cfg(any(target_os = "android", target_os = "linux"))] { + sockopt_impl!(SetOnly, Ipv6AddMembership, libc::IPPROTO_IPV6, libc::IPV6_ADD_MEMBERSHIP, super::Ipv6MembershipRequest); + sockopt_impl!(SetOnly, Ipv6DropMembership, libc::IPPROTO_IPV6, libc::IPV6_DROP_MEMBERSHIP, super::Ipv6MembershipRequest); + } else if #[cfg(any(target_os = "dragonfly", + target_os = "freebsd", + target_os = "ios", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd"))] { + sockopt_impl!(SetOnly, Ipv6AddMembership, libc::IPPROTO_IPV6, libc::IPV6_JOIN_GROUP, super::Ipv6MembershipRequest); + sockopt_impl!(SetOnly, Ipv6DropMembership, libc::IPPROTO_IPV6, libc::IPV6_LEAVE_GROUP, super::Ipv6MembershipRequest); + } +} sockopt_impl!(Both, IpMulticastTtl, libc::IPPROTO_IP, libc::IP_MULTICAST_TTL, u8); sockopt_impl!(Both, IpMulticastLoop, libc::IPPROTO_IP, libc::IP_MULTICAST_LOOP, bool); sockopt_impl!(Both, ReceiveTimeout, libc::SOL_SOCKET, libc::SO_RCVTIMEO, TimeVal); @@ -152,7 +158,7 @@ sockopt_impl!(Both, OobInline, libc::SOL_SOCKET, libc::SO_OOBINLINE, bool); sockopt_impl!(GetOnly, SocketError, libc::SOL_SOCKET, libc::SO_ERROR, i32); sockopt_impl!(Both, KeepAlive, libc::SOL_SOCKET, libc::SO_KEEPALIVE, bool); #[cfg(all(target_os = "linux", not(target_arch="arm")))] -sockopt_impl!(GetOnly, PeerCredentials, libc::SOL_SOCKET, libc::SO_PEERCRED, super::ucred); +sockopt_impl!(GetOnly, PeerCredentials, libc::SOL_SOCKET, libc::SO_PEERCRED, super::UnixCredentials); #[cfg(any(target_os = "macos", target_os = "ios"))] sockopt_impl!(Both, TcpKeepAlive, libc::IPPROTO_TCP, libc::TCP_KEEPALIVE, u32); @@ -384,7 +390,7 @@ mod test { let a_cred = getsockopt(a, super::PeerCredentials).unwrap(); let b_cred = getsockopt(b, super::PeerCredentials).unwrap(); assert_eq!(a_cred, b_cred); - assert!(a_cred.pid != 0); + assert!(a_cred.pid() != 0); } #[test] diff --git a/src/sys/statvfs.rs b/src/sys/statvfs.rs index 0a0dab7f..fbd0570e 100644 --- a/src/sys/statvfs.rs +++ b/src/sys/statvfs.rs @@ -10,45 +10,45 @@ use libc::{self, c_ulong}; use {Result, NixPath}; use errno::Errno; -bitflags!( +libc_bitflags!( /// File system mount Flags #[repr(C)] #[derive(Default)] pub struct FsFlags: c_ulong { /// Read Only - const RDONLY = libc::ST_RDONLY; + ST_RDONLY; /// Do not allow the set-uid bits to have an effect - const NOSUID = libc::ST_NOSUID; + ST_NOSUID; /// Do not interpret character or block-special devices #[cfg(any(target_os = "android", target_os = "linux"))] - const NODEV = libc::ST_NODEV; + ST_NODEV; /// Do not allow execution of binaries on the filesystem #[cfg(any(target_os = "android", target_os = "linux"))] - const NOEXEC = libc::ST_NOEXEC; + ST_NOEXEC; /// All IO should be done synchronously #[cfg(any(target_os = "android", target_os = "linux"))] - const SYNCHRONOUS = libc::ST_SYNCHRONOUS; + ST_SYNCHRONOUS; /// Allow mandatory locks on the filesystem #[cfg(any(target_os = "android", target_os = "linux"))] - const MANDLOCK = libc::ST_MANDLOCK; + ST_MANDLOCK; /// Write on file/directory/symlink #[cfg(any(target_os = "android", target_os = "linux"))] - const WRITE = libc::ST_WRITE; + ST_WRITE; /// Append-only file #[cfg(any(target_os = "android", target_os = "linux"))] - const APPEND = libc::ST_APPEND; + ST_APPEND; /// Immutable file #[cfg(any(target_os = "android", target_os = "linux"))] - const IMMUTABLE = libc::ST_IMMUTABLE; + ST_IMMUTABLE; /// Do not update access times on files #[cfg(any(target_os = "android", target_os = "linux"))] - const NOATIME = libc::ST_NOATIME; + ST_NOATIME; /// Do not update access times on files #[cfg(any(target_os = "android", target_os = "linux"))] - const NODIRATIME = libc::ST_NODIRATIME; + ST_NODIRATIME; /// Update access time relative to modify/change time #[cfg(any(target_os = "android", all(target_os = "linux", not(target_env = "musl"))))] - const RELATIME = libc::ST_RELATIME; + ST_RELATIME; } ); diff --git a/src/sys/uio.rs b/src/sys/uio.rs index cd161423..c785225b 100644 --- a/src/sys/uio.rs +++ b/src/sys/uio.rs @@ -169,9 +169,3 @@ impl<'a> IoVec<&'a mut [u8]> { }, PhantomData) } } - -#[test] -pub fn test_size_of_io_vec() { - use nixtest; - nixtest::assert_size_of::<IoVec<&[u8]>>("iovec"); -} diff --git a/src/sys/wait.rs b/src/sys/wait.rs index 6243634f..ba5dc27a 100644 --- a/src/sys/wait.rs +++ b/src/sys/wait.rs @@ -130,8 +130,8 @@ fn signaled(status: i32) -> bool { unsafe { libc::WIFSIGNALED(status) } } -fn term_signal(status: i32) -> Signal { - Signal::from_c_int(unsafe { libc::WTERMSIG(status) }).unwrap() +fn term_signal(status: i32) -> Result<Signal> { + Signal::from_c_int(unsafe { libc::WTERMSIG(status) }) } fn dumped_core(status: i32) -> bool { @@ -142,8 +142,8 @@ fn stopped(status: i32) -> bool { unsafe { libc::WIFSTOPPED(status) } } -fn stop_signal(status: i32) -> Signal { - Signal::from_c_int(unsafe { libc::WSTOPSIG(status) }).unwrap() +fn stop_signal(status: i32) -> Result<Signal> { + Signal::from_c_int(unsafe { libc::WSTOPSIG(status) }) } fn syscall_stop(status: i32) -> bool { @@ -162,34 +162,53 @@ fn continued(status: i32) -> bool { unsafe { libc::WIFCONTINUED(status) } } -fn decode(pid: Pid, status: i32) -> WaitStatus { - if exited(status) { - WaitStatus::Exited(pid, exit_status(status)) - } else if signaled(status) { - WaitStatus::Signaled(pid, term_signal(status), dumped_core(status)) - } else if stopped(status) { - cfg_if! { - if #[cfg(any(target_os = "linux", target_os = "android"))] { - fn decode_stopped(pid: Pid, status: i32) -> WaitStatus { - let status_additional = stop_additional(status); - if syscall_stop(status) { - WaitStatus::PtraceSyscall(pid) - } else if status_additional == 0 { - WaitStatus::Stopped(pid, stop_signal(status)) - } else { - WaitStatus::PtraceEvent(pid, stop_signal(status), stop_additional(status)) +impl WaitStatus { + /// Convert a raw `wstatus` as returned by `waitpid`/`wait` into a `WaitStatus` + /// + /// # Errors + /// + /// Returns an `Error` corresponding to `EINVAL` for invalid status values. + /// + /// # Examples + /// + /// Convert a `wstatus` obtained from `libc::waitpid` into a `WaitStatus`: + /// + /// ``` + /// use nix::sys::wait::WaitStatus; + /// use nix::sys::signal::Signal; + /// let pid = nix::unistd::Pid::from_raw(1); + /// let status = WaitStatus::from_raw(pid, 0x0002); + /// assert_eq!(status, Ok(WaitStatus::Signaled(pid, Signal::SIGINT, false))); + /// ``` + pub fn from_raw(pid: Pid, status: i32) -> Result<WaitStatus> { + Ok(if exited(status) { + WaitStatus::Exited(pid, exit_status(status)) + } else if signaled(status) { + WaitStatus::Signaled(pid, try!(term_signal(status)), dumped_core(status)) + } else if stopped(status) { + cfg_if! { + if #[cfg(any(target_os = "linux", target_os = "android"))] { + fn decode_stopped(pid: Pid, status: i32) -> Result<WaitStatus> { + let status_additional = stop_additional(status); + Ok(if syscall_stop(status) { + WaitStatus::PtraceSyscall(pid) + } else if status_additional == 0 { + WaitStatus::Stopped(pid, try!(stop_signal(status))) + } else { + WaitStatus::PtraceEvent(pid, try!(stop_signal(status)), stop_additional(status)) + }) + } + } else { + fn decode_stopped(pid: Pid, status: i32) -> Result<WaitStatus> { + Ok(WaitStatus::Stopped(pid, try!(stop_signal(status)))) } - } - } else { - fn decode_stopped(pid: Pid, status: i32) -> WaitStatus { - WaitStatus::Stopped(pid, stop_signal(status)) } } - } - decode_stopped(pid, status) - } else { - assert!(continued(status)); - WaitStatus::Continued(pid) + return decode_stopped(pid, status); + } else { + assert!(continued(status)); + WaitStatus::Continued(pid) + }) } } @@ -211,10 +230,10 @@ pub fn waitpid<P: Into<Option<Pid>>>(pid: P, options: Option<WaitPidFlag>) -> Re ) }; - Ok(match try!(Errno::result(res)) { - 0 => StillAlive, - res => decode(Pid::from_raw(res), status), - }) + match try!(Errno::result(res)) { + 0 => Ok(StillAlive), + res => WaitStatus::from_raw(Pid::from_raw(res), status), + } } pub fn wait() -> Result<WaitStatus> { diff --git a/src/unistd.rs b/src/unistd.rs index 81333b74..7a1c56c7 100644 --- a/src/unistd.rs +++ b/src/unistd.rs @@ -818,6 +818,7 @@ pub fn write(fd: RawFd, buf: &[u8]) -> Result<usize> { } /// Directive that tells [`lseek`] and [`lseek64`] what the offset is relative to. +/// /// [`lseek`]: ./fn.lseek.html /// [`lseek64`]: ./fn.lseek64.html #[repr(i32)] @@ -850,7 +851,7 @@ pub enum Whence { /// Move the read/write file offset. /// -/// See also [lseek(2)(http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html) +/// See also [lseek(2)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html) pub fn lseek(fd: RawFd, offset: libc::off_t, whence: Whence) -> Result<libc::off_t> { let res = unsafe { libc::lseek(fd, offset, whence as i32) }; @@ -879,10 +880,22 @@ pub fn pipe() -> Result<(RawFd, RawFd)> { } } -// libc only defines `pipe2` in `libc::notbsd`. -#[cfg(any(target_os = "linux", - target_os = "android", - target_os = "emscripten"))] +/// Like `pipe`, but allows setting certain file descriptor flags. +/// +/// The following flags are supported, and will be set atomically as the pipe is +/// created: +/// +/// `O_CLOEXEC`: Set the close-on-exec flag for the new file descriptors. +/// `O_NONBLOCK`: Set the non-blocking flag for the ends of the pipe. +/// +/// See also [pipe(2)](http://man7.org/linux/man-pages/man2/pipe.2.html) +#[cfg(any(target_os = "android", + target_os = "dragonfly", + target_os = "emscripten", + target_os = "freebsd", + target_os = "linux", + target_os = "netbsd", + target_os = "openbsd"))] pub fn pipe2(flags: OFlag) -> Result<(RawFd, RawFd)> { let mut fds: [c_int; 2] = unsafe { mem::uninitialized() }; @@ -893,9 +906,18 @@ pub fn pipe2(flags: OFlag) -> Result<(RawFd, RawFd)> { Ok((fds[0], fds[1])) } -#[cfg(not(any(target_os = "linux", - target_os = "android", - target_os = "emscripten")))] +/// Like `pipe`, but allows setting certain file descriptor flags. +/// +/// The following flags are supported, and will be set after the pipe is +/// created: +/// +/// `O_CLOEXEC`: Set the close-on-exec flag for the new file descriptors. +/// `O_NONBLOCK`: Set the non-blocking flag for the ends of the pipe. +#[cfg(any(target_os = "ios", target_os = "macos"))] +#[deprecated( + since="0.10.0", + note="pipe2(2) is not actually atomic on these platforms. Use pipe(2) and fcntl(2) instead" +)] pub fn pipe2(flags: OFlag) -> Result<(RawFd, RawFd)> { let mut fds: [c_int; 2] = unsafe { mem::uninitialized() }; @@ -908,9 +930,7 @@ pub fn pipe2(flags: OFlag) -> Result<(RawFd, RawFd)> { Ok((fds[0], fds[1])) } -#[cfg(not(any(target_os = "linux", - target_os = "android", - target_os = "emscripten")))] +#[cfg(any(target_os = "ios", target_os = "macos"))] fn pipe2_setflags(fd1: RawFd, fd2: RawFd, flags: OFlag) -> Result<()> { use fcntl::FdFlag; use fcntl::FcntlArg::F_SETFL; @@ -1127,12 +1147,24 @@ pub fn getgroups() -> Result<Vec<Gid>> { /// specific user and group. For example, given the user `www-data` with UID /// `33` and the group `backup` with the GID `34`, one could switch the user as /// follows: -/// ``` +/// +/// ```rust,no_run +/// # use std::error::Error; +/// # use nix::unistd::*; +/// # +/// # fn try_main() -> Result<(), Box<Error>> { /// let uid = Uid::from_raw(33); /// let gid = Gid::from_raw(34); /// setgroups(&[gid])?; /// setgid(gid)?; /// setuid(uid)?; +/// # +/// # Ok(()) +/// # } +/// # +/// # fn main() { +/// # try_main().unwrap(); +/// # } /// ``` #[cfg(not(any(target_os = "ios", target_os = "macos")))] pub fn setgroups(groups: &[Gid]) -> Result<()> { @@ -1248,13 +1280,26 @@ pub fn getgrouplist(user: &CStr, group: Gid) -> Result<Vec<Gid>> { /// UID and GID for the user in the system's password database (usually found /// in `/etc/passwd`). If the `www-data` user's UID and GID were `33` and `33`, /// respectively, one could switch the user as follows: -/// ``` +/// +/// ```rust,no_run +/// # use std::error::Error; +/// # use std::ffi::CString; +/// # use nix::unistd::*; +/// # +/// # fn try_main() -> Result<(), Box<Error>> { /// let user = CString::new("www-data").unwrap(); /// let uid = Uid::from_raw(33); /// let gid = Gid::from_raw(33); /// initgroups(&user, gid)?; /// setgid(gid)?; /// setuid(uid)?; +/// # +/// # Ok(()) +/// # } +/// # +/// # fn main() { +/// # try_main().unwrap(); +/// # } /// ``` #[cfg(not(any(target_os = "ios", target_os = "macos")))] pub fn initgroups(user: &CStr, group: Gid) -> Result<()> { @@ -1283,7 +1328,7 @@ pub fn pause() -> Result<()> { /// Suspend execution for an interval of time /// -/// See also [sleep(2)(http://pubs.opengroup.org/onlinepubs/009695399/functions/sleep.html#tag_03_705_05) +/// See also [sleep(2)](http://pubs.opengroup.org/onlinepubs/009695399/functions/sleep.html#tag_03_705_05) // Per POSIX, does not fail #[inline] pub fn sleep(seconds: libc::c_uint) -> c_uint { |