235
235
alignment_offset;
236
236
int has_topology;
238
#define dos_label (!sun_label && !sgi_label && !aix_label && !mac_label && !osf_label)
239
int sun_label = 0; /* looking at sun disklabel */
240
int sgi_label = 0; /* looking at sgi disklabel */
241
int aix_label = 0; /* looking at aix disklabel */
242
int osf_label = 0; /* looking at OSF/1 disklabel */
243
int mac_label = 0; /* looking at mac disklabel */
238
enum labeltype disklabel = DOS_LABEL; /* Current disklabel */
244
240
int possibly_osf_label = 0;
246
242
jmp_buf listingbuf;
416
412
puts(_(" v verify the partition table"));
417
413
puts(_(" w write table to disk and exit"));
419
else if (aix_label || mac_label) {
415
else if (disklabel == AIX_LABEL || disklabel == MAC_LABEL) {
420
416
puts(_("Command action"));
421
417
puts(_(" m print this menu"));
422
418
puts(_(" o create a new empty DOS partition table"));
480
476
puts(_(" v verify the partition table"));
481
477
puts(_(" w write table to disk and exit"));
483
else if (aix_label || mac_label) {
479
else if (disklabel == AIX_LABEL || disklabel == MAC_LABEL) {
484
480
puts(_("Command action"));
485
481
puts(_(" b move beginning of data in a partition")); /* !sun */
486
482
puts(_(" c change number of cylinders"));
520
516
get_sysid(int i) {
522
sun_label ? sun_get_sysid(i) :
523
sgi_label ? sgi_get_sysid(i) :
518
disklabel == SUN_LABEL ? sun_get_sysid(i) :
519
disklabel == SGI_LABEL ? sgi_get_sysid(i) :
524
520
ptes[i].part_table->sys_ind);
527
523
static struct systypes *
528
524
get_sys_types(void) {
530
sun_label ? sun_sys_types :
531
sgi_label ? sgi_sys_types :
526
disklabel == SUN_LABEL ? sun_sys_types :
527
disklabel == SGI_LABEL ? sgi_sys_types :
1543
if ((!sun_label && !sgi_label && !pe->part_table->sys_ind)
1543
if ((disklabel != SUN_LABEL && disklabel != SGI_LABEL && !pe->part_table->sys_ind)
1544
|| (disklabel == SUN_LABEL &&
1545
1545
(!sunlabel->partitions[i].num_sectors ||
1546
1546
!sunlabel->part_tags[i].tag))
1547
|| (sgi_label && (!sgi_get_num_sectors(i)))
1547
|| (disklabel == SGI_LABEL && (!sgi_get_num_sectors(i)))
1549
1549
fprintf(stderr,
1550
1550
_("Warning: partition %d has empty type\n"),
1738
1739
/* If sgi_label then don't use get_existing_partition,
1739
1740
let the user select a partition, since get_existing_partition()
1740
1741
only works for Linux like partition tables. */
1742
if (disklabel != SGI_LABEL) {
1742
1743
i = get_existing_partition(0, partitions);
1744
1745
i = get_partition(0, partitions);
1752
1753
/* if changing types T to 0 is allowed, then
1753
1754
the reverse change must be allowed, too */
1754
if (!sys && !sgi_label && !sun_label && !get_nr_sects(p))
1755
if (!sys && disklabel != SGI_LABEL && disklabel != SUN_LABEL && !get_nr_sects(p))
1755
1756
printf(_("Partition %d does not exist yet!\n"), i + 1);
1756
1757
else while (1) {
1757
1758
sys = read_hex (get_sys_types());
1759
if (!sys && !sgi_label && !sun_label) {
1760
if (!sys && disklabel != SGI_LABEL && disklabel != SUN_LABEL) {
1760
1761
printf(_("Type 0 means free space to many systems\n"
1761
1762
"(but not to Linux). Having partitions of\n"
1762
1763
"type 0 is probably unwise. You can delete\n"
1776
1777
if (sys < 256) {
1777
if (sun_label && i == 2 && sys != SUN_TAG_BACKUP)
1778
if (disklabel == SUN_LABEL && i == 2 && sys != SUN_TAG_BACKUP)
1778
1779
printf(_("Consider leaving partition 3 "
1779
1780
"as Whole disk (5),\n"
1780
1781
"as SunOS/Solaris expects it and "
1781
1782
"even Linux likes it.\n\n"));
1782
if (sgi_label && ((i == 10 && sys != ENTIRE_DISK)
1783
if (disklabel == SGI_LABEL && ((i == 10 && sys != ENTIRE_DISK)
1783
1784
|| (i == 8 && sys != 0)))
1784
1785
printf(_("Consider leaving partition 9 "
1785
1786
"as volume header (0),\nand "
2143
2144
/* Is partition table in disk order? It need not be, but... */
2144
2145
/* partition table entries are not checked for correct order if this
2145
2146
is a sgi, sun or aix labeled disk... */
2146
if (dos_label && wrong_p_order(NULL)) {
2147
if (disklabel == DOS_LABEL && wrong_p_order(NULL)) {
2147
2148
printf(_("\nPartition table entries are not in disk order\n"));
2338
2338
start = sector_offset;
2339
2339
if (display_in_cyl_units || !total_number_of_sectors)
2340
llimit = heads * sectors * cylinders - 1;
2340
limit = heads * sectors * cylinders - 1;
2342
llimit = total_number_of_sectors - 1;
2344
if (limit != llimit)
2342
limit = total_number_of_sectors - 1;
2344
if (limit > UINT_MAX)
2346
2347
if (extended_offset) {
2347
2348
first[ext_index] = extended_offset;
2348
2349
last[ext_index] = get_start_sect(q) +
2485
2487
if (warn_geometry())
2490
if (disklabel == SUN_LABEL) {
2489
2491
add_sun_partition(get_partition(0, partitions), LINUX_NATIVE);
2495
if (disklabel == SGI_LABEL) {
2494
2496
sgi_add_partition(get_partition(0, partitions), LINUX_NATIVE);
2500
if (disklabel == AIX_LABEL) {
2499
2501
printf(_("\tSorry - this fdisk cannot handle AIX disk labels."
2500
2502
"\n\tIf you want to add DOS-type partitions, create"
2501
2503
"\n\ta new empty DOS partition table first. (Use o.)"
2524
2526
if (!free_primary) {
2525
if (extended_offset)
2527
if (extended_offset) {
2528
printf(_("All primary partitions are in use\n"));
2528
printf(_("You must delete some partition and add "
2529
"an extended partition first\n"));
2531
printf(_("If you want to create more than four partitions, you must replace a\n"
2532
"primary partition with an extended partition first.\n"));
2530
2533
} else if (partitions >= MAXIMUM_PARTS) {
2531
2534
printf(_("All logical partitions are in use\n"));
2532
2535
printf(_("Adding a primary partition\n"));
2533
2536
add_partition(get_partition(0, 4), LINUX_NATIVE);
2535
char c, line[LINE_LENGTH];
2538
char c, dflt, line[LINE_LENGTH];
2540
dflt = (free_primary == 1 && !extended_offset) ? 'e' : 'p';
2536
2541
snprintf(line, sizeof(line),
2537
_("Command action\n %s\n p primary "
2538
"partition (1-4)\n"), extended_offset ?
2539
_("l logical (5 or over)") : _("e extended"));
2541
if ((c = tolower(read_char(line))) == 'p') {
2542
int i = get_nonexisting_partition(0, 4);
2544
add_partition(i, LINUX_NATIVE);
2547
else if (c == 'l' && extended_offset) {
2551
else if (c == 'e' && !extended_offset) {
2552
int i = get_nonexisting_partition(0, 4);
2554
add_partition(i, EXTENDED);
2558
printf(_("Invalid partition number "
2559
"for type `%c'\n"), c);
2542
_("Partition type:\n"
2543
" p primary (%d primary, %d extended, %d free)\n"
2545
"Select (default %c): "),
2546
4 - (extended_offset ? 1 : 0) - free_primary, extended_offset ? 1 : 0, free_primary,
2547
extended_offset ? _(" l logical (numbered from 5)") : _(" e extended"),
2550
c = tolower(read_chars(line));
2553
printf(_("Using default response %c\n"), c);
2556
int i = get_nonexisting_partition(0, 4);
2558
add_partition(i, LINUX_NATIVE);
2560
} else if (c == 'l' && extended_offset) {
2563
} else if (c == 'e' && !extended_offset) {
2564
int i = get_nonexisting_partition(0, 4);
2566
add_partition(i, EXTENDED);
2569
printf(_("Invalid partition type `%c'\n"), c);
2734
2742
c = tolower(read_char(_("Expert command (m for help): ")));
2745
if (disklabel == SUN_LABEL)
2738
2746
sun_set_alt_cyl();
2749
if (disklabel == DOS_LABEL)
2742
2750
move_begin(get_partition(0, partitions));
2745
2753
user_cylinders = cylinders =
2746
2754
read_int(1, cylinders, 1048576, 0,
2747
2755
_("Number of cylinders"));
2756
if (disklabel == SUN_LABEL)
2749
2757
sun_set_ncyl(cylinders);
2763
if (disklabel == SGI_LABEL)
2756
2764
sgi_set_xcyl();
2765
else if (disklabel == SUN_LABEL)
2758
2766
sun_set_xcyl();
2768
if (disklabel == DOS_LABEL)
2761
2769
x_list_table(1);
2772
if (disklabel == DOS_LABEL)
2765
2773
fix_partition_table_order();
2877
2885
if (gb > 0) { /* I/O error */
2878
2886
} else if (gb < 0) { /* no DOS signature */
2879
2887
list_disk_geometry();
2880
if (!aix_label && !mac_label && btrydev(device) < 0)
2888
if (disklabel != AIX_LABEL && disklabel != MAC_LABEL && btrydev(device) < 0)
2881
2889
fprintf(stderr,
2882
2890
_("Disk %s doesn't contain a valid "
2883
2891
"partition table\n"), device);
3086
3093
c = tolower(read_char(_("Command (m for help): ")));
3096
if (disklabel == DOS_LABEL)
3090
3097
toggle_active(get_partition(1, partitions));
3098
else if (disklabel == SUN_LABEL)
3092
3099
toggle_sunflags(get_partition(1, partitions),
3093
3100
SUN_FLAG_UNMNT);
3101
else if (disklabel == SGI_LABEL)
3095
3102
sgi_set_bootpartition(
3096
3103
get_partition(1, partitions));
3098
3105
unknown_command(c);
3108
if (disklabel == SGI_LABEL) {
3102
3109
printf(_("\nThe current boot file is: %s\n"),
3103
3110
sgi_get_bootfile());
3104
3111
if (read_chars(_("Please enter the name of the "
3120
if (disklabel == DOS_LABEL)
3114
3121
toggle_dos_compatibility_flag();
3122
else if (disklabel == SUN_LABEL)
3116
3123
toggle_sunflags(get_partition(1, partitions),
3117
3124
SUN_FLAG_RONLY);
3125
else if (disklabel == SGI_LABEL)
3119
3126
sgi_set_swappartition(
3120
3127
get_partition(1, partitions));