diff options
Diffstat (limited to 'mdk-stage1/rescue-gui.c')
| -rw-r--r-- | mdk-stage1/rescue-gui.c | 84 |
1 files changed, 71 insertions, 13 deletions
diff --git a/mdk-stage1/rescue-gui.c b/mdk-stage1/rescue-gui.c index be63229e8..c7aae6126 100644 --- a/mdk-stage1/rescue-gui.c +++ b/mdk-stage1/rescue-gui.c @@ -1,7 +1,7 @@ /* - * Guillaume Cottenceau (gc@mandrakesoft.com) + * Guillaume Cottenceau (gc) * - * Copyright 2001 Mandrakesoft + * Copyright 2001 Mandriva * * * This software may be freely redistributed under the terms of the GNU @@ -27,10 +27,19 @@ #include <sys/ioctl.h> #include <linux/unistd.h> #include <sys/select.h> +#include <linux/reboot.h> #include "config-stage1.h" #include "frontend.h" -#include "tools.h" +#include "utils.h" +#include "params.h" + +#include <sys/syscall.h> + +static inline long reboot(void) +{ + return (long) syscall(__NR_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART, 0); +} #if defined(__i386__) || defined(__x86_64__) #define ENABLE_RESCUE_MS_BOOT 1 @@ -38,9 +47,9 @@ char * env[] = { "PATH=/usr/bin:/bin:/sbin:/usr/sbin:/mnt/sbin:/mnt/usr/sbin:/mnt/bin:/mnt/usr/bin", - "LD_LIBRARY_PATH=/lib:/usr/lib:/mnt/lib:/mnt/usr/lib:/usr/X11R6/lib:/mnt/usr/X11R6/lib" -#if defined(__x86_64__) || defined(__ppc64__) - ":/lib64:/usr/lib64:/usr/X11R6/lib64:/mnt/lib64:/mnt/usr/lib64:/mnt/usr/X11R6/lib64" + "LD_LIBRARY_PATH=/lib:/usr/lib:/mnt/lib:/mnt/usr/lib" +#if defined(__x86_64__) + ":/lib64:/usr/lib64:/mnt/lib64:/mnt/usr/lib64" #endif , "HOME=/", @@ -59,7 +68,12 @@ static void PAUSE(void) { /* ------ UUURGH this is duplicated from `init.c', don't edit here........ */ -static inline _syscall3(int, reboot, int, magic, int, magic2, int, flag); +void fatal_error(char *msg) +{ + printf("FATAL ERROR IN RESCUE: %s\n\nI can't recover from this.\nYou may reboot your system.\n", msg); + while (1); +} + #define LOOP_CLR_FD 0x4C01 void del_loop(char *device) { @@ -139,7 +153,7 @@ void unmount_filesystems(void) for (i = nb = 0; i < numfs; i++) if (fs[i].mounted) { printf("\t%s umount failed\n", fs[i].name); - if (strcmp(fs[i].fs, "ext2") == 0) nb++; /* don't count not-ext2 umount failed */ + if (strcmp(fs[i].fs, "ext4") == 0) nb++; /* don't count not-ext4 umount failed */ } if (nb) { @@ -167,13 +181,34 @@ int main(int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)) char reboot_[] = "Reboot"; char doc[] = "Doc: what's addressed by this Rescue?"; - char * actions[] = { install_bootloader, + char upgrade[] = "Upgrade to New Version"; + char rootpass[] = "Reset Root Password"; + char userpass[] = "Reset User Password"; + char factory[] = "Reset to Factory Defaults"; + char backup[] = "Backup User Files"; + char restore[] = "Restore User Files from Backup"; + char badblocks[] = "Test Key for Badblocks"; + + char * actions_default[] = { install_bootloader, #if ENABLE_RESCUE_MS_BOOT - restore_ms_boot, + restore_ms_boot, #endif - mount_parts, go_to_console, reboot_, doc, NULL }; + mount_parts, go_to_console, reboot_, doc, NULL }; + char * actions_flash_rescue[] = { rootpass, userpass, factory, backup, restore, + badblocks, go_to_console, reboot_, NULL }; + char * actions_flash_upgrade[] = { upgrade, go_to_console, reboot_, NULL }; + + + char * flash_mode; + char ** actions; char * choice; + process_cmdline(); + flash_mode = get_param_valued("flash"); + actions = !flash_mode ? + actions_default : + streq(flash_mode, "upgrade") ? actions_flash_upgrade : actions_flash_rescue; + init_frontend("Welcome to " DISTRIB_NAME " Rescue (" DISTRIB_VERSION ") " __DATE__ " " __TIME__); do { @@ -202,12 +237,35 @@ 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"; } + /* Mandriva Flash entries */ + if (ptr_begins_static_str(choice, rootpass)) { + binary = "/usr/bin/reset_rootpass"; + } + if (ptr_begins_static_str(choice, userpass)) { + binary = "/usr/bin/reset_userpass"; + } + if (ptr_begins_static_str(choice, factory)) { + binary = "/usr/bin/clear_systemloop"; + } + if (ptr_begins_static_str(choice, backup)) { + binary = "/usr/bin/backup_systemloop"; + } + if (ptr_begins_static_str(choice, restore)) { + binary = "/usr/bin/restore_systemloop"; + } + if (ptr_begins_static_str(choice, badblocks)) { + binary = "/usr/bin/test_badblocks"; + } + if (ptr_begins_static_str(choice, upgrade)) { + binary = "/usr/bin/upgrade"; + } + if (binary) { int wait_status; suspend_to_console(); @@ -224,7 +282,7 @@ int main(int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)) return 33; } while (wait4(-1, &wait_status, 0, NULL) != pid) {}; - printf("<press Enter to return to Rescue GUI>"); + printf("<press Enter to return to Rescue menu>"); PAUSE(); resume_from_suspend(); if (!WIFEXITED(wait_status) || WEXITSTATUS(wait_status) != 0) { |
