bug-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "partnew" Command Writes Wrong Ending Cylinder in MPT- sburtchin Feb


From: sburtchin
Subject: Re: "partnew" Command Writes Wrong Ending Cylinder in MPT- sburtchin Feb 2, 2007; 6:45am
Date: Thu, 15 Feb 2007 19:46:08 -0800 (PST)

NOTE: Adding message of sburtchin Feb 2, 2007; 6:45am to Nabble thread.


----- Original Message ----- 
From: "adrian15" <address@hidden>
To: "Steve Burtchin" <address@hidden>
Sent: Thursday, February 01, 2007 6:30 AM
Subject: Re: "partnew" Command Writes Wrong Ending Cylinder in MPT


> See the attached cdrom once in English cdrom press 'c' key and you'll
> get a grub console from which you can run the new command:
>
> partnewbeta
>
Thanks, this worked great!


> I've also attached the builtins.c file so that you search for the
> partnewbeta string and see what you need to add a new command.
>
So I put my "epteditbeta" function code in the body of builtins.c and also
add an entry for it in the "builtin" structure at the end of the file.  That
is very straightforward.  The stuff I am unsure about is what has to be put
into "ChangeLog", "grub.texi ", "grub.info",  or other file and how it gets
there (see the attachment).  Some of this looks like it's needed.

The only other question I had was the use of "entry" (see attached source
code).
In the lines:
              /* Adjust for "current" or "next" slot.  */
              if (ept_slot == 'n') entry++;
Have I made the right assumption of how "entry" is used?


> > The data in the "buf_geom"
> > structure seems to get passed around quite a bit (eg. the "geometry"
> > function reports 1021 cylinders also [here its the value of
> > "geom.cylinders"], if that matters?).
>
> Do you mean geom.cylinders instead of buf_geom.cylinders ... interesting.
>
Exactly.  It gets displayed here:

  grub_printf ("drive 0x%x: C/H/S = %d/%d/%d, "
        "The number of sectors = %d, %s\n",
        current_drive,
        geom.cylinders, geom.heads, geom.sectors,
        geom.total_sectors, msg);

I would bet that "&geom.cylinders" is the same as "&buf_geom.cylinders".

> >  bufgeomcylinders = buf_geom.cylinders
> >  bufgeomcylinders+=2;
> >  if (cylinder >= bufgeomcylinders)
> >           cylinder = bufgeomcylinders - 1;
>
> That's the patch that I have applied.
> >
> >
> > leaving the "buf_geom" structure unchanged, and avoiding the potential
of
> > awakening that earlier bug.
>
> I do not agree with you but you may be right so I've applied your patch.
>
You would know better than me.  This is safest though, to leave the global
"buf_geom.cylinders" alone.  Even if no earlier bug, at least there is no
risk of creating a new bug.  It might have always maxed out at 1021 and
never caused problem for anyone.  Possibly only a serious risk for a
partition beginning or ending at cylinder 1022 or 1023 with the os using CHS
addressing.


> You'll tell me if you have any problem.
>
> adrian15
>
I have tested thoroughly and the patched code always writes the correct
starting/ending cylinder IMO.  I tested for all start/end cylinder values
from 1019 thru 1024.

There was another patch I had suggested for this function that you left out
of this beta.  This lets you zero out a whole slot in the MPT with a command
like: "partnew (hd0,3) 0x00 0 0".

   /* Convert a LBA address to a CHS address in the INT 13 format.  */
   auto void lba_to_chs (int lba, int *cl, int *ch, int *dh);
   void lba_to_chs (int lba, int *cl, int *ch, int *dh)
     {
       int cylinder, head, sector;

/* begin patch */
      if (lba <= 0)
       {
         *cl = 0;
         *ch = 0;
         *dh = 0;
        }
        else
        {

/* end patch */
         sector = lba % buf_geom.sectors + 1;
         head = (lba / buf_geom.sectors) % buf_geom.heads;
         cylinder = lba / (buf_geom.sectors * buf_geom.heads);

         if (cylinder >= buf_geom.cylinders)
          cylinder = buf_geom.cylinders - 1;

         *cl = sector | ((cylinder & 0x300) >> 2);
         *ch = cylinder & 0xFF;
         *dh = head;

/* begin patch */
       }

/* end patch */
    } http://www.nabble.com/file/6522/EPTEDIT_Source.rtf EPTEDIT_Source.rtf 
http://www.nabble.com/file/6523/New_GRUB_Command_misc.txt
New_GRUB_Command_misc.txt 
-- 
View this message in context: 
http://www.nabble.com/%22partnew%22-Command-Writes-Wrong-Ending-Cylinder-in-MPT-tf2599372.html#a8998539
Sent from the Grub - Bugs mailing list archive at Nabble.com.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]