1 - wrong number of sectors for large disks
3 --- util-linux-2.13-pre6/fdisk/fdisk.h.sectors 2006-06-12 10:50:11.000000000 +0200
4 +++ util-linux-2.13-pre6/fdisk/fdisk.h 2006-06-12 10:50:52.000000000 +0200
7 extern char *const str_units(int);
9 -extern unsigned int get_start_sect(struct partition *p);
10 -extern unsigned int get_nr_sects(struct partition *p);
11 +extern unsigned long long get_start_sect(struct partition *p);
12 +extern unsigned long long get_nr_sects(struct partition *p);
16 --- util-linux-2.13-pre6/fdisk/fdisksgilabel.h.sectors 2004-12-14 00:39:29.000000000 +0100
17 +++ util-linux-2.13-pre6/fdisk/fdisksgilabel.h 2006-06-12 10:50:52.000000000 +0200
20 #define sgilabel ((sgi_partition *)MBRbuffer)
21 #define sgiparam (sgilabel->devparam)
22 -extern char MBRbuffer[MAX_SECTOR_SIZE];
23 -extern unsigned int heads, sectors, cylinders, sector_size;
24 +extern unsigned char MBRbuffer[MAX_SECTOR_SIZE];
25 +extern unsigned int heads, cylinders, sector_size;
26 +extern unsigned long long sectors;
27 extern int show_begin;
29 extern char *partition_type(unsigned char type);
30 --- util-linux-2.13-pre6/fdisk/fdisksunlabel.h.sectors 2004-12-14 00:39:18.000000000 +0100
31 +++ util-linux-2.13-pre6/fdisk/fdisksunlabel.h 2006-06-12 10:50:52.000000000 +0200
36 -extern char MBRbuffer[MAX_SECTOR_SIZE];
37 -extern unsigned int heads, sectors, cylinders;
38 +extern unsigned char MBRbuffer[MAX_SECTOR_SIZE];
39 +extern unsigned int heads, cylinders;
40 +extern unsigned long long sectors;
41 extern int show_begin;
43 extern char *partition_type(unsigned char type);
44 --- util-linux-2.13-pre6/fdisk/fdiskaixlabel.h.sectors 2004-12-14 00:39:47.000000000 +0100
45 +++ util-linux-2.13-pre6/fdisk/fdiskaixlabel.h 2006-06-12 10:50:52.000000000 +0200
49 #define aixlabel ((aix_partition *)MBRbuffer)
50 -extern char MBRbuffer[MAX_SECTOR_SIZE];
51 +extern unsigned char MBRbuffer[MAX_SECTOR_SIZE];
52 extern char changed[MAXIMUM_PARTS];
53 -extern unsigned int heads, sectors, cylinders;
54 +extern unsigned int heads, cylinders;
55 +extern unsigned long long sectors;
56 extern int show_begin;
58 extern char *partition_type(unsigned char type);
59 --- util-linux-2.13-pre6/fdisk/fdisksunlabel.c.sectors 2005-07-31 18:00:29.000000000 +0200
60 +++ util-linux-2.13-pre6/fdisk/fdisksunlabel.c 2006-06-12 10:50:52.000000000 +0200
64 snprintf(sunlabel->info, sizeof(sunlabel->info),
65 - "%s%s%s cyl %d alt %d hd %d sec %d",
66 + "%s%s%s cyl %d alt %d hd %d sec %llu",
67 p ? p->vendor : "", (p && *p->vendor) ? " " : "",
69 : (floppy ? _("3,5\" floppy") : _("Linux custom")),
71 w = strlen(disk_device);
74 - _("\nDisk %s (Sun disk label): %d heads, %d sectors, %d rpm\n"
75 + _("\nDisk %s (Sun disk label): %d heads, %llu sectors, %d rpm\n"
76 "%d cylinders, %d alternate cylinders, %d physical cylinders\n"
77 "%d extra sects/cyl, interleave %d:1\n"
80 str_units(PLURAL), units_per_sector);
83 - _("\nDisk %s (Sun disk label): %d heads, %d sectors, %d cylinders\n"
84 + _("\nDisk %s (Sun disk label): %d heads, %llu sectors, %d cylinders\n"
85 "Units = %s of %d * 512 bytes\n\n"),
86 disk_device, heads, sectors, cylinders,
87 str_units(PLURAL), units_per_sector);
88 --- util-linux-2.13-pre6/fdisk/fdisk.c.sectors 2006-06-12 10:50:11.000000000 +0200
89 +++ util-linux-2.13-pre6/fdisk/fdisk.c 2006-06-12 10:51:53.000000000 +0200
92 /* A valid partition table sector ends in 0x55 0xaa */
94 -part_table_flag(char *b) {
95 +part_table_flag(unsigned char *b) {
96 return ((unsigned int) b[510]) + (((unsigned int) b[511]) << 8);
103 -write_part_table_flag(char *b) {
104 +write_part_table_flag(unsigned char *b) {
108 @@ -101,17 +101,17 @@
109 store4_little_endian(p->start4, start_sect);
114 get_start_sect(struct partition *p) {
115 return read4_little_endian(p->start4);
119 -set_nr_sects(struct partition *p, unsigned int nr_sects) {
120 +set_nr_sects(struct partition *p, unsigned long long nr_sects) {
121 store4_little_endian(p->size4, nr_sects);
126 get_nr_sects(struct partition *p) {
127 return read4_little_endian(p->size4);
130 * Raw disk label. For DOS-type partition tables the MBR,
131 * with descriptions of the primary partitions.
133 -char MBRbuffer[MAX_SECTOR_SIZE];
134 +unsigned char MBRbuffer[MAX_SECTOR_SIZE];
137 * per partition table entry data
139 struct partition *part_table; /* points into sectorbuffer */
140 struct partition *ext_pointer; /* points into sectorbuffer */
141 char changed; /* boolean */
142 - unsigned int offset; /* disk sector number */
143 - char *sectorbuffer; /* disk sector contents */
144 + unsigned long long offset; /* disk sector number */
145 + unsigned char *sectorbuffer; /* disk sector contents */
146 } ptes[MAXIMUM_PARTS];
148 char *disk_device, /* must be specified */
149 @@ -157,15 +157,14 @@
150 unsigned int pt_heads, pt_sectors;
151 unsigned int kern_heads, kern_sectors;
153 +unsigned long long sector_offset = 1, extended_offset = 0, sectors;
158 sector_size = DEFAULT_SECTOR_SIZE,
159 user_set_sector_size = 0,
161 units_per_sector = 1,
162 - display_in_cyl_units = 1,
163 - extended_offset = 0; /* offset of link pointers */
164 + display_in_cyl_units = 1;
166 unsigned long long total_number_of_sectors;
168 @@ -242,21 +241,21 @@
172 -seek_sector(int fd, unsigned int secno) {
173 +seek_sector(int fd, unsigned long long secno) {
174 off_t offset = (off_t) secno * sector_size;
175 if (lseek(fd, offset, SEEK_SET) == (off_t) -1)
176 fatal(unable_to_seek);
180 -read_sector(int fd, unsigned int secno, char *buf) {
181 +read_sector(int fd, unsigned long long secno, char *buf) {
182 seek_sector(fd, secno);
183 if (read(fd, buf, sector_size) != sector_size)
184 fatal(unable_to_read);
188 -write_sector(int fd, unsigned int secno, char *buf) {
189 +write_sector(int fd, unsigned long long secno, char *buf) {
190 seek_sector(fd, secno);
191 if (write(fd, buf, sector_size) != sector_size)
192 fatal(unable_to_write);
193 @@ -264,11 +263,11 @@
195 /* Allocate a buffer and read a partition table sector */
197 -read_pte(int fd, int pno, unsigned int offset) {
198 +read_pte(int fd, int pno, unsigned long long offset) {
199 struct pte *pe = &ptes[pno];
202 - pe->sectorbuffer = (char *) malloc(sector_size);
203 + pe->sectorbuffer = malloc(sector_size);
204 if (!pe->sectorbuffer)
205 fatal(out_of_memory);
206 read_sector(fd, offset, pe->sectorbuffer);
208 pe->part_table = pe->ext_pointer = NULL;
212 +static unsigned long long
213 get_partition_start(struct pte *pe) {
214 return pe->offset + get_start_sect(pe->part_table);
216 @@ -542,10 +541,10 @@
220 -set_partition(int i, int doext, unsigned int start, unsigned int stop,
222 +set_partition(int i, int doext, unsigned long long start,
223 + unsigned long long stop, int sysid) {
225 - unsigned int offset;
226 + unsigned long long offset;
229 p = ptes[i].ext_pointer;
230 @@ -1544,7 +1543,7 @@
232 printf(_("\nDisk %s: %ld.%ld GB, %lld bytes\n"),
233 disk_device, megabytes/1000, (megabytes/100)%10, bytes);
234 - printf(_("%d heads, %d sectors/track, %d cylinders"),
235 + printf(_("%d heads, %Ld sectors/track, %d cylinders"),
236 heads, sectors, cylinders);
237 if (units_per_sector == 1)
238 printf(_(", total %llu sectors"),
239 @@ -1776,20 +1775,21 @@
243 - printf(_("\nDisk %s: %d heads, %d sectors, %d cylinders\n\n"),
244 + printf(_("\nDisk %s: %d heads, %Ld sectors, %d cylinders\n\n"),
245 disk_device, heads, sectors, cylinders);
246 printf(_("Nr AF Hd Sec Cyl Hd Sec Cyl Start Size ID\n"));
247 for (i = 0 ; i < partitions; i++) {
249 p = (extend ? pe->ext_pointer : pe->part_table);
251 - printf("%2d %02x%4d%4d%5d%4d%4d%5d%11u%11u %02x\n",
252 + printf("%2d %02x%4d%4d%5d%4d%4d%5d%11lu%11lu %02x\n",
253 i + 1, p->boot_ind, p->head,
255 cylinder(p->sector, p->cyl), p->end_head,
256 sector(p->end_sector),
257 cylinder(p->end_sector, p->end_cyl),
258 - get_start_sect(p), get_nr_sects(p), p->sys_ind);
259 + (unsigned long) get_start_sect(p),
260 + (unsigned long) get_nr_sects(p), p->sys_ind);
262 check_consistency(p, i);
264 @@ -1797,7 +1797,7 @@
268 -fill_bounds(unsigned int *first, unsigned int *last) {
269 +fill_bounds(unsigned long long *first, unsigned long long *last) {
271 struct pte *pe = &ptes[0];
273 @@ -1830,7 +1830,7 @@
275 if (real_s >= sectors)
276 fprintf(stderr, _("Partition %d: sector %d greater than "
277 - "maximum %d\n"), n, s, sectors);
278 + "maximum %Ld\n"), n, s, sectors);
279 if (real_c >= cylinders)
280 fprintf(stderr, _("Partitions %d: cylinder %d greater than "
281 "maximum %d\n"), n, real_c + 1, cylinders);
282 @@ -1843,8 +1843,8 @@
286 - unsigned int total = 1;
287 - unsigned int first[partitions], last[partitions];
288 + unsigned long total = 1;
289 + unsigned long long first[partitions], last[partitions];
293 @@ -1888,7 +1888,7 @@
295 if (extended_offset) {
296 struct pte *pex = &ptes[ext_index];
297 - unsigned int e_last = get_start_sect(pex->part_table) +
298 + unsigned long long e_last = get_start_sect(pex->part_table) +
299 get_nr_sects(pex->part_table) - 1;
301 for (i = 4; i < partitions; i++) {
302 @@ -1907,8 +1907,8 @@
305 if (total > total_number_of_sectors)
306 - printf(_("Total allocated sectors %d greater than the maximum "
307 - "%lld\n"), total, total_number_of_sectors);
308 + printf(_("Total allocated sectors %ld greater than the maximum"
309 + " %lld\n"), total, total_number_of_sectors);
310 else if (total < total_number_of_sectors)
311 printf(_("%lld unallocated sectors\n"),
312 total_number_of_sectors - total);
313 @@ -1921,7 +1921,7 @@
314 struct partition *p = ptes[n].part_table;
315 struct partition *q = ptes[ext_index].part_table;
317 - unsigned int start, stop = 0, limit, temp,
318 + unsigned long long start, stop = 0, limit, temp,
319 first[partitions], last[partitions];
321 if (p && p->sys_ind) {
322 @@ -1967,7 +1967,7 @@
325 if (start >= temp+units_per_sector && read) {
326 - printf(_("Sector %d is already allocated\n"), temp);
327 + printf(_("Sector %llu is already allocated\n"), temp);
331 @@ -2225,14 +2225,14 @@
333 #define MAX_PER_LINE 16
335 -print_buffer(char pbuffer[]) {
336 +print_buffer(unsigned char pbuffer[]) {
340 for (i = 0, l = 0; i < sector_size; i++, l++) {
342 printf("0x%03X:", i);
343 - printf(" %02X", (unsigned char) pbuffer[i]);
344 + printf(" %02X", pbuffer[i]);
345 if (l == MAX_PER_LINE - 1) {