Bug#345931: A patch solving #345931

Leandro Dorileo ldorileo at gmail.com
Tue Sep 26 13:52:28 UTC 2006


Hi Robert

On Monday 25 September 2006 10:17, Robert Millan wrote:
> On Mon, Sep 11, 2006 at 06:26:37PM +0200, Mats Erik Andersson wrote:
> >   Venerable Maintainers of Grub,
> >
> >  I offer you a patch that should close bug report
> >  #345931.
> >
> >  The patch has been built on top of grub-0.97-13 with
> >  success and it repaired with honours mbr-installs of
> >
> >         grub-0.97-1ubuntu1   on kubuntu 6.0.6
> >   and
> >         grub-0.95+cvs20040624-17sarge1 on Debian
> > Sarge.
>
> Does your patch work with grub from debian sid?
>
> Does GRUB 2 also exhibit this problem?

I don`t think so, I`m trying this patch and I think It`s a totally grub legacy 
related problem. I just have few considerations on the proposed patch. 

>
> >  As you will see the coding is independent of any
> >  Debian patches and contains a few lines of code for
> >  the source file
> >
> >          grub-0.97/stage2/builtins.c
> >
> >  and thus would easily integrate in the upstream
> >  version 0.97. I leave to you to decide whether the
> >  author ought to be informed, since I am still a
> >  novice in these matters.
> >
> >           Best regards
> >
> >             Mats Erik Andersson
> >             ynglingatal at yahoo.se
>
> Content-Description: 526972506-drive_correction.diff
>
> > diff -Naur grub-0.97.orig/stage2/builtins.c grub-0.97/stage2/builtins.c
> > --- grub-0.97.orig/stage2/builtins.c	2006-09-11 16:08:32.261227280 +0200
> > +++ grub-0.97/stage2/builtins.c	2006-09-11 16:15:54.035067448 +0200
> > @@ -1953,13 +1953,30 @@
> >    *((unsigned char *) (stage1_buffer + STAGE1_FORCE_LBA)) =
> > is_force_lba;
> >
> >    /* If DEST_DRIVE is a hard disk, enable the workaround, which is
> > -     for buggy BIOSes which don't pass boot drive correctly. Instead,
> > -     they pass 0x00 or 0x01 even when booted from 0x80.  */
> > +   * for buggy BIOSes which don't pass boot drive correctly. Instead,
> > +   *  they pass 0x00 or 0x01 even when booted from 0x80.  */
> >    if (dest_drive & BIOS_FLAG_FIXED_DISK)
> > -    /* Replace the jmp (2 bytes) with double nop's.  */
> > -    *((unsigned short *) (stage1_buffer + STAGE1_BOOT_DRIVE_CHECK))
> > -      = 0x9090;
> > -
> > +  {
> > +    if ( *((unsigned char *) (stage1_buffer + STAGE1_BOOT_DRIVE_CHECK))
> > == 0xeb ) +            /* For version 0.97:
> > +	     * Replace the jmp (2 bytes) with double nop's.  */
> > +       *((unsigned short *) (stage1_buffer + STAGE1_BOOT_DRIVE_CHECK))
> > +         = 0x9090;

What have changed here?

> > +    else if ( *((unsigned char *) (stage1_buffer +
> > STAGE1_BOOT_DRIVE_CHECK)) == 0x80 ) +         {
> > +            /* For versions 0.94-96:
> > +	     *  Set the boot drive mask. This is a workaround for buggy BIOSes
> > which +            *  don't pass boot drive correctly. Instead, they pass
> > 0x00 even when +            *  booted from 0x80.
> > +	     *  Rem: the old STAGE1_BOOT_DRIVE_MASK equals
> > STAGE1_BOOT_DRIVE_CHECK + 2  */ +         *((unsigned char *)
> > (stage1_buffer + STAGE1_BOOT_DRIVE_CHECK + 2 )) +             =
> > (dest_drive & BIOS_FLAG_FIXED_DISK);
> > +	  }
> > +        else
> > +	      /* The boot sector is older than version 0.94.
> > +	       * Changing to a "nop" could make 0.92 and 0.93 acceptable. */
> > +	   goto fail;

What about we set here the errnum with ERR_BAD_VERSION? or perhaps define a 
new error with a new message - something like: you should run grub-install or 
you will be unbootable - for this situation?

> > +  }
> >    /* Read the first sector of Stage 2.  */
> >    disk_read_hook = disk_read_savesect_func;
> >    if (grub_read (stage2_first_buffer, SECTOR_SIZE) != SECTOR_SIZE)

I`ll try this patch a bit more in the end of the week.

--
Dorileo




More information about the Pkg-grub-devel mailing list