📄 grub-0.95-patch2-findroot
字号:
diff -Naur grub-0.95_startups/ChangeLog grub-0.95_findroot/ChangeLog--- grub-0.95_startups/ChangeLog 2004-10-22 14:03:21.327886608 +0800+++ grub-0.95_findroot/ChangeLog 2004-10-22 14:15:27.403506336 +0800@@ -1,5 +1,22 @@ 2004-07-13 + From Chris Semler <csemler@mail.com>:++ * stage2/builtins.c (find_func): added an option --set-root+ (fallback_func): enable the use as a menu item.+ (commandline_func): New function++ * stage2/cmdline.c (enter_cmdline): changed arg for commandline_func+ to use HEAP.+ (run_script): changed arg for commandline_func to use HEAP.++ * stage2/stage2.c (cmain): changed arg for commandline_func to use+ CMDLINE.++ * preset_menu.lst: New file++ * preset_menu_os_setup.lst: New file+ From Tinybit <tinybit@163.net>: For booting via DOS/NTLDR: * stage2/Makefile.am: added items for GRLDR, GRUB.EXE and GRUB4LINdiff -Naur grub-0.95_startups/preset_menu.lst grub-0.95_findroot/preset_menu.lst--- grub-0.95_startups/preset_menu.lst 1970-01-01 08:00:00.000000000 +0800+++ grub-0.95_findroot/preset_menu.lst 2004-10-22 14:12:22.242655064 +0800@@ -0,0 +1,20 @@+default 0+timeout 0+fallback 1++title load /boot/grub/menu.lst+ find --set-root /boot/grub/menu.lst+ configfile /boot/grub/menu.lst++title load /grub/menu.lst+ fallback 2+ find --set-root /grub/menu.lst+ configfile /grub/menu.lst++title load /menu.lst+ fallback 3+ find --set-root /menu.lst+ configfile /menu.lst++title enter commandline mode+ commandlinediff -Naur grub-0.95_startups/preset_menu_os_setup.lst grub-0.95_findroot/preset_menu_os_setup.lst--- grub-0.95_startups/preset_menu_os_setup.lst 1970-01-01 08:00:00.000000000 +0800+++ grub-0.95_findroot/preset_menu_os_setup.lst 2004-10-22 14:12:22.243654912 +0800@@ -0,0 +1,30 @@+default 0+timeout 0+fallback 1++title /os_setup_stage2.lst+ find --set-root /os_setup_stage2.lst+ configfile /os_setup_stage2.lst++title /os_setup.lst+ fallback 2+ find --set-root /os_setup.lst+ configfile /os_setup.lst++title /boot/grub/menu.lst+ fallback 3+ find --set-root /boot/grub/menu.lst+ configfile /boot/grub/menu.lst++title /grub/menu.lst+ fallback 4+ find --set-root /grub/menu.lst+ configfile /grub/menu.lst++title /menu.lst+ fallback 5+ find --set-root /menu.lst+ configfile /menu.lst++title enter commandline mode+ commandlinediff -Naur grub-0.95_startups/stage2/builtins.c grub-0.95_findroot/stage2/builtins.c--- grub-0.95_startups/stage2/builtins.c 2004-05-15 03:30:52.000000000 +0800+++ grub-0.95_findroot/stage2/builtins.c 2004-10-22 14:12:22.322642904 +0800@@ -1153,8 +1153,8 @@ { "fallback", fallback_func,- BUILTIN_MENU,-#if 0+ BUILTIN_MENU | BUILTIN_CMDLINE | BUILTIN_HELP_LIST,+#if 1 "fallback NUM", "Go into unattended boot mode: if the default boot entry has any" " errors, instead of waiting for the user to do anything, it"@@ -1165,8 +1165,38 @@ }; +/* commandline */+int+commandline_func (char *arg, int flags)+{+ int forever = 0;+ char *config_entries = arg;++ //config_entries = (char *) mbi.drives_addr + mbi.drives_length;+ + //if (! safe_parse_maxint (&arg, &forever))+ // return 1;+ enter_cmdline(config_entries, forever);++ return 0;+}++static struct builtin builtin_commandline =+{+ "commandline",+ commandline_func,+ BUILTIN_MENU | BUILTIN_CMDLINE | BUILTIN_HELP_LIST,+#if 1+ "commandline",+ "Enter command-line prompt mode."+#endif+};++ /* find */-/* Search for the filename ARG in all of partitions. */+/* Search for the filename ARG in all of partitions and optionally make that+ * partition root("--set-root", Thanks to Chris Semler <csemler@mail.com>).+ */ static int find_func (char *arg, int flags) {@@ -1175,29 +1205,17 @@ unsigned long tmp_drive = saved_drive; unsigned long tmp_partition = saved_partition; int got_file = 0;+ int set_root = 0;+ //char *in_drives = NULL; /* search in drive list */+ char root_found[16]; - /* Floppies. */- for (drive = 0; drive < 8; drive++)+ if (grub_memcmp (arg, "--set-root", 10) == 0) {- current_drive = drive;- current_partition = 0xFFFFFF;- - if (open_device ())- {- saved_drive = current_drive;- saved_partition = current_partition;- if (grub_open (filename))- {- grub_close ();- grub_printf (" (fd%d)\n", drive);- got_file = 1;- }- }-- errnum = ERR_NONE;+ set_root = 1;+ filename = skip_to (0, arg); } - /* Hard disks. */+ /* Hard disks. Search in hard disks first, since floppies are slow */ for (drive = 0x80; drive < 0x88; drive++) { unsigned long part = 0xFFFFFF;@@ -1227,13 +1245,16 @@ grub_close (); if (bsd_part == 0xFF)- grub_printf (" (hd%d,%d)\n",+ grub_sprintf (root_found, "(hd%d,%d)", drive - 0x80, pc_slice); else- grub_printf (" (hd%d,%d,%c)\n",+ grub_sprintf (root_found, "(hd%d,%d,%c)", drive - 0x80, pc_slice, bsd_part + 'a'); + grub_printf (" %s\n", root_found); got_file = 1;+ if (set_root)+ goto found; } } }@@ -1247,12 +1268,40 @@ errnum = ERR_NONE; } + /* Floppies. */+ for (drive = 0; drive < 8; drive++)+ {+ current_drive = drive;+ current_partition = 0xFFFFFF;+ + if (open_device ())+ {+ saved_drive = current_drive;+ saved_partition = current_partition;+ if (grub_open (filename))+ {+ grub_close ();+ grub_sprintf (root_found, "(fd%d)", drive);+ grub_printf (" %s\n", root_found);+ got_file = 1;+ if (set_root)+ goto found;+ }+ }++ errnum = ERR_NONE;+ }++found: saved_drive = tmp_drive; saved_partition = tmp_partition; if (got_file) {+ static int real_root_func (char *arg, int attempt_mount); errnum = ERR_NONE;+ if (set_root)+ return real_root_func (root_found, 1); return 0; } @@ -1265,9 +1314,11 @@ "find", find_func, BUILTIN_CMDLINE | BUILTIN_HELP_LIST,- "find FILENAME",+ "find [--set-root] FILENAME", "Search for the filename FILENAME in all of partitions and print the list of"- " the devices which contain the file."+ " the devices which contain the file. If the option --set-root is used and "+ "FILENAME is found on a device, then stop the find immediately and set the "+ "device as new root." }; @@ -4677,6 +4728,7 @@ &builtin_chainloader, &builtin_cmp, &builtin_color,+ &builtin_commandline, &builtin_configfile, &builtin_debug, &builtin_default,diff -Naur grub-0.95_startups/stage2/cmdline.c grub-0.95_findroot/stage2/cmdline.c--- grub-0.95_startups/stage2/cmdline.c 2004-03-18 07:08:48.000000000 +0800+++ grub-0.95_findroot/stage2/cmdline.c 2004-10-22 14:12:22.325642448 +0800@@ -114,6 +114,8 @@ init_builtins (); } +extern int commandline_func (char *arg, int flags);+ /* Enter the command-line interface. HEAP is used for the command-line buffer. Return only if FOREVER is nonzero and get_cmdline returns nonzero (ESC is pushed). */@@ -168,7 +170,7 @@ count_lines = 0; /* Run BUILTIN->FUNC. */- arg = skip_to (1, heap);+ arg = (builtin->func) == commandline_func ? heap : skip_to (1, heap); (builtin->func) (arg, BUILTIN_CMDLINE); /* Finish the line count. */@@ -251,7 +253,7 @@ buf_drive = -1; /* Run BUILTIN->FUNC. */- arg = skip_to (1, heap);+ arg = (builtin->func) == commandline_func ? heap : skip_to (1, heap); (builtin->func) (arg, BUILTIN_SCRIPT); } }diff -Naur grub-0.95_startups/stage2/stage2.c grub-0.95_findroot/stage2/stage2.c--- grub-0.95_startups/stage2/stage2.c 2004-03-28 00:09:41.000000000 +0800+++ grub-0.95_findroot/stage2/stage2.c 2004-10-22 14:12:22.329641840 +0800@@ -933,7 +933,8 @@ /* Run a command found is possible. */ if (builtin->flags & BUILTIN_MENU) {- char *arg = skip_to (1, cmdline);+ extern int commandline_func (char *arg, int flags);+ char *arg = (builtin->func) == commandline_func ? cmdline : skip_to (1, cmdline); (builtin->func) (arg, BUILTIN_MENU); errnum = 0; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -