----- Original Message ----- From: "Steve Burtchin" <[EMAIL PROTECTED]> To: "adrian15" <[EMAIL PROTECTED]> Sent: Friday, February 02, 2007 6:45 AM Subject: Re: "partnew" Command Writes Wrong Ending Cylinder in MPT
> > ----- Original Message ----- > From: "adrian15" <[EMAIL PROTECTED]> > To: "Steve Burtchin" <[EMAIL PROTECTED]> > 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 */ > } >
In ChangeLog add: 2006-11-## ?name? <[EMAIL PROTECTED]> Added new command "eptedit" based on code derived from functions partnew and "parttype", based on the patch by ?name? <[EMAIL PROTECTED]>: * stage2/builtins.c (eptedit_func): New function. (builtin_eptedit): New variable. (builtin_table): Added pointer to BUILTIN_EPTEDIT. Who is responsible for updating the change log? Please help me fill in the blanks. In grub.texi add as illustrated: . . . @menu * bootp:: Initialize a network device via BOOTP . . . * eptedit:: Change data in an extended partition table . . . @node eptedit @subsection eptedit @deffn Command eptedit part slot type bcyl bhead bsec ecyl ehead esec rsec tsec Change data in an extended partition table. @var{part} is a partition specification in GRUB syntax (@pxref{Naming convention}); @var{slot} is the position in the extended partition table and must be "c" [current] or "n" [next]; @var{type} is the partition type and must be a number in the range @code{0-0xff}; @var{bcyl} is the beginning cylinder; @var{bhead} is the beginning head; @var{bsec} is the beginning sector; @var{ecyl} is the ending cylinder; @var{ehead} is the ending head; @var{esec} is the ending sector; @var{rsec} is the relative sectors and @var{tsec} is the total sectors, both in sector units. @end deffn . . . Please check this. In grub.info add: . . . 13.2 The list of general commands ================================= Commands usable anywhere in the menu and in the command-line. * Menu: * bootp:: Initialize a network device via BOOTP . . . * eptedit:: Change data in an extended partition table . . . File: grub.info, Node: eptedit, Next: hide, Prev: dhcp, Up: General commands 13.2.5 eptedit -------------- -- Command: eptedit part slot type bcyl bhead bsec ecyl ehead esec rsec tsec Change data in an extended partition table. PART is a partition specification in GRUB syntax (*note Naming convention::); SLOT is the position in the extended partition table ("c" [current] or "n" [next]); TYPE is the partition type and must be a number in the range `0-0xff'; BCYL is the beginning cylinder; BHEAD is the beginning head; BSEC is the beginning sector; ECYL is the ending cylinder; EHEAD is the ending head; ESEC is the ending sector; RSEC is the relative sectors and TSEC is the total sectors, both in sector units. This is useful when using extended partitions of different ranges to accommodate a mix of LBA aware and LBA ignorant operating systems, and to avoid the DOS/Win9x last logical partition bug if you want to have a non-FAT last logical partition. . . . File: grub.info, Node: Index, Prev: Internals, Up: Top Index ***** _[index _] * Menu: * blocklist: blocklist. (line 7) . . . * eptedit: eptedit. (line 7) . . . Tag Table: . . . Node: eptedit##### - ? . . Please check this closely, especially the tag table entry. Is there anything else that needs to be done to create a new command? Please let me know. I will help anyway I can. Thanks!
EPTEDIT_Source.rtf
Description: MS-Word document
_______________________________________________ Bug-grub mailing list Bug-grub@gnu.org http://lists.gnu.org/mailman/listinfo/bug-grub