diff options
-rw-r--r-- | util-linux/fdisk.c | 293 | ||||
-rw-r--r-- | util-linux/fdisk_aix.c | 5 | ||||
-rw-r--r-- | util-linux/fdisk_osf.c | 56 | ||||
-rw-r--r-- | util-linux/fdisk_sgi.c | 46 | ||||
-rw-r--r-- | util-linux/fdisk_sun.c | 57 |
5 files changed, 246 insertions, 211 deletions
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c index 441640831..e50ee77d1 100644 --- a/util-linux/fdisk.c +++ b/util-linux/fdisk.c | |||
@@ -53,8 +53,18 @@ enum { | |||
53 | }; | 53 | }; |
54 | 54 | ||
55 | 55 | ||
56 | /* Used for sector numbers. Today's disk sizes make it necessary */ | ||
57 | typedef unsigned long long ullong; | 56 | typedef unsigned long long ullong; |
57 | /* Used for sector numbers. Partition formats we know | ||
58 | * do not support more than 2^32 sectors | ||
59 | */ | ||
60 | typedef uint32_t sector_t; | ||
61 | #if UINT_MAX == 4294967295 | ||
62 | # define SECT_FMT "" | ||
63 | #elif ULONG_MAX == 4294967295 | ||
64 | # define SECT_FMT "l" | ||
65 | #else | ||
66 | # error Cant detect sizeof(uint32_t) | ||
67 | #endif | ||
58 | 68 | ||
59 | struct hd_geometry { | 69 | struct hd_geometry { |
60 | unsigned char heads; | 70 | unsigned char heads; |
@@ -71,7 +81,7 @@ static const char msg_building_new_label[] ALIGN1 = | |||
71 | "won't be recoverable.\n\n"; | 81 | "won't be recoverable.\n\n"; |
72 | 82 | ||
73 | static const char msg_part_already_defined[] ALIGN1 = | 83 | static const char msg_part_already_defined[] ALIGN1 = |
74 | "Partition %d is already defined, delete it before re-adding\n"; | 84 | "Partition %u is already defined, delete it before re-adding\n"; |
75 | 85 | ||
76 | 86 | ||
77 | struct partition { | 87 | struct partition { |
@@ -136,9 +146,9 @@ static void update_units(void); | |||
136 | static void change_units(void); | 146 | static void change_units(void); |
137 | static void reread_partition_table(int leave); | 147 | static void reread_partition_table(int leave); |
138 | static void delete_partition(int i); | 148 | static void delete_partition(int i); |
139 | static int get_partition(int warn, int max); | 149 | static unsigned get_partition(int warn, unsigned max); |
140 | static void list_types(const char *const *sys); | 150 | static void list_types(const char *const *sys); |
141 | static unsigned read_int(unsigned low, unsigned dflt, unsigned high, unsigned base, const char *mesg); | 151 | static sector_t read_int(sector_t low, sector_t dflt, sector_t high, sector_t base, const char *mesg); |
142 | #endif | 152 | #endif |
143 | static const char *partition_type(unsigned char type); | 153 | static const char *partition_type(unsigned char type); |
144 | static void get_geometry(void); | 154 | static void get_geometry(void); |
@@ -151,8 +161,8 @@ static int get_boot(void); | |||
151 | #define PLURAL 0 | 161 | #define PLURAL 0 |
152 | #define SINGULAR 1 | 162 | #define SINGULAR 1 |
153 | 163 | ||
154 | static unsigned get_start_sect(const struct partition *p); | 164 | static sector_t get_start_sect(const struct partition *p); |
155 | static unsigned get_nr_sects(const struct partition *p); | 165 | static sector_t get_nr_sects(const struct partition *p); |
156 | 166 | ||
157 | /* | 167 | /* |
158 | * per partition table entry data | 168 | * per partition table entry data |
@@ -165,8 +175,8 @@ static unsigned get_nr_sects(const struct partition *p); | |||
165 | struct pte { | 175 | struct pte { |
166 | struct partition *part_table; /* points into sectorbuffer */ | 176 | struct partition *part_table; /* points into sectorbuffer */ |
167 | struct partition *ext_pointer; /* points into sectorbuffer */ | 177 | struct partition *ext_pointer; /* points into sectorbuffer */ |
168 | ullong offset; /* disk sector number */ | 178 | sector_t offset; /* disk sector number */ |
169 | char *sectorbuffer; /* disk sector contents */ | 179 | char *sectorbuffer; /* disk sector contents */ |
170 | #if ENABLE_FEATURE_FDISK_WRITABLE | 180 | #if ENABLE_FEATURE_FDISK_WRITABLE |
171 | char changed; /* boolean */ | 181 | char changed; /* boolean */ |
172 | #endif | 182 | #endif |
@@ -308,8 +318,8 @@ struct globals { | |||
308 | unsigned user_cylinders, user_heads, user_sectors; | 318 | unsigned user_cylinders, user_heads, user_sectors; |
309 | unsigned pt_heads, pt_sectors; | 319 | unsigned pt_heads, pt_sectors; |
310 | unsigned kern_heads, kern_sectors; | 320 | unsigned kern_heads, kern_sectors; |
311 | ullong extended_offset; /* offset of link pointers */ | 321 | sector_t extended_offset; /* offset of link pointers */ |
312 | ullong total_number_of_sectors; | 322 | sector_t total_number_of_sectors; |
313 | 323 | ||
314 | jmp_buf listingbuf; | 324 | jmp_buf listingbuf; |
315 | char line_buffer[80]; | 325 | char line_buffer[80]; |
@@ -364,18 +374,36 @@ struct globals { | |||
364 | 374 | ||
365 | 375 | ||
366 | /* TODO: move to libbb? */ | 376 | /* TODO: move to libbb? */ |
367 | static ullong bb_BLKGETSIZE_sectors(int fd) | 377 | /* TODO: return unsigned long long, FEATURE_FDISK_BLKSIZE _can_ handle |
378 | * disks > 2^32 sectors | ||
379 | */ | ||
380 | static sector_t bb_BLKGETSIZE_sectors(int fd) | ||
368 | { | 381 | { |
369 | uint64_t v64; | 382 | uint64_t v64; |
370 | unsigned long longsectors; | 383 | unsigned long longsectors; |
371 | 384 | ||
372 | if (ioctl(fd, BLKGETSIZE64, &v64) == 0) { | 385 | if (ioctl(fd, BLKGETSIZE64, &v64) == 0) { |
373 | /* Got bytes, convert to 512 byte sectors */ | 386 | /* Got bytes, convert to 512 byte sectors */ |
374 | return (v64 >> 9); | 387 | v64 >>= 9; |
388 | if (v64 != (sector_t)v64) { | ||
389 | ret_trunc: | ||
390 | /* Not only DOS, but all other partition tables | ||
391 | * we support can't record more than 32 bit | ||
392 | * sector counts or offsets | ||
393 | */ | ||
394 | bb_error_msg("device has more than 2^32 sectors, can't use all of them"); | ||
395 | v64 = (uint32_t)-1L; | ||
396 | } | ||
397 | return v64; | ||
375 | } | 398 | } |
376 | /* Needs temp of type long */ | 399 | /* Needs temp of type long */ |
377 | if (ioctl(fd, BLKGETSIZE, &longsectors)) | 400 | if (ioctl(fd, BLKGETSIZE, &longsectors)) |
378 | longsectors = 0; | 401 | longsectors = 0; |
402 | if (sizeof(long) > sizeof(sector_t) | ||
403 | && longsectors != (sector_t)longsectors | ||
404 | ) { | ||
405 | goto ret_trunc; | ||
406 | } | ||
379 | return longsectors; | 407 | return longsectors; |
380 | } | 408 | } |
381 | 409 | ||
@@ -566,15 +594,16 @@ static void fdisk_fatal(const char *why) | |||
566 | } | 594 | } |
567 | 595 | ||
568 | static void | 596 | static void |
569 | seek_sector(ullong secno) | 597 | seek_sector(sector_t secno) |
570 | { | 598 | { |
571 | secno *= sector_size; | ||
572 | #if ENABLE_FDISK_SUPPORT_LARGE_DISKS | 599 | #if ENABLE_FDISK_SUPPORT_LARGE_DISKS |
573 | if (lseek64(dev_fd, (off64_t)secno, SEEK_SET) == (off64_t) -1) | 600 | off64_t off = (off64_t)secno * sector_size; |
601 | if (lseek64(dev_fd, off, SEEK_SET) == (off64_t) -1) | ||
574 | fdisk_fatal(unable_to_seek); | 602 | fdisk_fatal(unable_to_seek); |
575 | #else | 603 | #else |
576 | if (secno > MAXINT(off_t) | 604 | uint64_t off = (uint64_t)secno * sector_size; |
577 | || lseek(dev_fd, (off_t)secno, SEEK_SET) == (off_t) -1 | 605 | if (off > MAXINT(off_t) |
606 | || lseek(dev_fd, (off_t)off, SEEK_SET) == (off_t) -1 | ||
578 | ) { | 607 | ) { |
579 | fdisk_fatal(unable_to_seek); | 608 | fdisk_fatal(unable_to_seek); |
580 | } | 609 | } |
@@ -583,7 +612,7 @@ seek_sector(ullong secno) | |||
583 | 612 | ||
584 | #if ENABLE_FEATURE_FDISK_WRITABLE | 613 | #if ENABLE_FEATURE_FDISK_WRITABLE |
585 | static void | 614 | static void |
586 | write_sector(ullong secno, const void *buf) | 615 | write_sector(sector_t secno, const void *buf) |
587 | { | 616 | { |
588 | seek_sector(secno); | 617 | seek_sector(secno); |
589 | xwrite(dev_fd, buf, sector_size); | 618 | xwrite(dev_fd, buf, sector_size); |
@@ -707,7 +736,7 @@ set_start_sect(struct partition *p, unsigned start_sect) | |||
707 | } | 736 | } |
708 | #endif | 737 | #endif |
709 | 738 | ||
710 | static unsigned | 739 | static sector_t |
711 | get_start_sect(const struct partition *p) | 740 | get_start_sect(const struct partition *p) |
712 | { | 741 | { |
713 | return read4_little_endian(p->start4); | 742 | return read4_little_endian(p->start4); |
@@ -721,7 +750,7 @@ set_nr_sects(struct partition *p, unsigned nr_sects) | |||
721 | } | 750 | } |
722 | #endif | 751 | #endif |
723 | 752 | ||
724 | static unsigned | 753 | static sector_t |
725 | get_nr_sects(const struct partition *p) | 754 | get_nr_sects(const struct partition *p) |
726 | { | 755 | { |
727 | return read4_little_endian(p->size4); | 756 | return read4_little_endian(p->size4); |
@@ -729,7 +758,7 @@ get_nr_sects(const struct partition *p) | |||
729 | 758 | ||
730 | /* Allocate a buffer and read a partition table sector */ | 759 | /* Allocate a buffer and read a partition table sector */ |
731 | static void | 760 | static void |
732 | read_pte(struct pte *pe, ullong offset) | 761 | read_pte(struct pte *pe, sector_t offset) |
733 | { | 762 | { |
734 | pe->offset = offset; | 763 | pe->offset = offset; |
735 | pe->sectorbuffer = xzalloc(sector_size); | 764 | pe->sectorbuffer = xzalloc(sector_size); |
@@ -743,7 +772,7 @@ read_pte(struct pte *pe, ullong offset) | |||
743 | pe->part_table = pe->ext_pointer = NULL; | 772 | pe->part_table = pe->ext_pointer = NULL; |
744 | } | 773 | } |
745 | 774 | ||
746 | static unsigned | 775 | static sector_t |
747 | get_partition_start(const struct pte *pe) | 776 | get_partition_start(const struct pte *pe) |
748 | { | 777 | { |
749 | return pe->offset + get_start_sect(pe->part_table); | 778 | return pe->offset + get_start_sect(pe->part_table); |
@@ -985,10 +1014,10 @@ clear_partition(struct partition *p) | |||
985 | 1014 | ||
986 | #if ENABLE_FEATURE_FDISK_WRITABLE | 1015 | #if ENABLE_FEATURE_FDISK_WRITABLE |
987 | static void | 1016 | static void |
988 | set_partition(int i, int doext, ullong start, ullong stop, int sysid) | 1017 | set_partition(int i, int doext, sector_t start, sector_t stop, int sysid) |
989 | { | 1018 | { |
990 | struct partition *p; | 1019 | struct partition *p; |
991 | ullong offset; | 1020 | sector_t offset; |
992 | 1021 | ||
993 | if (doext) { | 1022 | if (doext) { |
994 | p = ptes[i].ext_pointer; | 1023 | p = ptes[i].ext_pointer; |
@@ -1049,7 +1078,7 @@ warn_cylinders(void) | |||
1049 | { | 1078 | { |
1050 | if (LABEL_IS_DOS && g_cylinders > 1024 && !nowarn) | 1079 | if (LABEL_IS_DOS && g_cylinders > 1024 && !nowarn) |
1051 | printf("\n" | 1080 | printf("\n" |
1052 | "The number of cylinders for this disk is set to %d.\n" | 1081 | "The number of cylinders for this disk is set to %u.\n" |
1053 | "There is nothing wrong with that, but this is larger than 1024,\n" | 1082 | "There is nothing wrong with that, but this is larger than 1024,\n" |
1054 | "and could in certain setups cause problems with:\n" | 1083 | "and could in certain setups cause problems with:\n" |
1055 | "1) software that runs at boot time (e.g., old versions of LILO)\n" | 1084 | "1) software that runs at boot time (e.g., old versions of LILO)\n" |
@@ -1085,7 +1114,7 @@ read_extended(int ext) | |||
1085 | Do not try to 'improve' this test. */ | 1114 | Do not try to 'improve' this test. */ |
1086 | struct pte *pre = &ptes[g_partitions - 1]; | 1115 | struct pte *pre = &ptes[g_partitions - 1]; |
1087 | #if ENABLE_FEATURE_FDISK_WRITABLE | 1116 | #if ENABLE_FEATURE_FDISK_WRITABLE |
1088 | printf("Warning: deleting partitions after %d\n", | 1117 | printf("Warning: deleting partitions after %u\n", |
1089 | g_partitions); | 1118 | g_partitions); |
1090 | pre->changed = 1; | 1119 | pre->changed = 1; |
1091 | #endif | 1120 | #endif |
@@ -1104,14 +1133,14 @@ read_extended(int ext) | |||
1104 | if (pe->ext_pointer) | 1133 | if (pe->ext_pointer) |
1105 | printf("Warning: extra link " | 1134 | printf("Warning: extra link " |
1106 | "pointer in partition table" | 1135 | "pointer in partition table" |
1107 | " %d\n", g_partitions + 1); | 1136 | " %u\n", g_partitions + 1); |
1108 | else | 1137 | else |
1109 | pe->ext_pointer = p; | 1138 | pe->ext_pointer = p; |
1110 | } else if (p->sys_ind) { | 1139 | } else if (p->sys_ind) { |
1111 | if (pe->part_table) | 1140 | if (pe->part_table) |
1112 | printf("Warning: ignoring extra " | 1141 | printf("Warning: ignoring extra " |
1113 | "data in partition table" | 1142 | "data in partition table" |
1114 | " %d\n", g_partitions + 1); | 1143 | " %u\n", g_partitions + 1); |
1115 | else | 1144 | else |
1116 | pe->part_table = p; | 1145 | pe->part_table = p; |
1117 | } | 1146 | } |
@@ -1144,7 +1173,7 @@ read_extended(int ext) | |||
1144 | if (!get_nr_sects(pe->part_table) | 1173 | if (!get_nr_sects(pe->part_table) |
1145 | && (g_partitions > 5 || ptes[4].part_table->sys_ind) | 1174 | && (g_partitions > 5 || ptes[4].part_table->sys_ind) |
1146 | ) { | 1175 | ) { |
1147 | printf("Omitting empty partition (%d)\n", i+1); | 1176 | printf("Omitting empty partition (%u)\n", i+1); |
1148 | delete_partition(i); | 1177 | delete_partition(i); |
1149 | goto remove; /* numbering changed */ | 1178 | goto remove; /* numbering changed */ |
1150 | } | 1179 | } |
@@ -1185,7 +1214,7 @@ get_sectorsize(void) | |||
1185 | if (ioctl(dev_fd, BLKSSZGET, &arg) == 0) | 1214 | if (ioctl(dev_fd, BLKSSZGET, &arg) == 0) |
1186 | sector_size = arg; | 1215 | sector_size = arg; |
1187 | if (sector_size != DEFAULT_SECTOR_SIZE) | 1216 | if (sector_size != DEFAULT_SECTOR_SIZE) |
1188 | printf("Note: sector size is %d " | 1217 | printf("Note: sector size is %u " |
1189 | "(not " DEFAULT_SECTOR_SIZE_STR ")\n", | 1218 | "(not " DEFAULT_SECTOR_SIZE_STR ")\n", |
1190 | sector_size); | 1219 | sector_size); |
1191 | } | 1220 | } |
@@ -1396,7 +1425,7 @@ static int get_boot(void) | |||
1396 | if (IS_EXTENDED(ptes[i].part_table->sys_ind)) { | 1425 | if (IS_EXTENDED(ptes[i].part_table->sys_ind)) { |
1397 | if (g_partitions != 4) | 1426 | if (g_partitions != 4) |
1398 | printf("Ignoring extra extended " | 1427 | printf("Ignoring extra extended " |
1399 | "partition %d\n", i + 1); | 1428 | "partition %u\n", i + 1); |
1400 | else | 1429 | else |
1401 | read_extended(i); | 1430 | read_extended(i); |
1402 | } | 1431 | } |
@@ -1406,7 +1435,7 @@ static int get_boot(void) | |||
1406 | struct pte *pe = &ptes[i]; | 1435 | struct pte *pe = &ptes[i]; |
1407 | if (!valid_part_table_flag(pe->sectorbuffer)) { | 1436 | if (!valid_part_table_flag(pe->sectorbuffer)) { |
1408 | printf("Warning: invalid flag 0x%02x,0x%02x of partition " | 1437 | printf("Warning: invalid flag 0x%02x,0x%02x of partition " |
1409 | "table %d will be corrected by w(rite)\n", | 1438 | "table %u will be corrected by w(rite)\n", |
1410 | pe->sectorbuffer[510], | 1439 | pe->sectorbuffer[510], |
1411 | pe->sectorbuffer[511], | 1440 | pe->sectorbuffer[511], |
1412 | i + 1); | 1441 | i + 1); |
@@ -1425,10 +1454,10 @@ static int get_boot(void) | |||
1425 | * | 1454 | * |
1426 | * There is no default if DFLT is not between LOW and HIGH. | 1455 | * There is no default if DFLT is not between LOW and HIGH. |
1427 | */ | 1456 | */ |
1428 | static unsigned | 1457 | static sector_t |
1429 | read_int(unsigned low, unsigned dflt, unsigned high, unsigned base, const char *mesg) | 1458 | read_int(sector_t low, sector_t dflt, sector_t high, sector_t base, const char *mesg) |
1430 | { | 1459 | { |
1431 | unsigned i; | 1460 | sector_t value; |
1432 | int default_ok = 1; | 1461 | int default_ok = 1; |
1433 | const char *fmt = "%s (%u-%u, default %u): "; | 1462 | const char *fmt = "%s (%u-%u, default %u): "; |
1434 | 1463 | ||
@@ -1451,8 +1480,10 @@ read_int(unsigned low, unsigned dflt, unsigned high, unsigned base, const char * | |||
1451 | int minus = (*line_ptr == '-'); | 1480 | int minus = (*line_ptr == '-'); |
1452 | int absolute = 0; | 1481 | int absolute = 0; |
1453 | 1482 | ||
1454 | i = atoi(line_ptr + 1); | 1483 | value = atoi(line_ptr + 1); |
1455 | 1484 | ||
1485 | /* (1) if 2nd char is digit, use_default = 0. | ||
1486 | * (2) move line_ptr to first non-digit. */ | ||
1456 | while (isdigit(*++line_ptr)) | 1487 | while (isdigit(*++line_ptr)) |
1457 | use_default = 0; | 1488 | use_default = 0; |
1458 | 1489 | ||
@@ -1460,7 +1491,7 @@ read_int(unsigned low, unsigned dflt, unsigned high, unsigned base, const char * | |||
1460 | case 'c': | 1491 | case 'c': |
1461 | case 'C': | 1492 | case 'C': |
1462 | if (!display_in_cyl_units) | 1493 | if (!display_in_cyl_units) |
1463 | i *= g_heads * g_sectors; | 1494 | value *= g_heads * g_sectors; |
1464 | break; | 1495 | break; |
1465 | case 'K': | 1496 | case 'K': |
1466 | absolute = 1024; | 1497 | absolute = 1024; |
@@ -1483,38 +1514,38 @@ read_int(unsigned low, unsigned dflt, unsigned high, unsigned base, const char * | |||
1483 | ullong bytes; | 1514 | ullong bytes; |
1484 | unsigned long unit; | 1515 | unsigned long unit; |
1485 | 1516 | ||
1486 | bytes = (ullong) i * absolute; | 1517 | bytes = (ullong) value * absolute; |
1487 | unit = sector_size * units_per_sector; | 1518 | unit = sector_size * units_per_sector; |
1488 | bytes += unit/2; /* round */ | 1519 | bytes += unit/2; /* round */ |
1489 | bytes /= unit; | 1520 | bytes /= unit; |
1490 | i = bytes; | 1521 | value = bytes; |
1491 | } | 1522 | } |
1492 | if (minus) | 1523 | if (minus) |
1493 | i = -i; | 1524 | value = -value; |
1494 | i += base; | 1525 | value += base; |
1495 | } else { | 1526 | } else { |
1496 | i = atoi(line_ptr); | 1527 | value = atoi(line_ptr); |
1497 | while (isdigit(*line_ptr)) { | 1528 | while (isdigit(*line_ptr)) { |
1498 | line_ptr++; | 1529 | line_ptr++; |
1499 | use_default = 0; | 1530 | use_default = 0; |
1500 | } | 1531 | } |
1501 | } | 1532 | } |
1502 | if (use_default) { | 1533 | if (use_default) { |
1503 | i = dflt; | 1534 | value = dflt; |
1504 | printf("Using default value %u\n", i); | 1535 | printf("Using default value %u\n", value); |
1505 | } | 1536 | } |
1506 | if (i >= low && i <= high) | 1537 | if (value >= low && value <= high) |
1507 | break; | 1538 | break; |
1508 | printf("Value is out of range\n"); | 1539 | printf("Value is out of range\n"); |
1509 | } | 1540 | } |
1510 | return i; | 1541 | return value; |
1511 | } | 1542 | } |
1512 | 1543 | ||
1513 | static int | 1544 | static unsigned |
1514 | get_partition(int warn, int max) | 1545 | get_partition(int warn, unsigned max) |
1515 | { | 1546 | { |
1516 | struct pte *pe; | 1547 | struct pte *pe; |
1517 | int i; | 1548 | unsigned i; |
1518 | 1549 | ||
1519 | i = read_int(1, 0, max, 0, "Partition number") - 1; | 1550 | i = read_int(1, 0, max, 0, "Partition number") - 1; |
1520 | pe = &ptes[i]; | 1551 | pe = &ptes[i]; |
@@ -1524,17 +1555,17 @@ get_partition(int warn, int max) | |||
1524 | || (LABEL_IS_SUN && (!sunlabel->partitions[i].num_sectors || !sunlabel->infos[i].id)) | 1555 | || (LABEL_IS_SUN && (!sunlabel->partitions[i].num_sectors || !sunlabel->infos[i].id)) |
1525 | || (LABEL_IS_SGI && !sgi_get_num_sectors(i)) | 1556 | || (LABEL_IS_SGI && !sgi_get_num_sectors(i)) |
1526 | ) { | 1557 | ) { |
1527 | printf("Warning: partition %d has empty type\n", i+1); | 1558 | printf("Warning: partition %u has empty type\n", i+1); |
1528 | } | 1559 | } |
1529 | } | 1560 | } |
1530 | return i; | 1561 | return i; |
1531 | } | 1562 | } |
1532 | 1563 | ||
1533 | static int | 1564 | static int |
1534 | get_existing_partition(int warn, int max) | 1565 | get_existing_partition(int warn, unsigned max) |
1535 | { | 1566 | { |
1536 | int pno = -1; | 1567 | int pno = -1; |
1537 | int i; | 1568 | unsigned i; |
1538 | 1569 | ||
1539 | for (i = 0; i < max; i++) { | 1570 | for (i = 0; i < max; i++) { |
1540 | struct pte *pe = &ptes[i]; | 1571 | struct pte *pe = &ptes[i]; |
@@ -1547,7 +1578,7 @@ get_existing_partition(int warn, int max) | |||
1547 | } | 1578 | } |
1548 | } | 1579 | } |
1549 | if (pno >= 0) { | 1580 | if (pno >= 0) { |
1550 | printf("Selected partition %d\n", pno+1); | 1581 | printf("Selected partition %u\n", pno+1); |
1551 | return pno; | 1582 | return pno; |
1552 | } | 1583 | } |
1553 | printf("No partition is defined yet!\n"); | 1584 | printf("No partition is defined yet!\n"); |
@@ -1558,10 +1589,10 @@ get_existing_partition(int warn, int max) | |||
1558 | } | 1589 | } |
1559 | 1590 | ||
1560 | static int | 1591 | static int |
1561 | get_nonexisting_partition(int warn, int max) | 1592 | get_nonexisting_partition(int warn, unsigned max) |
1562 | { | 1593 | { |
1563 | int pno = -1; | 1594 | int pno = -1; |
1564 | int i; | 1595 | unsigned i; |
1565 | 1596 | ||
1566 | for (i = 0; i < max; i++) { | 1597 | for (i = 0; i < max; i++) { |
1567 | struct pte *pe = &ptes[i]; | 1598 | struct pte *pe = &ptes[i]; |
@@ -1574,7 +1605,7 @@ get_nonexisting_partition(int warn, int max) | |||
1574 | } | 1605 | } |
1575 | } | 1606 | } |
1576 | if (pno >= 0) { | 1607 | if (pno >= 0) { |
1577 | printf("Selected partition %d\n", pno+1); | 1608 | printf("Selected partition %u\n", pno+1); |
1578 | return pno; | 1609 | return pno; |
1579 | } | 1610 | } |
1580 | printf("All primary partitions have been defined already!\n"); | 1611 | printf("All primary partitions have been defined already!\n"); |
@@ -1601,7 +1632,7 @@ toggle_active(int i) | |||
1601 | struct partition *p = pe->part_table; | 1632 | struct partition *p = pe->part_table; |
1602 | 1633 | ||
1603 | if (IS_EXTENDED(p->sys_ind) && !p->boot_ind) | 1634 | if (IS_EXTENDED(p->sys_ind) && !p->boot_ind) |
1604 | printf("WARNING: Partition %d is an extended partition\n", i + 1); | 1635 | printf("WARNING: Partition %u is an extended partition\n", i + 1); |
1605 | p->boot_ind = (p->boot_ind ? 0 : ACTIVE_FLAG); | 1636 | p->boot_ind = (p->boot_ind ? 0 : ACTIVE_FLAG); |
1606 | pe->changed = 1; | 1637 | pe->changed = 1; |
1607 | } | 1638 | } |
@@ -1674,8 +1705,8 @@ delete_partition(int i) | |||
1674 | 1705 | ||
1675 | if (pe->part_table) /* prevent SEGFAULT */ | 1706 | if (pe->part_table) /* prevent SEGFAULT */ |
1676 | set_start_sect(pe->part_table, | 1707 | set_start_sect(pe->part_table, |
1677 | get_partition_start(pe) - | 1708 | get_partition_start(pe) - |
1678 | extended_offset); | 1709 | extended_offset); |
1679 | pe->offset = extended_offset; | 1710 | pe->offset = extended_offset; |
1680 | pe->changed = 1; | 1711 | pe->changed = 1; |
1681 | } | 1712 | } |
@@ -1714,7 +1745,7 @@ change_sysid(void) | |||
1714 | /* if changing types T to 0 is allowed, then | 1745 | /* if changing types T to 0 is allowed, then |
1715 | the reverse change must be allowed, too */ | 1746 | the reverse change must be allowed, too */ |
1716 | if (!sys && !LABEL_IS_SGI && !LABEL_IS_SUN && !get_nr_sects(p)) { | 1747 | if (!sys && !LABEL_IS_SGI && !LABEL_IS_SUN && !get_nr_sects(p)) { |
1717 | printf("Partition %d does not exist yet!\n", i + 1); | 1748 | printf("Partition %u does not exist yet!\n", i + 1); |
1718 | return; | 1749 | return; |
1719 | } | 1750 | } |
1720 | while (1) { | 1751 | while (1) { |
@@ -1765,7 +1796,7 @@ change_sysid(void) | |||
1765 | } else | 1796 | } else |
1766 | p->sys_ind = sys; | 1797 | p->sys_ind = sys; |
1767 | 1798 | ||
1768 | printf("Changed system type of partition %d " | 1799 | printf("Changed system type of partition %u " |
1769 | "to %x (%s)\n", i + 1, sys, | 1800 | "to %x (%s)\n", i + 1, sys, |
1770 | partition_type(sys)); | 1801 | partition_type(sys)); |
1771 | ptes[i].changed = 1; | 1802 | ptes[i].changed = 1; |
@@ -1823,23 +1854,23 @@ check_consistency(const struct partition *p, int partition) | |||
1823 | 1854 | ||
1824 | /* Same physical / logical beginning? */ | 1855 | /* Same physical / logical beginning? */ |
1825 | if (g_cylinders <= 1024 && (pbc != lbc || pbh != lbh || pbs != lbs)) { | 1856 | if (g_cylinders <= 1024 && (pbc != lbc || pbh != lbh || pbs != lbs)) { |
1826 | printf("Partition %d has different physical/logical " | 1857 | printf("Partition %u has different physical/logical " |
1827 | "beginnings (non-Linux?):\n", partition + 1); | 1858 | "beginnings (non-Linux?):\n", partition + 1); |
1828 | printf(" phys=(%d, %d, %d) ", pbc, pbh, pbs); | 1859 | printf(" phys=(%u, %u, %u) ", pbc, pbh, pbs); |
1829 | printf("logical=(%d, %d, %d)\n", lbc, lbh, lbs); | 1860 | printf("logical=(%u, %u, %u)\n", lbc, lbh, lbs); |
1830 | } | 1861 | } |
1831 | 1862 | ||
1832 | /* Same physical / logical ending? */ | 1863 | /* Same physical / logical ending? */ |
1833 | if (g_cylinders <= 1024 && (pec != lec || peh != leh || pes != les)) { | 1864 | if (g_cylinders <= 1024 && (pec != lec || peh != leh || pes != les)) { |
1834 | printf("Partition %d has different physical/logical " | 1865 | printf("Partition %u has different physical/logical " |
1835 | "endings:\n", partition + 1); | 1866 | "endings:\n", partition + 1); |
1836 | printf(" phys=(%d, %d, %d) ", pec, peh, pes); | 1867 | printf(" phys=(%u, %u, %u) ", pec, peh, pes); |
1837 | printf("logical=(%d, %d, %d)\n", lec, leh, les); | 1868 | printf("logical=(%u, %u, %u)\n", lec, leh, les); |
1838 | } | 1869 | } |
1839 | 1870 | ||
1840 | /* Ending on cylinder boundary? */ | 1871 | /* Ending on cylinder boundary? */ |
1841 | if (peh != (g_heads - 1) || pes != g_sectors) { | 1872 | if (peh != (g_heads - 1) || pes != g_sectors) { |
1842 | printf("Partition %i does not end on cylinder boundary\n", | 1873 | printf("Partition %u does not end on cylinder boundary\n", |
1843 | partition + 1); | 1874 | partition + 1); |
1844 | } | 1875 | } |
1845 | } | 1876 | } |
@@ -1847,23 +1878,23 @@ check_consistency(const struct partition *p, int partition) | |||
1847 | static void | 1878 | static void |
1848 | list_disk_geometry(void) | 1879 | list_disk_geometry(void) |
1849 | { | 1880 | { |
1850 | long long bytes = (total_number_of_sectors << 9); | 1881 | ullong bytes = ((ullong)total_number_of_sectors << 9); |
1851 | long megabytes = bytes/1000000; | 1882 | long megabytes = bytes / 1000000; |
1852 | 1883 | ||
1853 | if (megabytes < 10000) | 1884 | if (megabytes < 10000) |
1854 | printf("\nDisk %s: %ld MB, %lld bytes\n", | 1885 | printf("\nDisk %s: %lu MB, %llu bytes\n", |
1855 | disk_device, megabytes, bytes); | 1886 | disk_device, megabytes, bytes); |
1856 | else | 1887 | else |
1857 | printf("\nDisk %s: %ld.%ld GB, %lld bytes\n", | 1888 | printf("\nDisk %s: %lu.%lu GB, %llu bytes\n", |
1858 | disk_device, megabytes/1000, (megabytes/100)%10, bytes); | 1889 | disk_device, megabytes/1000, (megabytes/100)%10, bytes); |
1859 | printf("%d heads, %d sectors/track, %d cylinders", | 1890 | printf("%u heads, %u sectors/track, %u cylinders", |
1860 | g_heads, g_sectors, g_cylinders); | 1891 | g_heads, g_sectors, g_cylinders); |
1861 | if (units_per_sector == 1) | 1892 | if (units_per_sector == 1) |
1862 | printf(", total %llu sectors", | 1893 | printf(", total %"SECT_FMT"u sectors", |
1863 | total_number_of_sectors / (sector_size/512)); | 1894 | total_number_of_sectors / (sector_size/512)); |
1864 | printf("\nUnits = %s of %d * %d = %d bytes\n\n", | 1895 | printf("\nUnits = %s of %u * %u = %u bytes\n\n", |
1865 | str_units(PLURAL), | 1896 | str_units(PLURAL), |
1866 | units_per_sector, sector_size, units_per_sector * sector_size); | 1897 | units_per_sector, sector_size, units_per_sector * sector_size); |
1867 | } | 1898 | } |
1868 | 1899 | ||
1869 | /* | 1900 | /* |
@@ -1876,8 +1907,8 @@ wrong_p_order(int *prev) | |||
1876 | { | 1907 | { |
1877 | const struct pte *pe; | 1908 | const struct pte *pe; |
1878 | const struct partition *p; | 1909 | const struct partition *p; |
1879 | ullong last_p_start_pos = 0, p_start_pos; | 1910 | sector_t last_p_start_pos = 0, p_start_pos; |
1880 | int i, last_i = 0; | 1911 | unsigned i, last_i = 0; |
1881 | 1912 | ||
1882 | for (i = 0; i < g_partitions; i++) { | 1913 | for (i = 0; i < g_partitions; i++) { |
1883 | if (i == 4) { | 1914 | if (i == 4) { |
@@ -2045,8 +2076,8 @@ list_table(int xtra) | |||
2045 | 2076 | ||
2046 | for (i = 0; i < g_partitions; i++) { | 2077 | for (i = 0; i < g_partitions; i++) { |
2047 | const struct pte *pe = &ptes[i]; | 2078 | const struct pte *pe = &ptes[i]; |
2048 | ullong psects; | 2079 | sector_t psects; |
2049 | ullong pblocks; | 2080 | sector_t pblocks; |
2050 | unsigned podd; | 2081 | unsigned podd; |
2051 | 2082 | ||
2052 | p = pe->part_table; | 2083 | p = pe->part_table; |
@@ -2064,14 +2095,14 @@ list_table(int xtra) | |||
2064 | if (sector_size > 1024) | 2095 | if (sector_size > 1024) |
2065 | pblocks *= (sector_size / 1024); | 2096 | pblocks *= (sector_size / 1024); |
2066 | 2097 | ||
2067 | printf("%s %c %11llu %11llu %11llu%c %2x %s\n", | 2098 | printf("%s %c %11"SECT_FMT"u %11"SECT_FMT"u %11"SECT_FMT"u%c %2x %s\n", |
2068 | partname(disk_device, i+1, w+2), | 2099 | partname(disk_device, i+1, w+2), |
2069 | !p->boot_ind ? ' ' : p->boot_ind == ACTIVE_FLAG /* boot flag */ | 2100 | !p->boot_ind ? ' ' : p->boot_ind == ACTIVE_FLAG /* boot flag */ |
2070 | ? '*' : '?', | 2101 | ? '*' : '?', |
2071 | (ullong) cround(get_partition_start(pe)), /* start */ | 2102 | cround(get_partition_start(pe)), /* start */ |
2072 | (ullong) cround(get_partition_start(pe) + psects /* end */ | 2103 | cround(get_partition_start(pe) + psects /* end */ |
2073 | - (psects ? 1 : 0)), | 2104 | - (psects ? 1 : 0)), |
2074 | (ullong) pblocks, podd ? '+' : ' ', /* odd flag on end */ | 2105 | pblocks, podd ? '+' : ' ', /* odd flag on end */ |
2075 | p->sys_ind, /* type id */ | 2106 | p->sys_ind, /* type id */ |
2076 | partition_type(p->sys_ind)); /* type name */ | 2107 | partition_type(p->sys_ind)); /* type name */ |
2077 | 2108 | ||
@@ -2079,8 +2110,8 @@ list_table(int xtra) | |||
2079 | } | 2110 | } |
2080 | 2111 | ||
2081 | /* Is partition table in disk order? It need not be, but... */ | 2112 | /* Is partition table in disk order? It need not be, but... */ |
2082 | /* partition table entries are not checked for correct order if this | 2113 | /* partition table entries are not checked for correct order |
2083 | is a sgi, sun or aix labeled disk... */ | 2114 | * if this is a sgi, sun or aix labeled disk... */ |
2084 | if (LABEL_IS_DOS && wrong_p_order(NULL)) { | 2115 | if (LABEL_IS_DOS && wrong_p_order(NULL)) { |
2085 | /* FIXME */ | 2116 | /* FIXME */ |
2086 | printf("\nPartition table entries are not in disk order\n"); | 2117 | printf("\nPartition table entries are not in disk order\n"); |
@@ -2095,20 +2126,21 @@ x_list_table(int extend) | |||
2095 | const struct partition *p; | 2126 | const struct partition *p; |
2096 | int i; | 2127 | int i; |
2097 | 2128 | ||
2098 | printf("\nDisk %s: %d heads, %d sectors, %d cylinders\n\n", | 2129 | printf("\nDisk %s: %u heads, %u sectors, %u cylinders\n\n", |
2099 | disk_device, g_heads, g_sectors, g_cylinders); | 2130 | disk_device, g_heads, g_sectors, g_cylinders); |
2100 | printf("Nr AF Hd Sec Cyl Hd Sec Cyl Start Size ID\n"); | 2131 | printf("Nr AF Hd Sec Cyl Hd Sec Cyl Start Size ID\n"); |
2101 | for (i = 0; i < g_partitions; i++) { | 2132 | for (i = 0; i < g_partitions; i++) { |
2102 | pe = &ptes[i]; | 2133 | pe = &ptes[i]; |
2103 | p = (extend ? pe->ext_pointer : pe->part_table); | 2134 | p = (extend ? pe->ext_pointer : pe->part_table); |
2104 | if (p != NULL) { | 2135 | if (p != NULL) { |
2105 | printf("%2d %02x%4d%4d%5d%4d%4d%5d%11u%11u %02x\n", | 2136 | printf("%2u %02x%4u%4u%5u%4u%4u%5u%11"SECT_FMT"u%11"SECT_FMT"u %02x\n", |
2106 | i + 1, p->boot_ind, p->head, | 2137 | i + 1, p->boot_ind, p->head, |
2107 | sector(p->sector), | 2138 | sector(p->sector), |
2108 | cylinder(p->sector, p->cyl), p->end_head, | 2139 | cylinder(p->sector, p->cyl), p->end_head, |
2109 | sector(p->end_sector), | 2140 | sector(p->end_sector), |
2110 | cylinder(p->end_sector, p->end_cyl), | 2141 | cylinder(p->end_sector, p->end_cyl), |
2111 | get_start_sect(p), get_nr_sects(p), p->sys_ind); | 2142 | get_start_sect(p), get_nr_sects(p), |
2143 | p->sys_ind); | ||
2112 | if (p->sys_ind) | 2144 | if (p->sys_ind) |
2113 | check_consistency(p, i); | 2145 | check_consistency(p, i); |
2114 | } | 2146 | } |
@@ -2118,9 +2150,9 @@ x_list_table(int extend) | |||
2118 | 2150 | ||
2119 | #if ENABLE_FEATURE_FDISK_WRITABLE | 2151 | #if ENABLE_FEATURE_FDISK_WRITABLE |
2120 | static void | 2152 | static void |
2121 | fill_bounds(ullong *first, ullong *last) | 2153 | fill_bounds(sector_t *first, sector_t *last) |
2122 | { | 2154 | { |
2123 | int i; | 2155 | unsigned i; |
2124 | const struct pte *pe = &ptes[0]; | 2156 | const struct pte *pe = &ptes[0]; |
2125 | const struct partition *p; | 2157 | const struct partition *p; |
2126 | 2158 | ||
@@ -2137,35 +2169,35 @@ fill_bounds(ullong *first, ullong *last) | |||
2137 | } | 2169 | } |
2138 | 2170 | ||
2139 | static void | 2171 | static void |
2140 | check(int n, unsigned h, unsigned s, unsigned c, ullong start) | 2172 | check(int n, unsigned h, unsigned s, unsigned c, sector_t start) |
2141 | { | 2173 | { |
2142 | ullong total, real_s, real_c; | 2174 | sector_t total, real_s, real_c; |
2143 | 2175 | ||
2144 | real_s = sector(s) - 1; | 2176 | real_s = sector(s) - 1; |
2145 | real_c = cylinder(s, c); | 2177 | real_c = cylinder(s, c); |
2146 | total = (real_c * g_sectors + real_s) * g_heads + h; | 2178 | total = (real_c * g_sectors + real_s) * g_heads + h; |
2147 | if (!total) | 2179 | if (!total) |
2148 | printf("Partition %d contains sector 0\n", n); | 2180 | printf("Partition %u contains sector 0\n", n); |
2149 | if (h >= g_heads) | 2181 | if (h >= g_heads) |
2150 | printf("Partition %d: head %d greater than maximum %d\n", | 2182 | printf("Partition %u: head %u greater than maximum %u\n", |
2151 | n, h + 1, g_heads); | 2183 | n, h + 1, g_heads); |
2152 | if (real_s >= g_sectors) | 2184 | if (real_s >= g_sectors) |
2153 | printf("Partition %d: sector %d greater than " | 2185 | printf("Partition %u: sector %u greater than " |
2154 | "maximum %d\n", n, s, g_sectors); | 2186 | "maximum %u\n", n, s, g_sectors); |
2155 | if (real_c >= g_cylinders) | 2187 | if (real_c >= g_cylinders) |
2156 | printf("Partition %d: cylinder %llu greater than " | 2188 | printf("Partition %u: cylinder %"SECT_FMT"u greater than " |
2157 | "maximum %d\n", n, real_c + 1, g_cylinders); | 2189 | "maximum %u\n", n, real_c + 1, g_cylinders); |
2158 | if (g_cylinders <= 1024 && start != total) | 2190 | if (g_cylinders <= 1024 && start != total) |
2159 | printf("Partition %d: previous sectors %llu disagrees with " | 2191 | printf("Partition %u: previous sectors %"SECT_FMT"u disagrees with " |
2160 | "total %llu\n", n, start, total); | 2192 | "total %"SECT_FMT"u\n", n, start, total); |
2161 | } | 2193 | } |
2162 | 2194 | ||
2163 | static void | 2195 | static void |
2164 | verify(void) | 2196 | verify(void) |
2165 | { | 2197 | { |
2166 | int i, j; | 2198 | int i, j; |
2167 | unsigned total = 1; | 2199 | sector_t total = 1; |
2168 | ullong first[g_partitions], last[g_partitions]; | 2200 | sector_t first[g_partitions], last[g_partitions]; |
2169 | struct partition *p; | 2201 | struct partition *p; |
2170 | 2202 | ||
2171 | if (warn_geometry()) | 2203 | if (warn_geometry()) |
@@ -2189,15 +2221,15 @@ verify(void) | |||
2189 | check_consistency(p, i); | 2221 | check_consistency(p, i); |
2190 | if (get_partition_start(pe) < first[i]) | 2222 | if (get_partition_start(pe) < first[i]) |
2191 | printf("Warning: bad start-of-data in " | 2223 | printf("Warning: bad start-of-data in " |
2192 | "partition %d\n", i + 1); | 2224 | "partition %u\n", i + 1); |
2193 | check(i + 1, p->end_head, p->end_sector, p->end_cyl, | 2225 | check(i + 1, p->end_head, p->end_sector, p->end_cyl, |
2194 | last[i]); | 2226 | last[i]); |
2195 | total += last[i] + 1 - first[i]; | 2227 | total += last[i] + 1 - first[i]; |
2196 | for (j = 0; j < i; j++) { | 2228 | for (j = 0; j < i; j++) { |
2197 | if ((first[i] >= first[j] && first[i] <= last[j]) | 2229 | if ((first[i] >= first[j] && first[i] <= last[j]) |
2198 | || ((last[i] <= last[j] && last[i] >= first[j]))) { | 2230 | || ((last[i] <= last[j] && last[i] >= first[j]))) { |
2199 | printf("Warning: partition %d overlaps " | 2231 | printf("Warning: partition %u overlaps " |
2200 | "partition %d\n", j + 1, i + 1); | 2232 | "partition %u\n", j + 1, i + 1); |
2201 | total += first[i] >= first[j] ? | 2233 | total += first[i] >= first[j] ? |
2202 | first[i] : first[j]; | 2234 | first[i] : first[j]; |
2203 | total -= last[i] <= last[j] ? | 2235 | total -= last[i] <= last[j] ? |
@@ -2209,7 +2241,7 @@ verify(void) | |||
2209 | 2241 | ||
2210 | if (extended_offset) { | 2242 | if (extended_offset) { |
2211 | struct pte *pex = &ptes[ext_index]; | 2243 | struct pte *pex = &ptes[ext_index]; |
2212 | ullong e_last = get_start_sect(pex->part_table) + | 2244 | sector_t e_last = get_start_sect(pex->part_table) + |
2213 | get_nr_sects(pex->part_table) - 1; | 2245 | get_nr_sects(pex->part_table) - 1; |
2214 | 2246 | ||
2215 | for (i = 4; i < g_partitions; i++) { | 2247 | for (i = 4; i < g_partitions; i++) { |
@@ -2217,22 +2249,22 @@ verify(void) | |||
2217 | p = ptes[i].part_table; | 2249 | p = ptes[i].part_table; |
2218 | if (!p->sys_ind) { | 2250 | if (!p->sys_ind) { |
2219 | if (i != 4 || i + 1 < g_partitions) | 2251 | if (i != 4 || i + 1 < g_partitions) |
2220 | printf("Warning: partition %d " | 2252 | printf("Warning: partition %u " |
2221 | "is empty\n", i + 1); | 2253 | "is empty\n", i + 1); |
2222 | } else if (first[i] < extended_offset || last[i] > e_last) { | 2254 | } else if (first[i] < extended_offset || last[i] > e_last) { |
2223 | printf("Logical partition %d not entirely in " | 2255 | printf("Logical partition %u not entirely in " |
2224 | "partition %d\n", i + 1, ext_index + 1); | 2256 | "partition %u\n", i + 1, ext_index + 1); |
2225 | } | 2257 | } |
2226 | } | 2258 | } |
2227 | } | 2259 | } |
2228 | 2260 | ||
2229 | if (total > g_heads * g_sectors * g_cylinders) | 2261 | if (total > g_heads * g_sectors * g_cylinders) |
2230 | printf("Total allocated sectors %d greater than the maximum " | 2262 | printf("Total allocated sectors %u greater than the maximum " |
2231 | "%d\n", total, g_heads * g_sectors * g_cylinders); | 2263 | "%u\n", total, g_heads * g_sectors * g_cylinders); |
2232 | else { | 2264 | else { |
2233 | total = g_heads * g_sectors * g_cylinders - total; | 2265 | total = g_heads * g_sectors * g_cylinders - total; |
2234 | if (total != 0) | 2266 | if (total != 0) |
2235 | printf("%d unallocated sectors\n", total); | 2267 | printf("%"SECT_FMT"u unallocated sectors\n", total); |
2236 | } | 2268 | } |
2237 | } | 2269 | } |
2238 | 2270 | ||
@@ -2243,9 +2275,9 @@ add_partition(int n, int sys) | |||
2243 | int i, num_read = 0; | 2275 | int i, num_read = 0; |
2244 | struct partition *p = ptes[n].part_table; | 2276 | struct partition *p = ptes[n].part_table; |
2245 | struct partition *q = ptes[ext_index].part_table; | 2277 | struct partition *q = ptes[ext_index].part_table; |
2246 | ullong limit, temp; | 2278 | sector_t limit, temp; |
2247 | ullong start, stop = 0; | 2279 | sector_t start, stop = 0; |
2248 | ullong first[g_partitions], last[g_partitions]; | 2280 | sector_t first[g_partitions], last[g_partitions]; |
2249 | 2281 | ||
2250 | if (p && p->sys_ind) { | 2282 | if (p && p->sys_ind) { |
2251 | printf(msg_part_already_defined, n + 1); | 2283 | printf(msg_part_already_defined, n + 1); |
@@ -2255,7 +2287,7 @@ add_partition(int n, int sys) | |||
2255 | if (n < 4) { | 2287 | if (n < 4) { |
2256 | start = sector_offset; | 2288 | start = sector_offset; |
2257 | if (display_in_cyl_units || !total_number_of_sectors) | 2289 | if (display_in_cyl_units || !total_number_of_sectors) |
2258 | limit = (ullong) g_heads * g_sectors * g_cylinders - 1; | 2290 | limit = (sector_t) g_heads * g_sectors * g_cylinders - 1; |
2259 | else | 2291 | else |
2260 | limit = total_number_of_sectors - 1; | 2292 | limit = total_number_of_sectors - 1; |
2261 | if (extended_offset) { | 2293 | if (extended_offset) { |
@@ -2286,19 +2318,20 @@ add_partition(int n, int sys) | |||
2286 | if (start > limit) | 2318 | if (start > limit) |
2287 | break; | 2319 | break; |
2288 | if (start >= temp+units_per_sector && num_read) { | 2320 | if (start >= temp+units_per_sector && num_read) { |
2289 | printf("Sector %lld is already allocated\n", temp); | 2321 | printf("Sector %"SECT_FMT"u is already allocated\n", temp); |
2290 | temp = start; | 2322 | temp = start; |
2291 | num_read = 0; | 2323 | num_read = 0; |
2292 | } | 2324 | } |
2293 | if (!num_read && start == temp) { | 2325 | if (!num_read && start == temp) { |
2294 | ullong saved_start; | 2326 | sector_t saved_start; |
2295 | 2327 | ||
2296 | saved_start = start; | 2328 | saved_start = start; |
2297 | start = read_int(cround(saved_start), cround(saved_start), cround(limit), | 2329 | start = read_int(cround(saved_start), cround(saved_start), cround(limit), |
2298 | 0, mesg); | 2330 | 0, mesg); |
2299 | if (display_in_cyl_units) { | 2331 | if (display_in_cyl_units) { |
2300 | start = (start - 1) * units_per_sector; | 2332 | start = (start - 1) * units_per_sector; |
2301 | if (start < saved_start) start = saved_start; | 2333 | if (start < saved_start) |
2334 | start = saved_start; | ||
2302 | } | 2335 | } |
2303 | num_read = 1; | 2336 | num_read = 1; |
2304 | } | 2337 | } |
@@ -2546,16 +2579,16 @@ print_raw(void) | |||
2546 | } | 2579 | } |
2547 | 2580 | ||
2548 | static void | 2581 | static void |
2549 | move_begin(int i) | 2582 | move_begin(unsigned i) |
2550 | { | 2583 | { |
2551 | struct pte *pe = &ptes[i]; | 2584 | struct pte *pe = &ptes[i]; |
2552 | struct partition *p = pe->part_table; | 2585 | struct partition *p = pe->part_table; |
2553 | ullong new, first; | 2586 | sector_t new, first; |
2554 | 2587 | ||
2555 | if (warn_geometry()) | 2588 | if (warn_geometry()) |
2556 | return; | 2589 | return; |
2557 | if (!p->sys_ind || !get_nr_sects(p) || IS_EXTENDED(p->sys_ind)) { | 2590 | if (!p->sys_ind || !get_nr_sects(p) || IS_EXTENDED(p->sys_ind)) { |
2558 | printf("Partition %d has no data area\n", i + 1); | 2591 | printf("Partition %u has no data area\n", i + 1); |
2559 | return; | 2592 | return; |
2560 | } | 2593 | } |
2561 | first = get_partition_start(pe); | 2594 | first = get_partition_start(pe); |
@@ -2761,7 +2794,7 @@ list_devs_in_proc_partititons(void) | |||
2761 | procpt = fopen_or_warn("/proc/partitions", "r"); | 2794 | procpt = fopen_or_warn("/proc/partitions", "r"); |
2762 | 2795 | ||
2763 | while (fgets(line, sizeof(line), procpt)) { | 2796 | while (fgets(line, sizeof(line), procpt)) { |
2764 | if (sscanf(line, " %d %d %d %[^\n ]", | 2797 | if (sscanf(line, " %u %u %u %[^\n ]", |
2765 | &ma, &mi, &sz, ptname) != 4) | 2798 | &ma, &mi, &sz, ptname) != 4) |
2766 | continue; | 2799 | continue; |
2767 | for (s = ptname; *s; s++) | 2800 | for (s = ptname; *s; s++) |
@@ -2855,9 +2888,9 @@ int fdisk_main(int argc, char **argv) | |||
2855 | size = bb_BLKGETSIZE_sectors(fd) / 2; | 2888 | size = bb_BLKGETSIZE_sectors(fd) / 2; |
2856 | close(fd); | 2889 | close(fd); |
2857 | if (argc == 1) | 2890 | if (argc == 1) |
2858 | printf("%lld\n", size); | 2891 | printf("%llu\n", size); |
2859 | else | 2892 | else |
2860 | printf("%s: %lld\n", argv[j], size); | 2893 | printf("%s: %llu\n", argv[j], size); |
2861 | } | 2894 | } |
2862 | return 0; | 2895 | return 0; |
2863 | } | 2896 | } |
diff --git a/util-linux/fdisk_aix.c b/util-linux/fdisk_aix.c index 2c0d2a6ac..2a0ab1744 100644 --- a/util-linux/fdisk_aix.c +++ b/util-linux/fdisk_aix.c | |||
@@ -54,8 +54,9 @@ aix_info(void) | |||
54 | static int | 54 | static int |
55 | check_aix_label(void) | 55 | check_aix_label(void) |
56 | { | 56 | { |
57 | if (aixlabel->magic != AIX_LABEL_MAGIC && | 57 | if (aixlabel->magic != AIX_LABEL_MAGIC |
58 | aixlabel->magic != AIX_LABEL_MAGIC_SWAPPED) { | 58 | && aixlabel->magic != AIX_LABEL_MAGIC_SWAPPED |
59 | ) { | ||
59 | current_label_type = 0; | 60 | current_label_type = 0; |
60 | aix_other_endian = 0; | 61 | aix_other_endian = 0; |
61 | return 0; | 62 | return 0; |
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) | |||
637 | static int | 637 | static int |
638 | edit_int(int def, const char *mesg) | 638 | edit_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 | } |
diff --git a/util-linux/fdisk_sgi.c b/util-linux/fdisk_sgi.c index 51cf30c98..0e3cff50c 100644 --- a/util-linux/fdisk_sgi.c +++ b/util-linux/fdisk_sgi.c | |||
@@ -36,7 +36,7 @@ struct device_parameter { /* 48 bytes */ | |||
36 | unsigned short nsect; /* sectors/tracks in cyl 0 or vol 0 */ | 36 | unsigned short nsect; /* sectors/tracks in cyl 0 or vol 0 */ |
37 | unsigned short bytes; | 37 | unsigned short bytes; |
38 | unsigned short ilfact; | 38 | unsigned short ilfact; |
39 | unsigned int flags; /* controller flags */ | 39 | unsigned int flags; /* controller flags */ |
40 | unsigned int datarate; | 40 | unsigned int datarate; |
41 | unsigned int retries_on_error; | 41 | unsigned int retries_on_error; |
42 | unsigned int ms_per_word; | 42 | unsigned int ms_per_word; |
@@ -70,7 +70,7 @@ typedef struct { | |||
70 | unsigned int vol_file_start; /* number of logical block */ | 70 | unsigned int vol_file_start; /* number of logical block */ |
71 | unsigned int vol_file_size; /* number of bytes */ | 71 | unsigned int vol_file_size; /* number of bytes */ |
72 | } directory[15]; | 72 | } directory[15]; |
73 | struct sgi_partinfo { /* 16 * 12 bytes */ | 73 | struct sgi_partinfo { /* 16 * 12 bytes */ |
74 | unsigned int num_sectors; /* number of blocks */ | 74 | unsigned int num_sectors; /* number of blocks */ |
75 | unsigned int start_sector; /* must be cylinder aligned */ | 75 | unsigned int start_sector; /* must be cylinder aligned */ |
76 | unsigned int id; | 76 | unsigned int id; |
@@ -291,11 +291,11 @@ sgi_list_table(int xtra) | |||
291 | int kpi = 0; /* kernel partition ID */ | 291 | int kpi = 0; /* kernel partition ID */ |
292 | 292 | ||
293 | if (xtra) { | 293 | if (xtra) { |
294 | printf("\nDisk %s (SGI disk label): %d heads, %d sectors\n" | 294 | printf("\nDisk %s (SGI disk label): %u heads, %u sectors\n" |
295 | "%d cylinders, %d physical cylinders\n" | 295 | "%u cylinders, %u physical cylinders\n" |
296 | "%d extra sects/cyl, interleave %d:1\n" | 296 | "%u extra sects/cyl, interleave %u:1\n" |
297 | "%s\n" | 297 | "%s\n" |
298 | "Units = %s of %d * 512 bytes\n\n", | 298 | "Units = %s of %u * 512 bytes\n\n", |
299 | disk_device, g_heads, g_sectors, g_cylinders, | 299 | disk_device, g_heads, g_sectors, g_cylinders, |
300 | SGI_SSWAP16(sgiparam.pcylcount), | 300 | SGI_SSWAP16(sgiparam.pcylcount), |
301 | SGI_SSWAP16(sgiparam.sparecyl), | 301 | SGI_SSWAP16(sgiparam.sparecyl), |
@@ -304,8 +304,8 @@ sgi_list_table(int xtra) | |||
304 | str_units(PLURAL), units_per_sector); | 304 | str_units(PLURAL), units_per_sector); |
305 | } else { | 305 | } else { |
306 | printf("\nDisk %s (SGI disk label): " | 306 | printf("\nDisk %s (SGI disk label): " |
307 | "%d heads, %d sectors, %d cylinders\n" | 307 | "%u heads, %u sectors, %u cylinders\n" |
308 | "Units = %s of %d * 512 bytes\n\n", | 308 | "Units = %s of %u * 512 bytes\n\n", |
309 | disk_device, g_heads, g_sectors, g_cylinders, | 309 | disk_device, g_heads, g_sectors, g_cylinders, |
310 | str_units(PLURAL), units_per_sector ); | 310 | str_units(PLURAL), units_per_sector ); |
311 | } | 311 | } |
@@ -324,7 +324,7 @@ sgi_list_table(int xtra) | |||
324 | uint32_t len = sgi_get_num_sectors(i); | 324 | uint32_t len = sgi_get_num_sectors(i); |
325 | kpi++; /* only count nonempty partitions */ | 325 | kpi++; /* only count nonempty partitions */ |
326 | printf( | 326 | printf( |
327 | "%2d: %s %4s %9ld %9ld %9ld %2x %s\n", | 327 | "%2u: %s %4s %9lu %9lu %9lu %2x %s\n", |
328 | /* fdisk part number */ i+1, | 328 | /* fdisk part number */ i+1, |
329 | /* device */ partname(disk_device, kpi, w+3), | 329 | /* device */ partname(disk_device, kpi, w+3), |
330 | /* flags */ (sgi_get_swappartition() == i) ? "swap" : | 330 | /* flags */ (sgi_get_swappartition() == i) ? "swap" : |
@@ -345,7 +345,7 @@ sgi_list_table(int xtra) | |||
345 | uint32_t len = SGI_SSWAP32(sgilabel->directory[i].vol_file_size); | 345 | uint32_t len = SGI_SSWAP32(sgilabel->directory[i].vol_file_size); |
346 | unsigned char *name = sgilabel->directory[i].vol_file_name; | 346 | unsigned char *name = sgilabel->directory[i].vol_file_name; |
347 | 347 | ||
348 | printf("%2d: %-10s sector%5u size%8u\n", | 348 | printf("%2u: %-10s sector%5u size%8u\n", |
349 | i, (char*)name, (unsigned int) start, (unsigned int) len); | 349 | i, (char*)name, (unsigned int) start, (unsigned int) len); |
350 | } | 350 | } |
351 | } | 351 | } |
@@ -507,19 +507,19 @@ verify_sgi(int verbose) | |||
507 | if ((sgi_get_start_sector(Index[0]) != 0) && verbose) | 507 | if ((sgi_get_start_sector(Index[0]) != 0) && verbose) |
508 | printf("The entire disk partition should start " | 508 | printf("The entire disk partition should start " |
509 | "at block 0,\n" | 509 | "at block 0,\n" |
510 | "not at diskblock %d\n", | 510 | "not at diskblock %u\n", |
511 | sgi_get_start_sector(Index[0])); | 511 | sgi_get_start_sector(Index[0])); |
512 | if (SGI_DEBUG) /* I do not understand how some disks fulfil it */ | 512 | if (SGI_DEBUG) /* I do not understand how some disks fulfil it */ |
513 | if ((sgi_get_num_sectors(Index[0]) != lastblock) && verbose) | 513 | if ((sgi_get_num_sectors(Index[0]) != lastblock) && verbose) |
514 | printf("The entire disk partition is only %d diskblock large,\n" | 514 | printf("The entire disk partition is only %u diskblock large,\n" |
515 | "but the disk is %d diskblocks long\n", | 515 | "but the disk is %u diskblocks long\n", |
516 | sgi_get_num_sectors(Index[0]), lastblock); | 516 | sgi_get_num_sectors(Index[0]), lastblock); |
517 | lastblock = sgi_get_num_sectors(Index[0]); | 517 | lastblock = sgi_get_num_sectors(Index[0]); |
518 | } else { | 518 | } else { |
519 | if (verbose) | 519 | if (verbose) |
520 | printf("One Partition (#11) should cover the entire disk\n"); | 520 | printf("One Partition (#11) should cover the entire disk\n"); |
521 | if (SGI_DEBUG > 2) | 521 | if (SGI_DEBUG > 2) |
522 | printf("sysid=%d\tpartition=%d\n", | 522 | printf("sysid=%u\tpartition=%u\n", |
523 | sgi_get_sysid(Index[0]), Index[0]+1); | 523 | sgi_get_sysid(Index[0]), Index[0]+1); |
524 | } | 524 | } |
525 | for (i = 1, start = 0; i < sortcount; i++) { | 525 | for (i = 1, start = 0; i < sortcount; i++) { |
@@ -528,20 +528,20 @@ verify_sgi(int verbose) | |||
528 | if ((sgi_get_start_sector(Index[i]) % cylsize) != 0) { | 528 | if ((sgi_get_start_sector(Index[i]) % cylsize) != 0) { |
529 | if (SGI_DEBUG) /* I do not understand how some disks fulfil it */ | 529 | if (SGI_DEBUG) /* I do not understand how some disks fulfil it */ |
530 | if (verbose) | 530 | if (verbose) |
531 | printf("Partition %d does not start on cylinder boundary\n", | 531 | printf("Partition %u does not start on cylinder boundary\n", |
532 | Index[i]+1); | 532 | Index[i]+1); |
533 | } | 533 | } |
534 | if (sgi_get_num_sectors(Index[i]) % cylsize != 0) { | 534 | if (sgi_get_num_sectors(Index[i]) % cylsize != 0) { |
535 | if (SGI_DEBUG) /* I do not understand how some disks fulfil it */ | 535 | if (SGI_DEBUG) /* I do not understand how some disks fulfil it */ |
536 | if (verbose) | 536 | if (verbose) |
537 | printf("Partition %d does not end on cylinder boundary\n", | 537 | printf("Partition %u does not end on cylinder boundary\n", |
538 | Index[i]+1); | 538 | Index[i]+1); |
539 | } | 539 | } |
540 | /* We cannot handle several "entire disk" entries. */ | 540 | /* We cannot handle several "entire disk" entries. */ |
541 | if (sgi_get_sysid(Index[i]) == SGI_ENTIRE_DISK) continue; | 541 | if (sgi_get_sysid(Index[i]) == SGI_ENTIRE_DISK) continue; |
542 | if (start > sgi_get_start_sector(Index[i])) { | 542 | if (start > sgi_get_start_sector(Index[i])) { |
543 | if (verbose) | 543 | if (verbose) |
544 | printf("Partitions %d and %d overlap by %d sectors\n", | 544 | printf("Partitions %u and %u overlap by %u sectors\n", |
545 | Index[i-1]+1, Index[i]+1, | 545 | Index[i-1]+1, Index[i]+1, |
546 | start - sgi_get_start_sector(Index[i])); | 546 | start - sgi_get_start_sector(Index[i])); |
547 | if (gap > 0) gap = -gap; | 547 | if (gap > 0) gap = -gap; |
@@ -549,7 +549,7 @@ verify_sgi(int verbose) | |||
549 | } | 549 | } |
550 | if (start < sgi_get_start_sector(Index[i])) { | 550 | if (start < sgi_get_start_sector(Index[i])) { |
551 | if (verbose) | 551 | if (verbose) |
552 | printf("Unused gap of %8u sectors - sectors %8u-%8u\n", | 552 | printf("Unused gap of %u sectors - sectors %u-%u\n", |
553 | sgi_get_start_sector(Index[i]) - start, | 553 | sgi_get_start_sector(Index[i]) - start, |
554 | start, sgi_get_start_sector(Index[i])-1); | 554 | start, sgi_get_start_sector(Index[i])-1); |
555 | gap += sgi_get_start_sector(Index[i]) - start; | 555 | gap += sgi_get_start_sector(Index[i]) - start; |
@@ -559,7 +559,7 @@ verify_sgi(int verbose) | |||
559 | + sgi_get_num_sectors(Index[i]); | 559 | + sgi_get_num_sectors(Index[i]); |
560 | if (SGI_DEBUG > 1) { | 560 | if (SGI_DEBUG > 1) { |
561 | if (verbose) | 561 | if (verbose) |
562 | printf("%2d:%12d\t%12d\t%12d\n", Index[i], | 562 | printf("%2u:%12u\t%12u\t%12u\n", Index[i], |
563 | sgi_get_start_sector(Index[i]), | 563 | sgi_get_start_sector(Index[i]), |
564 | sgi_get_num_sectors(Index[i]), | 564 | sgi_get_num_sectors(Index[i]), |
565 | sgi_get_sysid(Index[i])); | 565 | sgi_get_sysid(Index[i])); |
@@ -567,7 +567,7 @@ verify_sgi(int verbose) | |||
567 | } | 567 | } |
568 | if (start < lastblock) { | 568 | if (start < lastblock) { |
569 | if (verbose) | 569 | if (verbose) |
570 | printf("Unused gap of %8u sectors - sectors %8u-%8u\n", | 570 | printf("Unused gap of %u sectors - sectors %u-%u\n", |
571 | lastblock - start, start, lastblock-1); | 571 | lastblock - start, start, lastblock-1); |
572 | gap += lastblock - start; | 572 | gap += lastblock - start; |
573 | add2freelist(start, lastblock); | 573 | add2freelist(start, lastblock); |
@@ -788,7 +788,7 @@ create_sgilabel(void) | |||
788 | /* otherwise print error and use truncated version */ | 788 | /* otherwise print error and use truncated version */ |
789 | g_cylinders = geometry.cylinders; | 789 | g_cylinders = geometry.cylinders; |
790 | printf( | 790 | printf( |
791 | "Warning: BLKGETSIZE ioctl failed on %s. Using geometry cylinder value of %d.\n" | 791 | "Warning: BLKGETSIZE ioctl failed on %s. Using geometry cylinder value of %u.\n" |
792 | "This value may be truncated for devices > 33.8 GB.\n", disk_device, g_cylinders); | 792 | "This value may be truncated for devices > 33.8 GB.\n", disk_device, g_cylinders); |
793 | } | 793 | } |
794 | } | 794 | } |
@@ -799,9 +799,9 @@ create_sgilabel(void) | |||
799 | old[i].sysid = get_part_table(i)->sys_ind; | 799 | old[i].sysid = get_part_table(i)->sys_ind; |
800 | old[i].start = get_start_sect(get_part_table(i)); | 800 | old[i].start = get_start_sect(get_part_table(i)); |
801 | old[i].nsect = get_nr_sects(get_part_table(i)); | 801 | old[i].nsect = get_nr_sects(get_part_table(i)); |
802 | printf("Trying to keep parameters of partition %d\n", i); | 802 | printf("Trying to keep parameters of partition %u\n", i); |
803 | if (SGI_DEBUG) | 803 | if (SGI_DEBUG) |
804 | printf("ID=%02x\tSTART=%d\tLENGTH=%d\n", | 804 | printf("ID=%02x\tSTART=%u\tLENGTH=%u\n", |
805 | old[i].sysid, old[i].start, old[i].nsect); | 805 | old[i].sysid, old[i].start, old[i].nsect); |
806 | } | 806 | } |
807 | } | 807 | } |
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 @@ | |||
27 | 27 | ||
28 | #define SCSI_IOCTL_GET_IDLUN 0x5382 | 28 | #define SCSI_IOCTL_GET_IDLUN 0x5382 |
29 | 29 | ||
30 | static int sun_other_endian; | 30 | static smallint sun_other_endian; |
31 | static int scsi_disk; | 31 | static smallint scsi_disk; |
32 | static int floppy; | 32 | static smallint floppy; |
33 | 33 | ||
34 | #ifndef IDE0_MAJOR | 34 | #ifndef IDE0_MAJOR |
35 | #define IDE0_MAJOR 3 | 35 | #define IDE0_MAJOR 3 |
@@ -81,7 +81,7 @@ static const char *const sun_sys_types[] = { | |||
81 | 81 | ||
82 | 82 | ||
83 | static void | 83 | static void |
84 | set_sun_partition(int i, uint start, uint stop, int sysid) | 84 | set_sun_partition(int i, unsigned start, unsigned stop, int sysid) |
85 | { | 85 | { |
86 | sunlabel->infos[i].id = sysid; | 86 | sunlabel->infos[i].id = sysid; |
87 | sunlabel->partitions[i].start_cylinder = | 87 | sunlabel->partitions[i].start_cylinder = |
@@ -98,7 +98,8 @@ check_sun_label(void) | |||
98 | int csum; | 98 | int csum; |
99 | 99 | ||
100 | if (sunlabel->magic != SUN_LABEL_MAGIC | 100 | if (sunlabel->magic != SUN_LABEL_MAGIC |
101 | && sunlabel->magic != SUN_LABEL_MAGIC_SWAPPED) { | 101 | && sunlabel->magic != SUN_LABEL_MAGIC_SWAPPED |
102 | ) { | ||
102 | current_label_type = LABEL_DOS; | 103 | current_label_type = LABEL_DOS; |
103 | sun_other_endian = 0; | 104 | sun_other_endian = 0; |
104 | return 0; | 105 | return 0; |
@@ -173,7 +174,7 @@ sun_autoconfigure_scsi(void) | |||
173 | return NULL; | 174 | return NULL; |
174 | 175 | ||
175 | sprintf(buffer, | 176 | sprintf(buffer, |
176 | "Host: scsi%d Channel: %02d Id: %02d Lun: %02d\n", | 177 | "Host: scsi%u Channel: %02u Id: %02u Lun: %02u\n", |
177 | /* This is very wrong (works only if you have one HBA), | 178 | /* This is very wrong (works only if you have one HBA), |
178 | but I haven't found a way how to get hostno | 179 | but I haven't found a way how to get hostno |
179 | from the current kernel */ | 180 | from the current kernel */ |
@@ -317,7 +318,7 @@ create_sunlabel(void) | |||
317 | } | 318 | } |
318 | 319 | ||
319 | snprintf((char *)(sunlabel->info), sizeof(sunlabel->info), | 320 | snprintf((char *)(sunlabel->info), sizeof(sunlabel->info), |
320 | "%s%s%s cyl %d alt %d hd %d sec %d", | 321 | "%s%s%s cyl %u alt %u hd %u sec %u", |
321 | p ? p->vendor : "", (p && *p->vendor) ? " " : "", | 322 | p ? p->vendor : "", (p && *p->vendor) ? " " : "", |
322 | p ? p->model : (floppy ? "3,5\" floppy" : "Linux custom"), | 323 | p ? p->model : (floppy ? "3,5\" floppy" : "Linux custom"), |
323 | g_cylinders, SUN_SSWAP16(sunlabel->nacyl), g_heads, g_sectors); | 324 | g_cylinders, SUN_SSWAP16(sunlabel->nacyl), g_heads, g_sectors); |
@@ -361,7 +362,7 @@ toggle_sunflags(int i, unsigned char mask) | |||
361 | } | 362 | } |
362 | 363 | ||
363 | static void | 364 | static void |
364 | fetch_sun(uint *starts, uint *lens, uint *start, uint *stop) | 365 | fetch_sun(unsigned *starts, unsigned *lens, unsigned *start, unsigned *stop) |
365 | { | 366 | { |
366 | int i, continuous = 1; | 367 | int i, continuous = 1; |
367 | 368 | ||
@@ -390,7 +391,7 @@ fetch_sun(uint *starts, uint *lens, uint *start, uint *stop) | |||
390 | } | 391 | } |
391 | } | 392 | } |
392 | 393 | ||
393 | static uint *verify_sun_starts; | 394 | static unsigned *verify_sun_starts; |
394 | 395 | ||
395 | static int | 396 | static int |
396 | verify_sun_cmp(int *a, int *b) | 397 | verify_sun_cmp(int *a, int *b) |
@@ -404,7 +405,7 @@ verify_sun_cmp(int *a, int *b) | |||
404 | static void | 405 | static void |
405 | verify_sun(void) | 406 | verify_sun(void) |
406 | { | 407 | { |
407 | uint starts[8], lens[8], start, stop; | 408 | unsigned starts[8], lens[8], start, stop; |
408 | int i,j,k,starto,endo; | 409 | int i,j,k,starto,endo; |
409 | int array[8]; | 410 | int array[8]; |
410 | 411 | ||
@@ -413,7 +414,7 @@ verify_sun(void) | |||
413 | for (k = 0; k < 7; k++) { | 414 | for (k = 0; k < 7; k++) { |
414 | for (i = 0; i < 8; i++) { | 415 | for (i = 0; i < 8; i++) { |
415 | if (k && (lens[i] % (g_heads * g_sectors))) { | 416 | if (k && (lens[i] % (g_heads * g_sectors))) { |
416 | printf("Partition %d doesn't end on cylinder boundary\n", i+1); | 417 | printf("Partition %u doesn't end on cylinder boundary\n", i+1); |
417 | } | 418 | } |
418 | if (lens[i]) { | 419 | if (lens[i]) { |
419 | for (j = 0; j < i; j++) | 420 | for (j = 0; j < i; j++) |
@@ -433,8 +434,8 @@ verify_sun(void) | |||
433 | endo = starts[i]+lens[i]; | 434 | endo = starts[i]+lens[i]; |
434 | if (starts[j]+lens[j] < endo) | 435 | if (starts[j]+lens[j] < endo) |
435 | endo = starts[j]+lens[j]; | 436 | endo = starts[j]+lens[j]; |
436 | printf("Partition %d overlaps with others in " | 437 | printf("Partition %u overlaps with others in " |
437 | "sectors %d-%d\n", i+1, starto, endo); | 438 | "sectors %u-%u\n", i+1, starto, endo); |
438 | } | 439 | } |
439 | } | 440 | } |
440 | } | 441 | } |
@@ -455,20 +456,20 @@ verify_sun(void) | |||
455 | } | 456 | } |
456 | stop = g_cylinders * g_heads * g_sectors; | 457 | stop = g_cylinders * g_heads * g_sectors; |
457 | if (starts[array[0]]) | 458 | if (starts[array[0]]) |
458 | printf("Unused gap - sectors 0-%d\n", starts[array[0]]); | 459 | printf("Unused gap - sectors %u-%u\n", 0, starts[array[0]]); |
459 | for (i = 0; i < 7 && array[i+1] != -1; i++) { | 460 | for (i = 0; i < 7 && array[i+1] != -1; i++) { |
460 | printf("Unused gap - sectors %d-%d\n", starts[array[i]]+lens[array[i]], starts[array[i+1]]); | 461 | printf("Unused gap - sectors %u-%u\n", starts[array[i]]+lens[array[i]], starts[array[i+1]]); |
461 | } | 462 | } |
462 | start = starts[array[i]] + lens[array[i]]; | 463 | start = starts[array[i]] + lens[array[i]]; |
463 | if (start < stop) | 464 | if (start < stop) |
464 | printf("Unused gap - sectors %d-%d\n", start, stop); | 465 | printf("Unused gap - sectors %u-%u\n", start, stop); |
465 | } | 466 | } |
466 | 467 | ||
467 | static void | 468 | static void |
468 | add_sun_partition(int n, int sys) | 469 | add_sun_partition(int n, int sys) |
469 | { | 470 | { |
470 | uint start, stop, stop2; | 471 | unsigned start, stop, stop2; |
471 | uint starts[8], lens[8]; | 472 | unsigned starts[8], lens[8]; |
472 | int whole_disk = 0; | 473 | int whole_disk = 0; |
473 | 474 | ||
474 | char mesg[256]; | 475 | char mesg[256]; |
@@ -529,7 +530,7 @@ and is of type 'Whole disk'\n"); | |||
529 | whole_disk = 1; | 530 | whole_disk = 1; |
530 | break; | 531 | break; |
531 | } | 532 | } |
532 | printf("Sector %d is already allocated\n", first); | 533 | printf("Sector %u is already allocated\n", first); |
533 | } else | 534 | } else |
534 | break; | 535 | break; |
535 | } | 536 | } |
@@ -560,8 +561,8 @@ and is of type 'Whole disk'\n"); | |||
560 | } else if (last > stop) { | 561 | } else if (last > stop) { |
561 | printf( | 562 | printf( |
562 | "You haven't covered the whole disk with the 3rd partition,\n" | 563 | "You haven't covered the whole disk with the 3rd partition,\n" |
563 | "but your value %d %s covers some other partition.\n" | 564 | "but your value %u %s covers some other partition.\n" |
564 | "Your entry has been changed to %d %s\n", | 565 | "Your entry has been changed to %u %s\n", |
565 | scround(last), str_units(SINGULAR), | 566 | scround(last), str_units(SINGULAR), |
566 | scround(stop), str_units(SINGULAR)); | 567 | scround(stop), str_units(SINGULAR)); |
567 | last = stop; | 568 | last = stop; |
@@ -627,11 +628,11 @@ sun_list_table(int xtra) | |||
627 | w = strlen(disk_device); | 628 | w = strlen(disk_device); |
628 | if (xtra) | 629 | if (xtra) |
629 | printf( | 630 | printf( |
630 | "\nDisk %s (Sun disk label): %d heads, %d sectors, %d rpm\n" | 631 | "\nDisk %s (Sun disk label): %u heads, %u sectors, %u rpm\n" |
631 | "%d cylinders, %d alternate cylinders, %d physical cylinders\n" | 632 | "%u cylinders, %u alternate cylinders, %u physical cylinders\n" |
632 | "%d extra sects/cyl, interleave %d:1\n" | 633 | "%u extra sects/cyl, interleave %u:1\n" |
633 | "%s\n" | 634 | "%s\n" |
634 | "Units = %s of %d * 512 bytes\n\n", | 635 | "Units = %s of %u * 512 bytes\n\n", |
635 | disk_device, g_heads, g_sectors, SUN_SSWAP16(sunlabel->rspeed), | 636 | disk_device, g_heads, g_sectors, SUN_SSWAP16(sunlabel->rspeed), |
636 | g_cylinders, SUN_SSWAP16(sunlabel->nacyl), | 637 | g_cylinders, SUN_SSWAP16(sunlabel->nacyl), |
637 | SUN_SSWAP16(sunlabel->pcylcount), | 638 | SUN_SSWAP16(sunlabel->pcylcount), |
@@ -641,8 +642,8 @@ sun_list_table(int xtra) | |||
641 | str_units(PLURAL), units_per_sector); | 642 | str_units(PLURAL), units_per_sector); |
642 | else | 643 | else |
643 | printf( | 644 | printf( |
644 | "\nDisk %s (Sun disk label): %d heads, %d sectors, %d cylinders\n" | 645 | "\nDisk %s (Sun disk label): %u heads, %u sectors, %u cylinders\n" |
645 | "Units = %s of %d * 512 bytes\n\n", | 646 | "Units = %s of %u * 512 bytes\n\n", |
646 | disk_device, g_heads, g_sectors, g_cylinders, | 647 | disk_device, g_heads, g_sectors, g_cylinders, |
647 | str_units(PLURAL), units_per_sector); | 648 | str_units(PLURAL), units_per_sector); |
648 | 649 | ||
@@ -652,7 +653,7 @@ sun_list_table(int xtra) | |||
652 | if (sunlabel->partitions[i].num_sectors) { | 653 | if (sunlabel->partitions[i].num_sectors) { |
653 | uint32_t start = SUN_SSWAP32(sunlabel->partitions[i].start_cylinder) * g_heads * g_sectors; | 654 | uint32_t start = SUN_SSWAP32(sunlabel->partitions[i].start_cylinder) * g_heads * g_sectors; |
654 | uint32_t len = SUN_SSWAP32(sunlabel->partitions[i].num_sectors); | 655 | uint32_t len = SUN_SSWAP32(sunlabel->partitions[i].num_sectors); |
655 | printf("%s %c%c %9ld %9ld %9ld%c %2x %s\n", | 656 | printf("%s %c%c %9lu %9lu %9lu%c %2x %s\n", |
656 | partname(disk_device, i+1, w), /* device */ | 657 | partname(disk_device, i+1, w), /* device */ |
657 | (sunlabel->infos[i].flags & 0x01) ? 'u' : ' ', /* flags */ | 658 | (sunlabel->infos[i].flags & 0x01) ? 'u' : ' ', /* flags */ |
658 | (sunlabel->infos[i].flags & 0x10) ? 'r' : ' ', | 659 | (sunlabel->infos[i].flags & 0x10) ? 'r' : ' ', |