diff options
Diffstat (limited to 'mdk-stage1/rescue-gui.c')
| -rw-r--r-- | mdk-stage1/rescue-gui.c | 96 |
1 files changed, 79 insertions, 17 deletions
diff --git a/mdk-stage1/rescue-gui.c b/mdk-stage1/rescue-gui.c index f75ec76b2..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,16 +27,29 @@ #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 +#endif 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=/", @@ -55,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) { @@ -135,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) { @@ -155,7 +173,7 @@ int main(int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)) enum return_type results; char install_bootloader[] = "Re-install Boot Loader"; -#ifdef __i386__ +#if ENABLE_RESCUE_MS_BOOT char restore_ms_boot[] = "Restore Windows Boot Loader"; #endif char mount_parts[] = "Mount your partitions under /mnt"; @@ -163,14 +181,35 @@ 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, -#ifdef __i386__ - restore_ms_boot, + 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, #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; - init_frontend("Welcome to " DISTRIB_NAME " Rescue (" VERSION ") " __DATE__ " " __TIME__); + 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 { int pid; @@ -182,7 +221,7 @@ int main(int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)) if (ptr_begins_static_str(choice, install_bootloader)) { binary = "/usr/bin/install_bootloader"; } -#ifdef __i386__ +#if ENABLE_RESCUE_MS_BOOT if (ptr_begins_static_str(choice, restore_ms_boot)) { binary = "/usr/bin/restore_ms_boot"; } @@ -198,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(); @@ -220,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) { |
