diff options
-rw-r--r-- | mdk-stage1/init.c | 27 | ||||
-rw-r--r-- | mdk-stage1/rescue-gui.c | 12 |
2 files changed, 27 insertions, 12 deletions
diff --git a/mdk-stage1/init.c b/mdk-stage1/init.c index 8130b422b..1d5841610 100644 --- a/mdk-stage1/init.c +++ b/mdk-stage1/init.c @@ -39,7 +39,21 @@ #include <sys/syscall.h> #define syslog(...) syscall(__NR_syslog, __VA_ARGS__) -#define reboot(...) syscall(__NR_reboot, __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 inline long reboot(unsigned int command) +{ + return (long) syscall(__NR_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, command, 0); +} #include "config-stage1.h" #include <linux/cdrom.h> @@ -360,13 +374,6 @@ void unmount_filesystems(void) } } -#define BMAGIC_HARD 0x89ABCDEF -#define BMAGIC_SOFT 0 -#define BMAGIC_REBOOT 0x01234567 -#define BMAGIC_HALT 0xCDEF0123 -#define BMAGIC_POWEROFF 0x4321FEDC -int reboot_magic = BMAGIC_REBOOT; - int in_reboot(void) { int fd; @@ -480,7 +487,7 @@ int main(int argc, char **argv) } while (WIFEXITED(wait_status) && WEXITSTATUS(wait_status) == exit_value_restart); /* allow Ctrl Alt Del to reboot */ - reboot(0xfee1dead, 672274793, BMAGIC_HARD); + reboot(BMAGIC_HARD); if (in_reboot()) { // any exitcode is valid if we're in_reboot @@ -533,7 +540,7 @@ int main(int argc, char **argv) printf("automatic reboot in 10 seconds\n"); sleep(10); #endif - reboot(0xfee1dead, 672274793, reboot_magic); + reboot(reboot_magic); } else { printf("you may safely poweroff your computer now\n"); } diff --git a/mdk-stage1/rescue-gui.c b/mdk-stage1/rescue-gui.c index a71a5ae91..e9cd2495e 100644 --- a/mdk-stage1/rescue-gui.c +++ b/mdk-stage1/rescue-gui.c @@ -34,7 +34,15 @@ #include "params.h" #include <sys/syscall.h> -#define reboot(...) syscall(__NR_reboot, __VA_ARGS__) + +#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); +} #if defined(__i386__) || defined(__x86_64__) #define ENABLE_RESCUE_MS_BOOT 1 @@ -233,7 +241,7 @@ int main(int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)) sync(); sync(); printf("rebooting system\n"); sleep(2); - reboot(0xfee1dead, 672274793, 0x01234567); + reboot(); } if (ptr_begins_static_str(choice, doc)) { binary = "/usr/bin/rescue-doc"; |