Attached there is a patch that addresses the following bug:

Let's suppose you install a grub in the partition boot sector from (hd0,5).

Let's suppose that you boot from a grub cdrom and that you want to chainload it and you do:

rootnoverify (hd0,5)
chainloader +1
boot

This gives you a: Error 25.

If you try:
root (hd0,5)
chainloader +1
boot

it boots... but this is not ok for you because you know you should chainload a partition boot sector installed grub with rootnoverify.

The problem is in the real_root_func function on builtins.c that when it does not have to mount it uses:

      if (open_partition ())
        {
          set_bootdev (0);
          if (errnum)
            return 1;
        }

and this set_bootdev uses the saved_drive variable to make this saved_drive the bootable one. Why? Because later in the code... when the drive is mounted the variable where the mounted drive is called: saved_drive :)

However in this part of the code the opened partition (thanks to open_partition) it is stored on the current_drive variable.


Putting the code like this:

      if (open_partition ())
        {
          saved_drive = current_drive;
          set_bootdev (0);
          if (errnum)
            return 1;
        }


fixes the problem.


Now I have some problems when you boot from a grub usb hard disk but from cdrom it works without any problem, and it is evident that there's a bug there. The set_bootdev function waits for the saved_drive to be set and when you run the old rootnoverify code is never set!

adrian15
--- sgd_source_code_0.9586/dev_grub/stage2/builtins.c	2007-03-11 21:45:54.000000000 +0100
+++ sgd_source_code_0.9588/dev_grub/stage2/builtins.c	2007-03-17 23:58:11.000000000 +0100
@@ -3520,6 +3520,7 @@
 	 must be set appropriately.  */
       if (open_partition ())
 	{
+	  saved_drive = current_drive; // Let's update saved_drive with value from open_partition - adrian15
 	  set_bootdev (0);
 	  if (errnum)
 	    return 1;
_______________________________________________
Bug-grub mailing list
Bug-grub@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-grub

Reply via email to