aboutsummaryrefslogtreecommitdiff
path: root/util-linux/fdisk_osf.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-09-16 03:03:13 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-09-16 03:03:13 +0200
commitddf7850f2b775c2148f76cd7e839b8a6e667de8e (patch)
tree7f70a23e698c6a1ddb04416259c65450fbc0d522 /util-linux/fdisk_osf.c
parent8dc0e1929e3af3b1673e5a8e486808386400c020 (diff)
downloadbusybox-w32-ddf7850f2b775c2148f76cd7e839b8a6e667de8e.tar.gz
busybox-w32-ddf7850f2b775c2148f76cd7e839b8a6e667de8e.tar.bz2
busybox-w32-ddf7850f2b775c2148f76cd7e839b8a6e667de8e.zip
fdisk: add a warning and truncate disks with >= 2^32 sectors
As a result, for sectors we can use uint32_t instead of long long, and on 32 bits it has drastic effects: function old new delta get_geometry 619 646 +27 set_sun_partition 148 150 +2 get_partition 134 135 +1 xbsd_write_bootstrap 382 381 -1 xbsd_readlabel 247 246 -1 bsd_select 1674 1672 -2 sun_other_endian 4 1 -3 scsi_disk 4 1 -3 floppy 4 1 -3 fdisk_main 3735 3732 -3 read_maybe_empty 43 37 -6 create_doslabel 111 104 -7 read_line 97 88 -9 add_logical 117 107 -10 write_table 599 588 -11 new_partition 1684 1670 -14 list_disk_geometry 229 215 -14 wrong_p_order 130 110 -20 xselect 3142 3114 -28 seek_sector 71 40 -31 get_boot 1576 1533 -43 fill_bounds 174 128 -46 delete_partition 603 551 -52 list_table 1401 1232 -169 set_partition 459 286 -173 verify 1840 1495 -345 add_partition 2486 1270 -1216 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/24 up/down: 30/-2210) Total: -2180 bytes text data bss dec hex filename 848812 460 7116 856388 d1144 busybox_old 846620 460 7108 854188 d08ac busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'util-linux/fdisk_osf.c')
-rw-r--r--util-linux/fdisk_osf.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/util-linux/fdisk_osf.c b/util-linux/fdisk_osf.c
index aeccc6913..09a68da83 100644
--- a/util-linux/fdisk_osf.c
+++ b/util-linux/fdisk_osf.c
@@ -65,8 +65,8 @@ struct xbsd_disklabel {
65 int16_t d_type; /* drive type */ 65 int16_t d_type; /* drive type */
66 int16_t d_subtype; /* controller/d_type specific */ 66 int16_t d_subtype; /* controller/d_type specific */
67 char d_typename[16]; /* type name, e.g. "eagle" */ 67 char d_typename[16]; /* type name, e.g. "eagle" */
68 char d_packname[16]; /* pack identifier */ 68 char d_packname[16]; /* pack identifier */
69 /* disk geometry: */ 69 /* disk geometry: */
70 uint32_t d_secsize; /* # of bytes per sector */ 70 uint32_t d_secsize; /* # of bytes per sector */
71 uint32_t d_nsectors; /* # of data sectors per track */ 71 uint32_t d_nsectors; /* # of data sectors per track */
72 uint32_t d_ntracks; /* # of tracks per cylinder */ 72 uint32_t d_ntracks; /* # of tracks per cylinder */
@@ -87,7 +87,7 @@ struct xbsd_disklabel {
87 */ 87 */
88 uint32_t d_acylinders; /* # of alt. cylinders per unit */ 88 uint32_t d_acylinders; /* # of alt. cylinders per unit */
89 89
90 /* hardware characteristics: */ 90 /* hardware characteristics: */
91 /* 91 /*
92 * d_interleave, d_trackskew and d_cylskew describe perturbations 92 * d_interleave, d_trackskew and d_cylskew describe perturbations
93 * in the media format used to compensate for a slow controller. 93 * in the media format used to compensate for a slow controller.
@@ -117,11 +117,11 @@ struct xbsd_disklabel {
117 uint32_t d_spare[NSPARE]; /* reserved for future use */ 117 uint32_t d_spare[NSPARE]; /* reserved for future use */
118 uint32_t d_magic2; /* the magic number (again) */ 118 uint32_t d_magic2; /* the magic number (again) */
119 uint16_t d_checksum; /* xor of data incl. partitions */ 119 uint16_t d_checksum; /* xor of data incl. partitions */
120 /* filesystem and partition information: */ 120 /* filesystem and partition information: */
121 uint16_t d_npartitions; /* number of partitions in following */ 121 uint16_t d_npartitions; /* number of partitions in following */
122 uint32_t d_bbsize; /* size of boot area at sn0, bytes */ 122 uint32_t d_bbsize; /* size of boot area at sn0, bytes */
123 uint32_t d_sbsize; /* max size of fs superblock, bytes */ 123 uint32_t d_sbsize; /* max size of fs superblock, bytes */
124 struct xbsd_partition { /* the partition table */ 124 struct xbsd_partition { /* the partition table */
125 uint32_t p_size; /* number of sectors in partition */ 125 uint32_t p_size; /* number of sectors in partition */
126 uint32_t p_offset; /* starting sector */ 126 uint32_t p_offset; /* starting sector */
127 uint32_t p_fsize; /* filesystem basic fragment size */ 127 uint32_t p_fsize; /* filesystem basic fragment size */
@@ -367,7 +367,7 @@ bsd_select(void)
367 partname(disk_device, t+1, 0)); 367 partname(disk_device, t+1, 0));
368 return; 368 return;
369 } 369 }
370 printf("Reading disklabel of %s at sector %d\n", 370 printf("Reading disklabel of %s at sector %u\n",
371 partname(disk_device, t+1, 0), ss + BSD_LABELSECTOR); 371 partname(disk_device, t+1, 0), ss + BSD_LABELSECTOR);
372 if (xbsd_readlabel(xbsd_part) == 0) 372 if (xbsd_readlabel(xbsd_part) == 0)
373 if (xbsd_create_disklabel() == 0) 373 if (xbsd_create_disklabel() == 0)
@@ -510,7 +510,7 @@ xbsd_print_disklabel(int show_all)
510 if ((unsigned) lp->d_type < ARRAY_SIZE(xbsd_dktypenames)-1) 510 if ((unsigned) lp->d_type < ARRAY_SIZE(xbsd_dktypenames)-1)
511 printf("type: %s\n", xbsd_dktypenames[lp->d_type]); 511 printf("type: %s\n", xbsd_dktypenames[lp->d_type]);
512 else 512 else
513 printf("type: %d\n", lp->d_type); 513 printf("type: %u\n", lp->d_type);
514 printf("disk: %.*s\n", (int) sizeof(lp->d_typename), lp->d_typename); 514 printf("disk: %.*s\n", (int) sizeof(lp->d_typename), lp->d_typename);
515 printf("label: %.*s\n", (int) sizeof(lp->d_packname), lp->d_packname); 515 printf("label: %.*s\n", (int) sizeof(lp->d_packname), lp->d_packname);
516 printf("flags: "); 516 printf("flags: ");
@@ -518,18 +518,18 @@ xbsd_print_disklabel(int show_all)
518 bb_putchar('\n'); 518 bb_putchar('\n');
519 /* On various machines the fields of *lp are short/int/long */ 519 /* On various machines the fields of *lp are short/int/long */
520 /* In order to avoid problems, we cast them all to long. */ 520 /* In order to avoid problems, we cast them all to long. */
521 printf("bytes/sector: %ld\n", (long) lp->d_secsize); 521 printf("bytes/sector: %lu\n", (long) lp->d_secsize);
522 printf("sectors/track: %ld\n", (long) lp->d_nsectors); 522 printf("sectors/track: %lu\n", (long) lp->d_nsectors);
523 printf("tracks/cylinder: %ld\n", (long) lp->d_ntracks); 523 printf("tracks/cylinder: %lu\n", (long) lp->d_ntracks);
524 printf("sectors/cylinder: %ld\n", (long) lp->d_secpercyl); 524 printf("sectors/cylinder: %lu\n", (long) lp->d_secpercyl);
525 printf("cylinders: %ld\n", (long) lp->d_ncylinders); 525 printf("cylinders: %lu\n", (long) lp->d_ncylinders);
526 printf("rpm: %d\n", lp->d_rpm); 526 printf("rpm: %u\n", lp->d_rpm);
527 printf("interleave: %d\n", lp->d_interleave); 527 printf("interleave: %u\n", lp->d_interleave);
528 printf("trackskew: %d\n", lp->d_trackskew); 528 printf("trackskew: %u\n", lp->d_trackskew);
529 printf("cylinderskew: %d\n", lp->d_cylskew); 529 printf("cylinderskew: %u\n", lp->d_cylskew);
530 printf("headswitch: %ld\t\t# milliseconds\n", 530 printf("headswitch: %lu\t\t# milliseconds\n",
531 (long) lp->d_headswitch); 531 (long) lp->d_headswitch);
532 printf("track-to-track seek: %ld\t# milliseconds\n", 532 printf("track-to-track seek: %lu\t# milliseconds\n",
533 (long) lp->d_trkseek); 533 (long) lp->d_trkseek);
534 printf("drivedata: "); 534 printf("drivedata: ");
535 for (i = NDDATA - 1; i >= 0; i--) 535 for (i = NDDATA - 1; i >= 0; i--)
@@ -538,25 +538,25 @@ xbsd_print_disklabel(int show_all)
538 if (i < 0) 538 if (i < 0)
539 i = 0; 539 i = 0;
540 for (j = 0; j <= i; j++) 540 for (j = 0; j <= i; j++)
541 printf("%ld ", (long) lp->d_drivedata[j]); 541 printf("%lu ", (long) lp->d_drivedata[j]);
542 } 542 }
543 printf("\n%d partitions:\n", lp->d_npartitions); 543 printf("\n%u partitions:\n", lp->d_npartitions);
544 printf("# start end size fstype [fsize bsize cpg]\n"); 544 printf("# start end size fstype [fsize bsize cpg]\n");
545 pp = lp->d_partitions; 545 pp = lp->d_partitions;
546 for (i = 0; i < lp->d_npartitions; i++, pp++) { 546 for (i = 0; i < lp->d_npartitions; i++, pp++) {
547 if (pp->p_size) { 547 if (pp->p_size) {
548 if (display_in_cyl_units && lp->d_secpercyl) { 548 if (display_in_cyl_units && lp->d_secpercyl) {
549 printf(" %c: %8ld%c %8ld%c %8ld%c ", 549 printf(" %c: %8lu%c %8lu%c %8lu%c ",
550 'a' + i, 550 'a' + i,
551 (long) pp->p_offset / lp->d_secpercyl + 1, 551 (unsigned long) pp->p_offset / lp->d_secpercyl + 1,
552 (pp->p_offset % lp->d_secpercyl) ? '*' : ' ', 552 (pp->p_offset % lp->d_secpercyl) ? '*' : ' ',
553 (long) (pp->p_offset + pp->p_size + lp->d_secpercyl - 1) / lp->d_secpercyl, 553 (unsigned long) (pp->p_offset + pp->p_size + lp->d_secpercyl - 1) / lp->d_secpercyl,
554 ((pp->p_offset + pp->p_size) % lp->d_secpercyl) ? '*' : ' ', 554 ((pp->p_offset + pp->p_size) % lp->d_secpercyl) ? '*' : ' ',
555 (long) pp->p_size / lp->d_secpercyl, 555 (long) pp->p_size / lp->d_secpercyl,
556 (pp->p_size % lp->d_secpercyl) ? '*' : ' ' 556 (pp->p_size % lp->d_secpercyl) ? '*' : ' '
557 ); 557 );
558 } else { 558 } else {
559 printf(" %c: %8ld %8ld %8ld ", 559 printf(" %c: %8lu %8lu %8lu ",
560 'a' + i, 560 'a' + i,
561 (long) pp->p_offset, 561 (long) pp->p_offset,
562 (long) pp->p_offset + pp->p_size - 1, 562 (long) pp->p_offset + pp->p_size - 1,
@@ -571,11 +571,11 @@ xbsd_print_disklabel(int show_all)
571 571
572 switch (pp->p_fstype) { 572 switch (pp->p_fstype) {
573 case BSD_FS_UNUSED: 573 case BSD_FS_UNUSED:
574 printf(" %5ld %5ld %5.5s ", 574 printf(" %5lu %5lu %5.5s ",
575 (long) pp->p_fsize, (long) pp->p_fsize * pp->p_frag, ""); 575 (long) pp->p_fsize, (long) pp->p_fsize * pp->p_frag, "");
576 break; 576 break;
577 case BSD_FS_BSDFFS: 577 case BSD_FS_BSDFFS:
578 printf(" %5ld %5ld %5d ", 578 printf(" %5lu %5lu %5u ",
579 (long) pp->p_fsize, (long) pp->p_fsize * pp->p_frag, pp->p_cpg); 579 (long) pp->p_fsize, (long) pp->p_fsize * pp->p_frag, pp->p_cpg);
580 break; 580 break;
581 default: 581 default:
@@ -637,7 +637,7 @@ xbsd_create_disklabel(void)
637static int 637static int
638edit_int(int def, const char *mesg) 638edit_int(int def, const char *mesg)
639{ 639{
640 mesg = xasprintf("%s (%d): ", mesg, def); 640 mesg = xasprintf("%s (%u): ", mesg, def);
641 do { 641 do {
642 if (!read_line(mesg)) 642 if (!read_line(mesg))
643 goto ret; 643 goto ret;
@@ -950,7 +950,7 @@ xbsd_readlabel(struct partition *p)
950 } 950 }
951 951
952 if (d->d_npartitions > BSD_MAXPARTITIONS) 952 if (d->d_npartitions > BSD_MAXPARTITIONS)
953 printf("Warning: too many partitions (%d, maximum is %d)\n", 953 printf("Warning: too many partitions (%u, maximum is %u)\n",
954 d->d_npartitions, BSD_MAXPARTITIONS); 954 d->d_npartitions, BSD_MAXPARTITIONS);
955 return 1; 955 return 1;
956} 956}