⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 grub-0.97-patch2-findroot

📁 grub for dos ,people can use it in dos for calling linux
💻 97-PATCH2-FINDROOT
字号:
diff -Naur grub-0.97_startups/ChangeLog grub-0.97_findroot/ChangeLog--- grub-0.97_startups/ChangeLog	2006-10-24 12:28:50.000000000 +0800+++ grub-0.97_findroot/ChangeLog	2006-10-24 12:28:50.000000000 +0800@@ -1,5 +1,22 @@ 2005-05-11 +	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.97_startups/preset_menu.lst grub-0.97_findroot/preset_menu.lst--- grub-0.97_startups/preset_menu.lst	1970-01-01 08:00:00.000000000 +0800+++ grub-0.97_findroot/preset_menu.lst	2006-10-24 12:28:50.000000000 +0800@@ -0,0 +1,27 @@+default 0+timeout 1+fallback 1++title find /menu.lst+	find --set-root --ignore-floppies /menu.lst+	configfile /menu.lst++title find /boot/grub/menu.lst+	fallback 2+	find --set-root --ignore-floppies /boot/grub/menu.lst+	configfile /boot/grub/menu.lst++title find /grub/menu.lst+	fallback 3+	find --set-root --ignore-floppies /grub/menu.lst+	configfile /grub/menu.lst++title commandline+	commandline++title reboot+	reboot++title halt+	halt+diff -Naur grub-0.97_startups/preset_menu_os_setup.lst grub-0.97_findroot/preset_menu_os_setup.lst--- grub-0.97_startups/preset_menu_os_setup.lst	1970-01-01 08:00:00.000000000 +0800+++ grub-0.97_findroot/preset_menu_os_setup.lst	2006-10-24 12:28:50.000000000 +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.97_startups/stage2/builtins.c grub-0.97_findroot/stage2/builtins.c--- grub-0.97_startups/stage2/builtins.c	2006-10-24 12:28:50.000000000 +0800+++ grub-0.97_findroot/stage2/builtins.c	2006-10-24 12:28:50.000000000 +0800@@ -81,6 +81,7 @@ /* Prototypes for allowing straightfoward calling of builtins functions    inside other functions.  */ static int configfile_func (char *arg, int flags);+int commandline_func (char *arg, int flags);  /* Initialize the data for builtins.  */ void@@ -1202,8 +1203,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"@@ -1214,8 +1215,39 @@ };  +/* 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+};++static int real_root_func (char *arg1, int attempt_mount);+ /* 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) {@@ -1224,30 +1256,24 @@   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.  */-  for (drive = 0x80; drive < 0x88; drive++)+  /* Hard disks. Search in hard disks first, since floppies are slow */+#ifdef GRUB_UTIL+#define FIND_DRIVES 8+#else+#define FIND_DRIVES (*((char *)0x475))+#endif+  for (drive = 0x80; drive < 0x80 + FIND_DRIVES; drive++)+#undef FIND_DRIVES     {       unsigned long part = 0xFFFFFF;       unsigned long start, len, offset, ext_offset;@@ -1276,13 +1302,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; 		    } 		} 	    }@@ -1296,12 +1325,77 @@       errnum = ERR_NONE;     } +  /* CD-ROM.  */+  if (cdrom_drive != GRUB_INVALID_DRIVE)+    {+      current_drive = cdrom_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, "(cd)");+	      grub_printf (" %s\n", root_found);+	      got_file = 1;+	      if (set_root)+		goto found;+	    }+	}++      errnum = ERR_NONE;+    }++  /* Floppies.  */+#ifdef GRUB_UTIL+#define FIND_DRIVES 8+#else+#define FIND_DRIVES ((*(char*)0x410 & 1)?(*(char*)0x410 >> 6) + 1 : 0)+#endif+  for (drive = 0; drive < 0 + FIND_DRIVES; drive++)+#undef FIND_DRIVES+    {+      extern int biosdisk_standard (int ah, int drv, int coff, int hoff, int soff, int nsec, int segment);+      +#ifndef GRUB_UTIL+      /* Check if the media is present using int13/ah=04h (verify sectors) */+      if (biosdisk_standard (0x04, drive, 0, 0, 1, 1, SCRATCHSEG))+	continue;+#endif+      +      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)     {       errnum = ERR_NONE;+      if (set_root)+	return real_root_func (root_found, 1);       return 0;     } @@ -1314,9 +1408,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." };  @@ -4821,6 +4917,7 @@   &builtin_chainloader,   &builtin_cmp,   &builtin_color,+  &builtin_commandline,   &builtin_configfile,   &builtin_debug,   &builtin_default,diff -Naur grub-0.97_startups/stage2/cmdline.c grub-0.97_findroot/stage2/cmdline.c--- grub-0.97_startups/stage2/cmdline.c	2006-10-24 12:28:50.000000000 +0800+++ grub-0.97_findroot/stage2/cmdline.c	2006-10-24 12:28:50.000000000 +0800@@ -115,6 +115,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).  */@@ -169,7 +171,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.  */@@ -252,7 +254,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.97_startups/stage2/stage2.c grub-0.97_findroot/stage2/stage2.c--- grub-0.97_startups/stage2/stage2.c	2006-10-24 12:28:50.000000000 +0800+++ grub-0.97_findroot/stage2/stage2.c	2006-10-24 12:28:50.000000000 +0800@@ -974,7 +974,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 + -