Package: util-linux
Version: 2.13.1.1-1
Severity: grave
Tags: patch

Yesterday I tried the d-i rc1 for lenny on a silicon graphics O2 (a
complete report is available as Debian bug #510060).

The problem I found against fdisk is that when using large disks (i.e.,
disks with more than 4096 sectors per cylinder), the volhdr partition is
incorrectly sized because it is marked as starting and ending on
cylinder 0. When having this specific case, this is what happen:

Command (m for help): p

Disk /dev/sda (SGI disk label): 255 heads, 63 sectors, 8941 cylinders
Units = cylinders of 16065 * 512 bytes

----- partitions -----
Pt#    Device  Info     Start       End   Sectors  Id  System
----- Bootinfo -----
Bootfile: /unix
----- Directory Entries -----
 0: arcboot    sector    4 size   72492

Command (m for help): n
Partition number (1-16): 1
Attempting to generate entire disk entry automatically.
First cylinder (1-8940, default 1): 
Using default value 1
 Last cylinder (1-8940, default 8940): 2000

Command (m for help): p

Disk /dev/sda (SGI disk label): 255 heads, 63 sectors, 8941 cylinders
Units = cylinders of 16065 * 512 bytes

----- partitions -----
Pt#    Device  Info     Start       End   Sectors  Id  System
 1: /dev/sda1  boot         1      2000  32130000  83  Linux native
 9: /dev/sda2               0         0      4096   0  SGI volhdr
11: /dev/sda3               0      8940 143637165   6  SGI volume
----- Bootinfo -----
Bootfile: /unix
----- Directory Entries -----
 0: arcboot    sector    4 size   72492


Command (m for help): n
Partition number (1-16): 2
First cylinder (1-0): 1
Value out of range.
First cylinder (1-0): 0
Value out of range.
First cylinder (1-0): 2001
Value out of range.
First cylinder (1-0): ^C

As you may see, once the first partition has been created, fdisk will
automatically create partitions 9 and 11, but it will wrongly set the
end boundary of volhdr. Starting with this error, it is not possible to
add any new partition, because the accepted cylinder range would be
"1-0".

Please find attached a solution for this bug. This solution raise the
volhdr size of 4096 up to the first cylinder boundary. If the boundary
is less than 4096 then nothing is changed.

If you like the fix and will accept this patch, please add this note to
the changelog:

 * fix of mips related bug, dedicate to ths.

Thanks,
Giuseppe
--- fdisk/fdisksgilabel.c.orig	2008-04-21 14:58:43.000000000 +0200
+++ fdisk/fdisksgilabel.c	2008-12-29 16:01:14.000000000 +0100
@@ -604,8 +604,11 @@
 			 * Choose same default volume header size
 			 * as IRIX fx uses.
 			 */
-			if (4096 < sgi_get_lastblock())
-				sgi_set_partition(n, 0, 4096, SGI_VOLHDR);
+ 			unsigned hdrsize = heads * sectors;
+ 			if (hdrsize<4096)
+ 				hdrsize=4096;
+ 			if (hdrsize < sgi_get_lastblock())
+ 				sgi_set_partition(n, 0, hdrsize, SGI_VOLHDR);
 			break;
 		}
 	}

Reply via email to