summaryrefslogtreecommitdiffstats
path: root/mdk-stage1
diff options
context:
space:
mode:
authorArnaud Patard <rtp@mageia.org>2011-03-18 21:23:34 +0000
committerArnaud Patard <rtp@mageia.org>2011-03-18 21:23:34 +0000
commit51f081cd0ac8d1f895f39244747b96082a6d0a6a (patch)
treeb7fc57c72b035b772322cafdb17e4d10616204c5 /mdk-stage1
parent2923175afa8b253cffdea00c1087c29e877d7fea (diff)
downloaddrakx-51f081cd0ac8d1f895f39244747b96082a6d0a6a.tar
drakx-51f081cd0ac8d1f895f39244747b96082a6d0a6a.tar.gz
drakx-51f081cd0ac8d1f895f39244747b96082a6d0a6a.tar.bz2
drakx-51f081cd0ac8d1f895f39244747b96082a6d0a6a.tar.xz
drakx-51f081cd0ac8d1f895f39244747b96082a6d0a6a.zip
- clean reboot syscall handling
Diffstat (limited to 'mdk-stage1')
-rw-r--r--mdk-stage1/init.c27
-rw-r--r--mdk-stage1/rescue-gui.c12
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";