diff options
author | Thierry Vignaud <tv@mageia.org> | 2013-03-23 12:30:20 +0000 |
---|---|---|
committer | Thierry Vignaud <tv@mageia.org> | 2013-03-23 12:30:20 +0000 |
commit | b8fe5265b23376de2a40a58101188f88c0281626 (patch) | |
tree | 563efef761a376c06b8254da0f56f22849c24622 | |
parent | 8b4287037ff2b28c3fed65c8936b4e74140fe631 (diff) | |
download | drakx-b8fe5265b23376de2a40a58101188f88c0281626.tar drakx-b8fe5265b23376de2a40a58101188f88c0281626.tar.gz drakx-b8fe5265b23376de2a40a58101188f88c0281626.tar.bz2 drakx-b8fe5265b23376de2a40a58101188f88c0281626.tar.xz drakx-b8fe5265b23376de2a40a58101188f88c0281626.zip |
do not reinvent kernel constants
-rw-r--r-- | mdk-stage1/init.c | 17 | ||||
-rw-r--r-- | mdk-stage1/rescue-gui.c | 7 |
2 files changed, 7 insertions, 17 deletions
diff --git a/mdk-stage1/init.c b/mdk-stage1/init.c index af6aefd2a..3f912c2ac 100644 --- a/mdk-stage1/init.c +++ b/mdk-stage1/init.c @@ -36,19 +36,12 @@ #include <linux/unistd.h> #include <sys/select.h> #include <sys/ioctl.h> +#include <linux/reboot.h> #include <sys/syscall.h> #define syslog(...) syscall(__NR_syslog, __VA_ARGS__) -#define LINUX_REBOOT_MAGIC1 0xfee1dead -#define LINUX_REBOOT_MAGIC2 672274793 -#define BMAGIC_HARD 0x89ABCDEF -#define BMAGIC_SOFT 0 -#define BMAGIC_REBOOT 0x01234567 -#define BMAGIC_HALT 0xCDEF0123 -#define BMAGIC_POWEROFF 0x4321FEDC - -static unsigned int reboot_magic = BMAGIC_REBOOT; +static unsigned int reboot_magic = LINUX_REBOOT_CMD_RESTART; static inline long reboot(unsigned int command) { @@ -379,7 +372,7 @@ int in_reboot(void) int i = read(fd, buf, sizeof(buf)); close(fd); if (strstr(buf, "halt")) - reboot_magic = BMAGIC_POWEROFF; + reboot_magic = LINUX_REBOOT_CMD_POWER_OFF; return i > 0; } return 0; @@ -492,7 +485,7 @@ int main(int argc, char **argv) } while (WIFEXITED(wait_status) && WEXITSTATUS(wait_status) == exit_value_restart); /* allow Ctrl Alt Del to reboot */ - reboot(BMAGIC_HARD); + reboot(LINUX_REBOOT_CMD_CAD_ON); if (in_reboot()) { // any exitcode is valid if we're in_reboot @@ -540,7 +533,7 @@ int main(int argc, char **argv) sync(); sync(); if (!abnormal_termination) { - if (reboot_magic == BMAGIC_REBOOT) { + if (reboot_magic == LINUX_REBOOT_CMD_RESTART) { #ifdef DEBUG printf("automatic reboot in 10 seconds\n"); sleep(10); diff --git a/mdk-stage1/rescue-gui.c b/mdk-stage1/rescue-gui.c index 0755865af..7d5b0a423 100644 --- a/mdk-stage1/rescue-gui.c +++ b/mdk-stage1/rescue-gui.c @@ -27,6 +27,7 @@ #include <sys/ioctl.h> #include <linux/unistd.h> #include <sys/select.h> +#include <linux/reboot.h> #include "config-stage1.h" #include "frontend.h" @@ -35,13 +36,9 @@ #include <sys/syscall.h> -#define LINUX_REBOOT_MAGIC1 0xfee1dead -#define LINUX_REBOOT_MAGIC2 672274793 -#define BMAGIC_REBOOT 0x01234567 - static inline long reboot(void) { - return (long) syscall(__NR_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, BMAGIC_REBOOT, 0); + return (long) syscall(__NR_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART, 0); } #if defined(__i386__) || defined(__x86_64__) |