summaryrefslogtreecommitdiffhomepage
path: root/util-linux/fdisk_sun.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_sun.c
parent8dc0e1929e3af3b1673e5a8e486808386400c020 (diff)
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_sun.c')
-rw-r--r--util-linux/fdisk_sun.c57
1 files changed, 29 insertions, 28 deletions
diff --git a/util-linux/fdisk_sun.c b/util-linux/fdisk_sun.c
index 9cdf869e9..fa6f7e48b 100644
--- a/util-linux/fdisk_sun.c
+++ b/util-linux/fdisk_sun.c
@@ -27,9 +27,9 @@
#define SCSI_IOCTL_GET_IDLUN 0x5382
-static int sun_other_endian;
-static int scsi_disk;
-static int floppy;
+static smallint sun_other_endian;
+static smallint scsi_disk;
+static smallint floppy;
#ifndef IDE0_MAJOR
#define IDE0_MAJOR 3
@@ -81,7 +81,7 @@ static const char *const sun_sys_types[] = {
static void
-set_sun_partition(int i, uint start, uint stop, int sysid)
+set_sun_partition(int i, unsigned start, unsigned stop, int sysid)
{
sunlabel->infos[i].id = sysid;
sunlabel->partitions[i].start_cylinder =
@@ -98,7 +98,8 @@ check_sun_label(void)
int csum;
if (sunlabel->magic != SUN_LABEL_MAGIC
- && sunlabel->magic != SUN_LABEL_MAGIC_SWAPPED) {
+ && sunlabel->magic != SUN_LABEL_MAGIC_SWAPPED
+ ) {
current_label_type = LABEL_DOS;
sun_other_endian = 0;
return 0;
@@ -173,7 +174,7 @@ sun_autoconfigure_scsi(void)
return NULL;
sprintf(buffer,
- "Host: scsi%d Channel: %02d Id: %02d Lun: %02d\n",
+ "Host: scsi%u Channel: %02u Id: %02u Lun: %02u\n",
/* This is very wrong (works only if you have one HBA),
but I haven't found a way how to get hostno
from the current kernel */
@@ -317,7 +318,7 @@ create_sunlabel(void)
}
snprintf((char *)(sunlabel->info), sizeof(sunlabel->info),
- "%s%s%s cyl %d alt %d hd %d sec %d",
+ "%s%s%s cyl %u alt %u hd %u sec %u",
p ? p->vendor : "", (p && *p->vendor) ? " " : "",
p ? p->model : (floppy ? "3,5\" floppy" : "Linux custom"),
g_cylinders, SUN_SSWAP16(sunlabel->nacyl), g_heads, g_sectors);
@@ -361,7 +362,7 @@ toggle_sunflags(int i, unsigned char mask)
}
static void
-fetch_sun(uint *starts, uint *lens, uint *start, uint *stop)
+fetch_sun(unsigned *starts, unsigned *lens, unsigned *start, unsigned *stop)
{
int i, continuous = 1;
@@ -390,7 +391,7 @@ fetch_sun(uint *starts, uint *lens, uint *start, uint *stop)
}
}
-static uint *verify_sun_starts;
+static unsigned *verify_sun_starts;
static int
verify_sun_cmp(int *a, int *b)
@@ -404,7 +405,7 @@ verify_sun_cmp(int *a, int *b)
static void
verify_sun(void)
{
- uint starts[8], lens[8], start, stop;
+ unsigned starts[8], lens[8], start, stop;
int i,j,k,starto,endo;
int array[8];
@@ -413,7 +414,7 @@ verify_sun(void)
for (k = 0; k < 7; k++) {
for (i = 0; i < 8; i++) {
if (k && (lens[i] % (g_heads * g_sectors))) {
- printf("Partition %d doesn't end on cylinder boundary\n", i+1);
+ printf("Partition %u doesn't end on cylinder boundary\n", i+1);
}
if (lens[i]) {
for (j = 0; j < i; j++)
@@ -433,8 +434,8 @@ verify_sun(void)
endo = starts[i]+lens[i];
if (starts[j]+lens[j] < endo)
endo = starts[j]+lens[j];
- printf("Partition %d overlaps with others in "
- "sectors %d-%d\n", i+1, starto, endo);
+ printf("Partition %u overlaps with others in "
+ "sectors %u-%u\n", i+1, starto, endo);
}
}
}
@@ -455,20 +456,20 @@ verify_sun(void)
}
stop = g_cylinders * g_heads * g_sectors;
if (starts[array[0]])
- printf("Unused gap - sectors 0-%d\n", starts[array[0]]);
+ printf("Unused gap - sectors %u-%u\n", 0, starts[array[0]]);
for (i = 0; i < 7 && array[i+1] != -1; i++) {
- printf("Unused gap - sectors %d-%d\n", starts[array[i]]+lens[array[i]], starts[array[i+1]]);
+ printf("Unused gap - sectors %u-%u\n", starts[array[i]]+lens[array[i]], starts[array[i+1]]);
}
start = starts[array[i]] + lens[array[i]];
if (start < stop)
- printf("Unused gap - sectors %d-%d\n", start, stop);
+ printf("Unused gap - sectors %u-%u\n", start, stop);
}
static void
add_sun_partition(int n, int sys)
{
- uint start, stop, stop2;
- uint starts[8], lens[8];
+ unsigned start, stop, stop2;
+ unsigned starts[8], lens[8];
int whole_disk = 0;
char mesg[256];
@@ -529,7 +530,7 @@ and is of type 'Whole disk'\n");
whole_disk = 1;
break;
}
- printf("Sector %d is already allocated\n", first);
+ printf("Sector %u is already allocated\n", first);
} else
break;
}
@@ -560,8 +561,8 @@ and is of type 'Whole disk'\n");
} else if (last > stop) {
printf(
"You haven't covered the whole disk with the 3rd partition,\n"
-"but your value %d %s covers some other partition.\n"
-"Your entry has been changed to %d %s\n",
+"but your value %u %s covers some other partition.\n"
+"Your entry has been changed to %u %s\n",
scround(last), str_units(SINGULAR),
scround(stop), str_units(SINGULAR));
last = stop;
@@ -627,11 +628,11 @@ sun_list_table(int xtra)
w = strlen(disk_device);
if (xtra)
printf(
- "\nDisk %s (Sun disk label): %d heads, %d sectors, %d rpm\n"
- "%d cylinders, %d alternate cylinders, %d physical cylinders\n"
- "%d extra sects/cyl, interleave %d:1\n"
+ "\nDisk %s (Sun disk label): %u heads, %u sectors, %u rpm\n"
+ "%u cylinders, %u alternate cylinders, %u physical cylinders\n"
+ "%u extra sects/cyl, interleave %u:1\n"
"%s\n"
- "Units = %s of %d * 512 bytes\n\n",
+ "Units = %s of %u * 512 bytes\n\n",
disk_device, g_heads, g_sectors, SUN_SSWAP16(sunlabel->rspeed),
g_cylinders, SUN_SSWAP16(sunlabel->nacyl),
SUN_SSWAP16(sunlabel->pcylcount),
@@ -641,8 +642,8 @@ sun_list_table(int xtra)
str_units(PLURAL), units_per_sector);
else
printf(
- "\nDisk %s (Sun disk label): %d heads, %d sectors, %d cylinders\n"
- "Units = %s of %d * 512 bytes\n\n",
+ "\nDisk %s (Sun disk label): %u heads, %u sectors, %u cylinders\n"
+ "Units = %s of %u * 512 bytes\n\n",
disk_device, g_heads, g_sectors, g_cylinders,
str_units(PLURAL), units_per_sector);
@@ -652,7 +653,7 @@ sun_list_table(int xtra)
if (sunlabel->partitions[i].num_sectors) {
uint32_t start = SUN_SSWAP32(sunlabel->partitions[i].start_cylinder) * g_heads * g_sectors;
uint32_t len = SUN_SSWAP32(sunlabel->partitions[i].num_sectors);
- printf("%s %c%c %9ld %9ld %9ld%c %2x %s\n",
+ printf("%s %c%c %9lu %9lu %9lu%c %2x %s\n",
partname(disk_device, i+1, w), /* device */
(sunlabel->infos[i].flags & 0x01) ? 'u' : ' ', /* flags */
(sunlabel->infos[i].flags & 0x10) ? 'r' : ' ',