About the only behavior of BootEasy that I liked was that booting a
partition made it the default partition for the next boot. GRUB is
much nicer in all other ways, so I figured I'd take a crack at fixing
this.
The attached patch makes default look for "active" as an argument, and
sets the default to the number of the active partition. While this is
very much a hack, it means the BootEasy behavior can be simulate with
enough work - at least for my purposes.
For a GRUB boot entry to change itself to the default, it's entry
number must be the same as it's partition number on the boot drive,
and it must set itself as active.
It's not clear that this can be made sane for systems that boot off
multiple disks (not to imply that the current behavior is sane), but
it's a start in the direction of providing this functionality.
Thanx,
<mike
diff -ru stage2-orig/builtins.c stage2/builtins.c
--- stage2-orig/builtins.c Wed Aug 2 06:56:52 2000
+++ stage2/builtins.c Wed Aug 2 06:57:08 2000
@@ -697,6 +697,12 @@
static int
default_func (char *arg, int flags)
{
+ if (grub_strcmp (arg, "active") == 0)
+ {
+ default_entry = find_active(NULL);
+ return 1;
+ }
+
if (! safe_parse_maxint (&arg, &default_entry))
return 1;
diff -ru stage2-orig/disk_io.c stage2/disk_io.c
--- stage2-orig/disk_io.c Wed Aug 2 06:56:52 2000
+++ stage2/disk_io.c Wed Aug 2 06:57:19 2000
@@ -302,6 +302,26 @@
#ifndef STAGE1_5
+/* Return the partition number of the active partition from device. */
+int
+find_active(char *device) {
+ int part;
+
+ if (saved_drive & 0x80)
+ {
+ /* Read the MBR in the scratch space. */
+ if (! rawread (saved_drive, 0, 0, SECTOR_SIZE, (char *) SCRATCHADDR))
+ return 0;
+
+ for (part = 0; part < 4; part +=1 )
+ if (! IS_PC_SLICE_TYPE_EXTENDED (PC_SLICE_TYPE (SCRATCHADDR, part))
+ && PC_SLICE_FLAG (SCRATCHADDR, part) == PC_SLICE_FLAG_BOOTABLE)
+ return part ;
+ }
+ return 0;
+}
+
+
/* Turn on the active flag for the partition SAVED_PARATITION in the
drive SAVED_DRIVE. If an error occurs, return zero, otherwise return
non-zero. */