Skip to content

Commit ed91e1f

Browse files
authored
Update to linux-raw-sys 0.4.8. (#862)
This provides `LINUX_REBOOT_*` and `*SO_ORIGINAL_DST`.
1 parent 8bbb1a9 commit ed91e1f

2 files changed

Lines changed: 36 additions & 38 deletions

File tree

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ once_cell = { version = "1.5.2", optional = true }
3636
# libc backend can be selected via adding `--cfg=rustix_use_libc` to
3737
# `RUSTFLAGS` or enabling the `use-libc` cargo feature.
3838
[target.'cfg(all(not(rustix_use_libc), not(miri), target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))'.dependencies]
39-
linux-raw-sys = { version = "0.4.7", default-features = false, features = ["general", "errno", "ioctl", "no_std", "elf"] }
39+
linux-raw-sys = { version = "0.4.8", default-features = false, features = ["general", "errno", "ioctl", "no_std", "elf"] }
4040
libc_errno = { package = "errno", version = "0.3.1", default-features = false, optional = true }
4141
libc = { version = "0.2.148", default-features = false, features = ["extra_traits"], optional = true }
4242

@@ -53,7 +53,7 @@ libc = { version = "0.2.148", default-features = false, features = ["extra_trait
5353
# Some syscalls do not have libc wrappers, such as in `io_uring`. For these,
5454
# the libc backend uses the linux-raw-sys ABI and `libc::syscall`.
5555
[target.'cfg(all(any(target_os = "android", target_os = "linux"), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64")))))))'.dependencies]
56-
linux-raw-sys = { version = "0.4.3", default-features = false, features = ["general", "ioctl", "no_std"] }
56+
linux-raw-sys = { version = "0.4.8", default-features = false, features = ["general", "ioctl", "no_std"] }
5757

5858
# For the libc backend on Windows, use the Winsock2 API in windows-sys.
5959
[target.'cfg(windows)'.dependencies.windows-sys]

src/backend/linux_raw/c.rs

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#![allow(unused_imports)]
77
#![allow(non_camel_case_types)]
88

9-
pub type size_t = usize;
9+
pub(crate) type size_t = usize;
1010
pub(crate) use linux_raw_sys::ctypes::*;
1111
pub(crate) use linux_raw_sys::errno::EINVAL;
1212
pub(crate) use linux_raw_sys::ioctl::{FIONBIO, FIONREAD};
@@ -58,28 +58,24 @@ pub(crate) use linux_raw_sys::{
5858
AF_IEEE802154, AF_INET, AF_INET6, AF_IPX, AF_IRDA, AF_ISDN, AF_IUCV, AF_KEY, AF_LLC,
5959
AF_NETBEUI, AF_NETLINK, AF_NETROM, AF_PACKET, AF_PHONET, AF_PPPOX, AF_RDS, AF_ROSE,
6060
AF_RXRPC, AF_SECURITY, AF_SNA, AF_TIPC, AF_UNIX, AF_UNSPEC, AF_WANPIPE, AF_X25,
61-
IPPROTO_FRAGMENT, IPPROTO_ICMPV6, IPPROTO_MH, IPPROTO_ROUTING, IPV6_ADD_MEMBERSHIP,
62-
IPV6_DROP_MEMBERSHIP, IPV6_FREEBIND, IPV6_MULTICAST_HOPS, IPV6_MULTICAST_LOOP,
63-
IPV6_RECVTCLASS, IPV6_TCLASS, IPV6_UNICAST_HOPS, IPV6_V6ONLY, IP_ADD_MEMBERSHIP,
64-
IP_ADD_SOURCE_MEMBERSHIP, IP_DROP_MEMBERSHIP, IP_DROP_SOURCE_MEMBERSHIP, IP_FREEBIND,
65-
IP_MULTICAST_LOOP, IP_MULTICAST_TTL, IP_RECVTOS, IP_TOS, IP_TTL, MSG_CMSG_CLOEXEC,
66-
MSG_CONFIRM, MSG_DONTROUTE, MSG_DONTWAIT, MSG_EOR, MSG_ERRQUEUE, MSG_MORE, MSG_NOSIGNAL,
67-
MSG_OOB, MSG_PEEK, MSG_TRUNC, MSG_WAITALL, SCM_CREDENTIALS, SCM_RIGHTS, SHUT_RD, SHUT_RDWR,
68-
SHUT_WR, SOCK_DGRAM, SOCK_RAW, SOCK_RDM, SOCK_SEQPACKET, SOCK_STREAM, SOL_SOCKET,
69-
SO_ACCEPTCONN, SO_BROADCAST, SO_COOKIE, SO_DOMAIN, SO_ERROR, SO_INCOMING_CPU, SO_KEEPALIVE,
70-
SO_LINGER, SO_OOBINLINE, SO_PASSCRED, SO_PROTOCOL, SO_RCVBUF, SO_RCVTIMEO_NEW,
71-
SO_RCVTIMEO_NEW as SO_RCVTIMEO, SO_RCVTIMEO_OLD, SO_REUSEADDR, SO_REUSEPORT, SO_SNDBUF,
72-
SO_SNDTIMEO_NEW, SO_SNDTIMEO_NEW as SO_SNDTIMEO, SO_SNDTIMEO_OLD, SO_TYPE, TCP_CONGESTION,
73-
TCP_CORK, TCP_KEEPCNT, TCP_KEEPIDLE, TCP_KEEPINTVL, TCP_NODELAY, TCP_QUICKACK,
74-
TCP_THIN_LINEAR_TIMEOUTS, TCP_USER_TIMEOUT,
61+
IP6T_SO_ORIGINAL_DST, IPPROTO_FRAGMENT, IPPROTO_ICMPV6, IPPROTO_MH, IPPROTO_ROUTING,
62+
IPV6_ADD_MEMBERSHIP, IPV6_DROP_MEMBERSHIP, IPV6_FREEBIND, IPV6_MULTICAST_HOPS,
63+
IPV6_MULTICAST_LOOP, IPV6_RECVTCLASS, IPV6_TCLASS, IPV6_UNICAST_HOPS, IPV6_V6ONLY,
64+
IP_ADD_MEMBERSHIP, IP_ADD_SOURCE_MEMBERSHIP, IP_DROP_MEMBERSHIP, IP_DROP_SOURCE_MEMBERSHIP,
65+
IP_FREEBIND, IP_MULTICAST_LOOP, IP_MULTICAST_TTL, IP_RECVTOS, IP_TOS, IP_TTL,
66+
MSG_CMSG_CLOEXEC, MSG_CONFIRM, MSG_DONTROUTE, MSG_DONTWAIT, MSG_EOR, MSG_ERRQUEUE,
67+
MSG_MORE, MSG_NOSIGNAL, MSG_OOB, MSG_PEEK, MSG_TRUNC, MSG_WAITALL, SCM_CREDENTIALS,
68+
SCM_RIGHTS, SHUT_RD, SHUT_RDWR, SHUT_WR, SOCK_DGRAM, SOCK_RAW, SOCK_RDM, SOCK_SEQPACKET,
69+
SOCK_STREAM, SOL_SOCKET, SO_ACCEPTCONN, SO_BROADCAST, SO_COOKIE, SO_DOMAIN, SO_ERROR,
70+
SO_INCOMING_CPU, SO_KEEPALIVE, SO_LINGER, SO_OOBINLINE, SO_ORIGINAL_DST, SO_PASSCRED,
71+
SO_PROTOCOL, SO_RCVBUF, SO_RCVTIMEO_NEW, SO_RCVTIMEO_NEW as SO_RCVTIMEO, SO_RCVTIMEO_OLD,
72+
SO_REUSEADDR, SO_REUSEPORT, SO_SNDBUF, SO_SNDTIMEO_NEW, SO_SNDTIMEO_NEW as SO_SNDTIMEO,
73+
SO_SNDTIMEO_OLD, SO_TYPE, TCP_CONGESTION, TCP_CORK, TCP_KEEPCNT, TCP_KEEPIDLE,
74+
TCP_KEEPINTVL, TCP_NODELAY, TCP_QUICKACK, TCP_THIN_LINEAR_TIMEOUTS, TCP_USER_TIMEOUT,
7575
},
7676
netlink::*,
7777
};
7878

79-
// TODO: Modify linux-raw-sys to include these.
80-
pub(crate) const IP6T_SO_ORIGINAL_DST: u32 = 80;
81-
pub(crate) const SO_ORIGINAL_DST: u32 = 80;
82-
8379
// Cast away bindgen's `enum` type to make these consistent with the other
8480
// `setsockopt`/`getsockopt` level values.
8581
#[cfg(feature = "net")]
@@ -271,25 +267,27 @@ pub(crate) const CLOCK_THREAD_CPUTIME_ID: c_int =
271267
pub(crate) const CLOCK_PROCESS_CPUTIME_ID: c_int =
272268
linux_raw_sys::general::CLOCK_PROCESS_CPUTIME_ID as _;
273269

274-
#[allow(overflowing_literals)]
275-
#[allow(dead_code)]
270+
#[cfg(feature = "system")]
276271
mod reboot_symbols {
277-
use linux_raw_sys::ctypes::*;
272+
use super::c_int;
278273

279-
pub(crate) const LINUX_REBOOT_MAGIC1: c_int = 0xfee1dead;
280-
pub(crate) const LINUX_REBOOT_MAGIC2: c_int = 672274793;
281-
pub(crate) const LINUX_REBOOT_MAGIC2A: c_int = 85072278;
282-
pub(crate) const LINUX_REBOOT_MAGIC2B: c_int = 369367448;
283-
pub(crate) const LINUX_REBOOT_MAGIC2C: c_int = 537993216;
274+
pub(crate) const LINUX_REBOOT_MAGIC1: c_int = linux_raw_sys::general::LINUX_REBOOT_MAGIC1 as _;
275+
pub(crate) const LINUX_REBOOT_MAGIC2: c_int = linux_raw_sys::general::LINUX_REBOOT_MAGIC2 as _;
284276

285-
pub(crate) const LINUX_REBOOT_CMD_RESTART: c_int = 0x01234567;
286-
pub(crate) const LINUX_REBOOT_CMD_HALT: c_int = 0xCDEF0123;
287-
pub(crate) const LINUX_REBOOT_CMD_CAD_ON: c_int = 0x89ABCDEF;
288-
pub(crate) const LINUX_REBOOT_CMD_CAD_OFF: c_int = 0x00000000;
289-
pub(crate) const LINUX_REBOOT_CMD_POWER_OFF: c_int = 0x4321FEDC;
290-
pub(crate) const LINUX_REBOOT_CMD_RESTART2: c_int = 0xA1B2C3D4;
291-
pub(crate) const LINUX_REBOOT_CMD_SW_SUSPEND: c_int = 0xD000FCE2;
292-
pub(crate) const LINUX_REBOOT_CMD_KEXEC: c_int = 0x45584543;
277+
pub(crate) const LINUX_REBOOT_CMD_RESTART: c_int =
278+
linux_raw_sys::general::LINUX_REBOOT_CMD_RESTART as _;
279+
pub(crate) const LINUX_REBOOT_CMD_HALT: c_int =
280+
linux_raw_sys::general::LINUX_REBOOT_CMD_HALT as _;
281+
pub(crate) const LINUX_REBOOT_CMD_CAD_ON: c_int =
282+
linux_raw_sys::general::LINUX_REBOOT_CMD_CAD_ON as _;
283+
pub(crate) const LINUX_REBOOT_CMD_CAD_OFF: c_int =
284+
linux_raw_sys::general::LINUX_REBOOT_CMD_CAD_OFF as _;
285+
pub(crate) const LINUX_REBOOT_CMD_POWER_OFF: c_int =
286+
linux_raw_sys::general::LINUX_REBOOT_CMD_POWER_OFF as _;
287+
pub(crate) const LINUX_REBOOT_CMD_SW_SUSPEND: c_int =
288+
linux_raw_sys::general::LINUX_REBOOT_CMD_SW_SUSPEND as _;
289+
pub(crate) const LINUX_REBOOT_CMD_KEXEC: c_int =
290+
linux_raw_sys::general::LINUX_REBOOT_CMD_KEXEC as _;
293291
}
294-
292+
#[cfg(feature = "system")]
295293
pub(crate) use reboot_symbols::*;

0 commit comments

Comments
 (0)