summaryrefslogtreecommitdiffstats
path: root/mdk-stage1
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2003-11-27 13:18:47 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2003-11-27 13:18:47 +0000
commitf3837fd9c687ec40de7aab3a56ce75cc39aa2961 (patch)
treec87b4a2f708c86f0c14e8af25f74a9a06255312a /mdk-stage1
parentd3551589c911a40239d5be2b7ddc414f89dd548f (diff)
downloaddrakx-f3837fd9c687ec40de7aab3a56ce75cc39aa2961.tar
drakx-f3837fd9c687ec40de7aab3a56ce75cc39aa2961.tar.gz
drakx-f3837fd9c687ec40de7aab3a56ce75cc39aa2961.tar.bz2
drakx-f3837fd9c687ec40de7aab3a56ce75cc39aa2961.tar.xz
drakx-f3837fd9c687ec40de7aab3a56ce75cc39aa2961.zip
allow to halt machine
Diffstat (limited to 'mdk-stage1')
-rw-r--r--mdk-stage1/init.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/mdk-stage1/init.c b/mdk-stage1/init.c
index ac9154dcd..44fc9a3e9 100644
--- a/mdk-stage1/init.c
+++ b/mdk-stage1/init.c
@@ -336,13 +336,17 @@ void unmount_filesystems(void)
}
}
+int reboot_magic = 0x01234567;
+
int in_reboot(void)
{
int fd;
if ((fd = open("/var/run/rebootctl", O_RDONLY, 0)) > 0) {
- char buf[1];
+ char buf[100];
int i = read(fd, buf, sizeof(buf));
close(fd);
+ if (strstr(buf, "halt"))
+ reboot_magic = 0x4321FEDC;
return i > 0;
}
return 0;
@@ -475,9 +479,12 @@ int main(int argc __attribute__ ((unused)), char **argv __attribute__ ((unused))
sync(); sync();
if (!abnormal_termination) {
- printf("automatic reboot in 10 seconds\n");
+ if (reboot_magic == 0x01234567)
+ printf("automatic reboot in 10 seconds\n");
+ else
+ printf("automatic poweroff in 10 seconds\n");
sleep(10);
- reboot(0xfee1dead, 672274793, 0x01234567);
+ reboot(0xfee1dead, 672274793, reboot_magic);
} else {
printf("you may safely reboot or halt your system\n");
while (1);