diff options
Diffstat (limited to 'src/sys')
-rw-r--r-- | src/sys/signalfd.rs | 7 | ||||
-rw-r--r-- | src/sys/socket/mod.rs | 9 | ||||
-rw-r--r-- | src/sys/statfs.rs | 58 |
3 files changed, 43 insertions, 31 deletions
diff --git a/src/sys/signalfd.rs b/src/sys/signalfd.rs index e3ded1f7..c43b4504 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(Clone, Debug, Eq, Hash, PartialEq)] +#[derive(Debug, Eq, Hash, PartialEq)] pub struct SignalFd(RawFd); impl SignalFd { @@ -116,7 +116,10 @@ impl SignalFd { impl Drop for SignalFd { fn drop(&mut self) { - let _ = unistd::close(self.0); + let e = unistd::close(self.0); + if !std::thread::panicking() && e == Err(Error::Sys(Errno::EBADF)) { + panic!("Closing an invalid file descriptor!"); + }; } } diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs index 38b910f1..11ed329f 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs @@ -1702,6 +1702,15 @@ pub fn sockaddr_storage_to_addr( Ok(SockAddr::Unix(UnixAddr(sun, pathlen))) } #[cfg(any(target_os = "android", target_os = "linux"))] + libc::AF_PACKET => { + use libc::sockaddr_ll; + assert_eq!(len as usize, mem::size_of::<sockaddr_ll>()); + let sll = unsafe { + *(addr as *const _ as *const sockaddr_ll) + }; + Ok(SockAddr::Link(LinkAddr(sll))) + } + #[cfg(any(target_os = "android", target_os = "linux"))] libc::AF_NETLINK => { use libc::sockaddr_nl; let snl = unsafe { diff --git a/src/sys/statfs.rs b/src/sys/statfs.rs index 8e90a58d..924d293f 100644 --- a/src/sys/statfs.rs +++ b/src/sys/statfs.rs @@ -31,63 +31,63 @@ pub struct FsType(pub libc::c_ulong); #[derive(Eq, Copy, Clone, PartialEq, Debug)] pub struct FsType(pub libc::c_long); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const ADFS_SUPER_MAGIC: FsType = FsType(libc::ADFS_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const AFFS_SUPER_MAGIC: FsType = FsType(libc::AFFS_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const CODA_SUPER_MAGIC: FsType = FsType(libc::CODA_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const CRAMFS_MAGIC: FsType = FsType(libc::CRAMFS_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const EFS_SUPER_MAGIC: FsType = FsType(libc::EFS_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const EXT2_SUPER_MAGIC: FsType = FsType(libc::EXT2_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const EXT3_SUPER_MAGIC: FsType = FsType(libc::EXT3_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const EXT4_SUPER_MAGIC: FsType = FsType(libc::EXT4_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const HPFS_SUPER_MAGIC: FsType = FsType(libc::HPFS_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const HUGETLBFS_MAGIC: FsType = FsType(libc::HUGETLBFS_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const ISOFS_SUPER_MAGIC: FsType = FsType(libc::ISOFS_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const JFFS2_SUPER_MAGIC: FsType = FsType(libc::JFFS2_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const MINIX_SUPER_MAGIC: FsType = FsType(libc::MINIX_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const MINIX_SUPER_MAGIC2: FsType = FsType(libc::MINIX_SUPER_MAGIC2); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const MINIX2_SUPER_MAGIC: FsType = FsType(libc::MINIX2_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const MINIX2_SUPER_MAGIC2: FsType = FsType(libc::MINIX2_SUPER_MAGIC2); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const MSDOS_SUPER_MAGIC: FsType = FsType(libc::MSDOS_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const NCP_SUPER_MAGIC: FsType = FsType(libc::NCP_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const NFS_SUPER_MAGIC: FsType = FsType(libc::NFS_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const OPENPROM_SUPER_MAGIC: FsType = FsType(libc::OPENPROM_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const OVERLAYFS_SUPER_MAGIC: FsType = FsType(libc::OVERLAYFS_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const PROC_SUPER_MAGIC: FsType = FsType(libc::PROC_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const QNX4_SUPER_MAGIC: FsType = FsType(libc::QNX4_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const REISERFS_SUPER_MAGIC: FsType = FsType(libc::REISERFS_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const SMB_SUPER_MAGIC: FsType = FsType(libc::SMB_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const TMPFS_MAGIC: FsType = FsType(libc::TMPFS_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const USBDEVICE_SUPER_MAGIC: FsType = FsType(libc::USBDEVICE_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const CGROUP_SUPER_MAGIC: FsType = FsType(libc::CGROUP_SUPER_MAGIC); -#[cfg(all(target_os = "linux", not(target_env = "musl"), not(target_arch = "s390x")))] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] pub const CGROUP2_SUPER_MAGIC: FsType = FsType(libc::CGROUP2_SUPER_MAGIC); impl Statfs { |