Skip to content

Commit

Permalink
Auto merge of #3156 - ribalda:kexec, r=JohnTitor
Browse files Browse the repository at this point in the history
linux: add kexec flags

This adds `KEXEC_ARCH_MASK`, `KEXEC_FILE_NO_INITRAMFS`, `KEXEC_FILE_ON_CRASH`, `KEXEC_FILE_UNLOAD`, `KEXEC_ON_CRASH`, and `KEXEC_PRESERVE_CONTEXT` constants on Linux and Android.

Those are used by `kexec` and `kexec_file_load` syscalls.
  • Loading branch information
bors committed Mar 23, 2023
2 parents 57760b3 + e1f4836 commit ac1cb39
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1631,6 +1631,7 @@ fn test_android(target: &str) {
"linux/if_link.h",
"linux/rtnetlink.h",
"linux/if_tun.h",
"linux/kexec.h",
"linux/magic.h",
"linux/membarrier.h",
"linux/memfd.h",
Expand Down Expand Up @@ -3250,6 +3251,7 @@ fn test_linux(target: &str) {
"linux/if_tun.h",
"linux/input.h",
"linux/ipv6.h",
"linux/kexec.h",
"linux/keyctl.h",
"linux/magic.h",
"linux/memfd.h",
Expand Down Expand Up @@ -3464,6 +3466,7 @@ fn test_linux(target: &str) {
|| name.starts_with("F_")
|| name.starts_with("FALLOC_FL_")
|| name.starts_with("IFLA_")
|| name.starts_with("KEXEC_")
|| name.starts_with("MS_")
|| name.starts_with("MSG_")
|| name.starts_with("OPEN_TREE_")
Expand Down
6 changes: 6 additions & 0 deletions libc-test/semver/android.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,12 @@ IXANY
IXOFF
IXON
JFFS2_SUPER_MAGIC
KEXEC_ARCH_MASK
KEXEC_FILE_NO_INITRAMFS
KEXEC_FILE_ON_CRASH
KEXEC_FILE_UNLOAD
KEXEC_ON_CRASH
KEXEC_PRESERVE_CONTEXT
KEY_CNT
KEY_MAX
LC_ADDRESS
Expand Down
6 changes: 6 additions & 0 deletions libc-test/semver/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,12 @@ J1939_PGN_MAX
J1939_PGN_PDU1_MAX
J1939_PGN_REQUEST
KERNEL_VERSION
KEXEC_ARCH_MASK
KEXEC_FILE_NO_INITRAMFS
KEXEC_FILE_ON_CRASH
KEXEC_FILE_UNLOAD
KEXEC_ON_CRASH
KEXEC_PRESERVE_CONTEXT
KEYCTL_ASSUME_AUTHORITY
KEYCTL_CHOWN
KEYCTL_CLEAR
Expand Down
8 changes: 8 additions & 0 deletions src/unix/linux_like/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1606,6 +1606,14 @@ pub const AI_ADDRCONFIG: ::c_int = 0x00000400;
pub const AI_V4MAPPED: ::c_int = 0x00000800;
pub const AI_DEFAULT: ::c_int = AI_V4MAPPED_CFG | AI_ADDRCONFIG;

// linux/kexec.h
pub const KEXEC_ON_CRASH: ::c_int = 0x00000001;
pub const KEXEC_PRESERVE_CONTEXT: ::c_int = 0x00000002;
pub const KEXEC_ARCH_MASK: ::c_int = 0xffff0000;
pub const KEXEC_FILE_UNLOAD: ::c_int = 0x00000001;
pub const KEXEC_FILE_ON_CRASH: ::c_int = 0x00000002;
pub const KEXEC_FILE_NO_INITRAMFS: ::c_int = 0x00000004;

pub const LINUX_REBOOT_MAGIC1: ::c_int = 0xfee1dead;
pub const LINUX_REBOOT_MAGIC2: ::c_int = 672274793;
pub const LINUX_REBOOT_MAGIC2A: ::c_int = 85072278;
Expand Down
8 changes: 8 additions & 0 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3550,6 +3550,14 @@ pub fn FUTEX_OP(op: ::c_int, oparg: ::c_int, cmp: ::c_int, cmparg: ::c_int) -> :
((op & 0xf) << 28) | ((cmp & 0xf) << 24) | ((oparg & 0xfff) << 12) | (cmparg & 0xfff)
}

// linux/kexec.h
pub const KEXEC_ON_CRASH: ::c_int = 0x00000001;
pub const KEXEC_PRESERVE_CONTEXT: ::c_int = 0x00000002;
pub const KEXEC_ARCH_MASK: ::c_int = 0xffff0000;
pub const KEXEC_FILE_UNLOAD: ::c_int = 0x00000001;
pub const KEXEC_FILE_ON_CRASH: ::c_int = 0x00000002;
pub const KEXEC_FILE_NO_INITRAMFS: ::c_int = 0x00000004;

// linux/reboot.h
pub const LINUX_REBOOT_MAGIC1: ::c_int = 0xfee1dead;
pub const LINUX_REBOOT_MAGIC2: ::c_int = 672274793;
Expand Down

0 comments on commit ac1cb39

Please sign in to comment.