From 13f022f57a5ae30588d3dd5955afd8945699c93d Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Sat, 23 Mar 2013 12:30:20 +0000 Subject: do not reinvent kernel constants --- mdk-stage1/init.c | 17 +++++------------ 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 #include #include +#include #include #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 #include #include +#include #include "config-stage1.h" #include "frontend.h" @@ -35,13 +36,9 @@ #include -#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__) -- cgit v1.2.1