Fri 23 Mar 2007 05:46:09 AM UTC, original submission:
Firstly: All problems described in this bug report have been solved and thoroughly tested by me on my Compaq Deskpro EN. For reference see "partnew" Command Writes Wrong Ending Cylinder in MPT. I also want to thank adrian15 for his help to get me started debugging GRUB.
Secondly: Though seemingly related on the surface, I actually found two entirely unrelated bugs in the "partnew" code. Both have been solved by changes to only the code within the "partnew" function.
The Bugs
- The first problem has to do with the calculation of cylinder values for large disks, and for partitions near the end of any size disk. If a partition begins or ends on the last or next-to-last cylinder, or past cylinder 1021 on a large disk, "partnew" incorrectly calculates the cylinder value to be the largest allowed value for the disk minus two.
For example, on my small disk with CHS 833/240/63:
writes C/H/S 137/0/1 thru 830/239/63 (ending cylinder should be 831)
Another example, on my large disk with CHS 10587/240/63:
writes C/H/S 1021/0/1 thru 1021/239/63 (beginning and ending cylinder should both be 1023)
This is actually a manifestation of another problem external to the "partnew" function (I was not able to find it). This is evident when I ask for "geometry" from the GRUB command line:
- The second problem is that "partnew" does not properly handle parameters equal to zero. This situation arises when I want to create an 'Undefined' partition to thoroughly hide it from aggressive operating system installers (such as the NT os's which recognize filesystems regardless of what filesystem type is assigned).
For example:
writes C/H/S 0/0/1 thru 1021/164/4 (I expected C/H/S 0/0/0 thru 0/0/0)
The Patches
The complete patches to both problems can be found in the attached "builtins.c" file. This has been thoroughly validated by me on my Compaq Deskpro EN.
- The fix to the first problem is actually a 'dirty fix' in the sense that it only covers up a more basic problem (see above). This patch is a modification to code suggested by adrian15:
Replace:
- The patch to correct the second problem is also only a minor change to the code within the "partnew" function:
What Next?
I will do whatever I can to help get these changes into the GRUB Legacy code. Can someone help me get started writing ChangeLog? Is there a template or standard format I have to follow?
What about CVS - is that standard with all Linux distros, or do I need to install it? I have Debian Sarge, but there were problems reading the installation CD's, so I may install SuSE for further GRUB development.
What other files do I need to attach to this bug report?
|