~ubuntu-branches/ubuntu/trusty/util-linux/trusty-proposed

« back to all changes in this revision

Viewing changes to fdisk/fdisk.c

  • Committer: Package Import Robot
  • Author(s): LaMont Jones
  • Date: 2011-11-03 15:38:23 UTC
  • mto: (4.5.5 sid) (1.6.4)
  • mto: This revision was merged to the branch mainline in revision 85.
  • Revision ID: package-import@ubuntu.com-20111103153823-10sx16jprzxlhkqf
ImportĀ upstreamĀ versionĀ 2.20.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
#ifdef HAVE_LINUX_BLKPG_H
45
45
#include <linux/blkpg.h>
46
46
#endif
47
 
#ifdef HAVE_LIBBLKID_INTERNAL
 
47
#ifdef HAVE_LIBBLKID
48
48
#include <blkid.h>
49
49
#endif
50
50
 
235
235
              alignment_offset;
236
236
int has_topology;
237
237
 
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 */
 
239
 
244
240
int     possibly_osf_label = 0;
245
241
 
246
242
jmp_buf listingbuf;
379
375
 
380
376
static void
381
377
menu(void) {
382
 
        if (sun_label) {
 
378
        if (disklabel == SUN_LABEL) {
383
379
           puts(_("Command action"));
384
380
           puts(_("   a   toggle a read only flag"));           /* sun */
385
381
           puts(_("   b   edit bsd disklabel"));
398
394
           puts(_("   w   write table to disk and exit"));
399
395
           puts(_("   x   extra functionality (experts only)"));
400
396
        }
401
 
        else if (sgi_label) {
 
397
        else if (disklabel == SGI_LABEL) {
402
398
           puts(_("Command action"));
403
399
           puts(_("   a   select bootable partition"));    /* sgi flavour */
404
400
           puts(_("   b   edit bootfile entry"));          /* sgi */
416
412
           puts(_("   v   verify the partition table"));
417
413
           puts(_("   w   write table to disk and exit"));
418
414
        }
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"));
446
442
 
447
443
static void
448
444
xmenu(void) {
449
 
        if (sun_label) {
 
445
        if (disklabel == SUN_LABEL) {
450
446
           puts(_("Command action"));
451
447
           puts(_("   a   change number of alternate cylinders"));      /*sun*/
452
448
           puts(_("   c   change number of cylinders"));
464
460
           puts(_("   w   write table to disk and exit"));
465
461
           puts(_("   y   change number of physical cylinders"));       /*sun*/
466
462
        }
467
 
        else if (sgi_label) {
 
463
        else if (disklabel == SGI_LABEL) {
468
464
           puts(_("Command action"));
469
465
           puts(_("   b   move beginning of data in a partition")); /* !sun */
470
466
           puts(_("   c   change number of cylinders"));
480
476
           puts(_("   v   verify the partition table"));
481
477
           puts(_("   w   write table to disk and exit"));
482
478
        }
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"));
519
515
static int
520
516
get_sysid(int i) {
521
517
        return (
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);
525
521
}
526
522
 
527
523
static struct systypes *
528
524
get_sys_types(void) {
529
525
        return (
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 :
532
528
                i386_sys_types);
533
529
}
534
530
 
729
725
        char *m = NULL;
730
726
        int prev = 0;
731
727
 
732
 
        if (sgi_label)  /* cannot set cylinders etc anyway */
 
728
        if (disklabel == SGI_LABEL)     /* cannot set cylinders etc anyway */
733
729
                return 0;
734
730
        if (!heads)
735
731
                prev = test_c(&m, _("heads"));
938
934
                id);
939
935
        sun_nolabel();  /* otherwise always recognised as sun */
940
936
        sgi_nolabel();  /* otherwise always recognised as sgi */
941
 
        mac_label = aix_label = osf_label = possibly_osf_label = 0;
 
937
        disklabel = DOS_LABEL;
 
938
        possibly_osf_label = 0;
942
939
        partitions = 4;
943
940
 
944
941
        /* Zero out the MBR buffer */
957
954
static void
958
955
get_topology(int fd) {
959
956
        int arg;
960
 
#ifdef HAVE_LIBBLKID_INTERNAL
 
957
#ifdef HAVE_LIBBLKID
961
958
        blkid_probe pr;
962
959
 
963
960
        pr = blkid_new_probe();
1233
1230
        if (check_osf_label()) {
1234
1231
                possibly_osf_label = 1;
1235
1232
                if (!valid_part_table_flag(MBRbuffer)) {
1236
 
                        osf_label = 1;
 
1233
                        disklabel = OSF_LABEL;
1237
1234
                        return 0;
1238
1235
                }
1239
1236
                printf(_("This disk has both DOS and BSD magic.\n"
1400
1397
        unsigned int i;
1401
1398
        int default_ok = 1;
1402
1399
        static char *ms = NULL;
1403
 
        static int mslen = 0;
 
1400
        static size_t mslen = 0;
1404
1401
 
1405
1402
        if (!ms || strlen(mesg)+100 > mslen) {
1406
1403
                mslen = strlen(mesg)+200;
1435
1432
                        while (isdigit(*++line_ptr))
1436
1433
                                use_default = 0;
1437
1434
 
 
1435
                        while (isspace(*line_ptr))
 
1436
                                line_ptr++;
 
1437
 
1438
1438
                        suflen = strlen(line_ptr) - 1;
1439
1439
 
1440
1440
                        while(isspace(*(line_ptr + suflen)))
1540
1540
        pe = &ptes[i];
1541
1541
 
1542
1542
        if (warn) {
1543
 
                if ((!sun_label && !sgi_label && !pe->part_table->sys_ind)
1544
 
                    || (sun_label &&
 
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)))
1548
1548
                   )
1549
1549
                        fprintf(stderr,
1550
1550
                                _("Warning: partition %d has empty type\n"),
1573
1573
                        pno = i;
1574
1574
                }
1575
1575
        }
 
1576
 
1576
1577
        if (pno >= 0) {
1577
1578
                printf(_("Selected partition %d\n"), pno+1);
1578
1579
                return pno;
1670
1671
                return;         /* C/H/S not set */
1671
1672
        pe->changed = 1;
1672
1673
 
1673
 
        if (sun_label) {
 
1674
        if (disklabel == SUN_LABEL) {
1674
1675
                sun_delete_partition(i);
1675
1676
                return;
1676
1677
        }
1677
1678
 
1678
 
        if (sgi_label) {
 
1679
        if (disklabel == SGI_LABEL) {
1679
1680
                sgi_delete_partition(i);
1680
1681
                return;
1681
1682
        }
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. */
1741
 
        if (!sgi_label) {
 
1742
        if (disklabel != SGI_LABEL) {
1742
1743
                i = get_existing_partition(0, partitions);
1743
1744
        } else {
1744
1745
                i = get_partition(0, partitions);
1751
1752
 
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());
1758
1759
 
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"
1764
1765
                        /* break; */
1765
1766
                }
1766
1767
 
1767
 
                if (!sun_label && !sgi_label) {
 
1768
                if (disklabel != SGI_LABEL && disklabel != SUN_LABEL) {
1768
1769
                        if (IS_EXTENDED (sys) != IS_EXTENDED (p->sys_ind)) {
1769
1770
                                printf(_("You cannot change a partition into"
1770
1771
                                       " an extended one or vice versa\n"
1774
1775
                }
1775
1776
 
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 "
1787
1788
                                       "as IRIX expects it.\n\n"));
1788
1789
                        if (sys == origsys)
1789
1790
                                break;
1790
 
                        if (sun_label) {
 
1791
                        if (disklabel == SUN_LABEL) {
1791
1792
                                ptes[i].changed = sun_change_sysid(i, sys);
1792
1793
                        } else
1793
 
                        if (sgi_label) {
 
1794
                        if (disklabel == SGI_LABEL) {
1794
1795
                                ptes[i].changed = sgi_change_sysid(i, sys);
1795
1796
                        } else {
1796
1797
                                p->sys_ind = sys;
1928
1929
                                min_io_size, io_size);
1929
1930
        if (alignment_offset)
1930
1931
                printf(_("Alignment offset: %lu bytes\n"), alignment_offset);
1931
 
        if (dos_label)
 
1932
        if (disklabel == DOS_LABEL)
1932
1933
                dos_print_mbr_id();
1933
1934
        printf("\n");
1934
1935
}
2074
2075
        char *type;
2075
2076
        int i, w;
2076
2077
 
2077
 
        if (sun_label) {
 
2078
        if (disklabel == SUN_LABEL) {
2078
2079
                sun_list_table(xtra);
2079
2080
                return;
2080
2081
        }
2081
2082
 
2082
 
        if (sgi_label) {
 
2083
        if (disklabel == SGI_LABEL) {
2083
2084
                sgi_list_table(xtra);
2084
2085
                return;
2085
2086
        }
2086
2087
 
2087
2088
        list_disk_geometry();
2088
2089
 
2089
 
        if (osf_label) {
 
2090
        if (disklabel == OSF_LABEL) {
2090
2091
                xbsd_print_disklabel(xtra);
2091
2092
                return;
2092
2093
        }
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"));
2148
2149
        }
2149
2150
}
2232
2233
        if (warn_geometry())
2233
2234
                return;
2234
2235
 
2235
 
        if (sun_label) {
 
2236
        if (disklabel == SUN_LABEL) {
2236
2237
                verify_sun();
2237
2238
                return;
2238
2239
        }
2239
2240
 
2240
 
        if (sgi_label) {
 
2241
        if (disklabel == SGI_LABEL) {
2241
2242
                verify_sgi(1);
2242
2243
                return;
2243
2244
        }
2324
2325
        int i, read = 0;
2325
2326
        struct partition *p = ptes[n].part_table;
2326
2327
        struct partition *q = ptes[ext_index].part_table;
2327
 
        long long llimit;
2328
2328
        unsigned long long start, stop = 0, limit, temp,
2329
2329
                first[partitions], last[partitions];
2330
2330
 
2337
2337
        if (n < 4) {
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;
2341
2341
                else
2342
 
                        llimit = total_number_of_sectors - 1;
2343
 
                limit = llimit;
2344
 
                if (limit != llimit)
2345
 
                        limit = 0x7fffffff;
 
2342
                        limit = total_number_of_sectors - 1;
 
2343
 
 
2344
                if (limit > UINT_MAX)
 
2345
                        limit = UINT_MAX;
 
2346
 
2346
2347
                if (extended_offset) {
2347
2348
                        first[ext_index] = extended_offset;
2348
2349
                        last[ext_index] = get_start_sect(q) +
2475
2476
                pe->changed = 1;
2476
2477
                partitions++;
2477
2478
        }
 
2479
        printf(_("Adding logical partition %d\n"), partitions);
2478
2480
        add_partition(partitions - 1, LINUX_NATIVE);
2479
2481
}
2480
2482
 
2485
2487
        if (warn_geometry())
2486
2488
                return;
2487
2489
 
2488
 
        if (sun_label) {
 
2490
        if (disklabel == SUN_LABEL) {
2489
2491
                add_sun_partition(get_partition(0, partitions), LINUX_NATIVE);
2490
2492
                return;
2491
2493
        }
2492
2494
 
2493
 
        if (sgi_label) {
 
2495
        if (disklabel == SGI_LABEL) {
2494
2496
                sgi_add_partition(get_partition(0, partitions), LINUX_NATIVE);
2495
2497
                return;
2496
2498
        }
2497
2499
 
2498
 
        if (aix_label) {
 
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.)"
2504
2506
                return;
2505
2507
        }
2506
2508
 
2507
 
        if (mac_label) {
 
2509
        if (disklabel == MAC_LABEL) {
2508
2510
                printf(_("\tSorry - this fdisk cannot handle Mac disk labels."
2509
2511
                         "\n\tIf you want to add DOS-type partitions, create"
2510
2512
                         "\n\ta new empty DOS partition table first. (Use o.)"
2522
2524
        }
2523
2525
 
2524
2526
        if (!free_primary) {
2525
 
                if (extended_offset)
 
2527
                if (extended_offset) {
 
2528
                        printf(_("All primary partitions are in use\n"));
2526
2529
                        add_logical();
2527
 
                else
2528
 
                        printf(_("You must delete some partition and add "
2529
 
                                 "an extended partition first\n"));
 
2530
                } else
 
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);
2534
2537
        } else {
2535
 
                char c, line[LINE_LENGTH];
 
2538
                char c, dflt, line[LINE_LENGTH];
 
2539
 
 
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"));
2540
 
                while (1) {
2541
 
                        if ((c = tolower(read_char(line))) == 'p') {
2542
 
                                int i = get_nonexisting_partition(0, 4);
2543
 
                                if (i >= 0)
2544
 
                                        add_partition(i, LINUX_NATIVE);
2545
 
                                return;
2546
 
                        }
2547
 
                        else if (c == 'l' && extended_offset) {
2548
 
                                add_logical();
2549
 
                                return;
2550
 
                        }
2551
 
                        else if (c == 'e' && !extended_offset) {
2552
 
                                int i = get_nonexisting_partition(0, 4);
2553
 
                                if (i >= 0)
2554
 
                                        add_partition(i, EXTENDED);
2555
 
                                return;
2556
 
                        }
2557
 
                        else
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"
 
2544
                           "%s\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"),
 
2548
                         dflt);
 
2549
 
 
2550
                c = tolower(read_chars(line));
 
2551
                if (c == '\n') {
 
2552
                        c = dflt;
 
2553
                        printf(_("Using default response %c\n"), c);
2560
2554
                }
 
2555
                if (c == 'p') {
 
2556
                        int i = get_nonexisting_partition(0, 4);
 
2557
                        if (i >= 0)
 
2558
                                add_partition(i, LINUX_NATIVE);
 
2559
                        return;
 
2560
                } else if (c == 'l' && extended_offset) {
 
2561
                        add_logical();
 
2562
                        return;
 
2563
                } else if (c == 'e' && !extended_offset) {
 
2564
                        int i = get_nonexisting_partition(0, 4);
 
2565
                        if (i >= 0)
 
2566
                                add_partition(i, EXTENDED);
 
2567
                        return;
 
2568
                } else
 
2569
                        printf(_("Invalid partition type `%c'\n"), c);
2561
2570
        }
2562
2571
}
2563
2572
 
2565
2574
write_table(void) {
2566
2575
        int i;
2567
2576
 
2568
 
        if (dos_label) {
 
2577
        if (disklabel == DOS_LABEL) {
2569
2578
                /* MBR (primary partitions) */
2570
2579
                if (!MBRbuffer_changed) {
2571
2580
                        for (i = 0; i < 4; i++)
2586
2595
                        }
2587
2596
                }
2588
2597
        }
2589
 
        else if (sgi_label) {
 
2598
        else if (disklabel == SGI_LABEL) {
2590
2599
                /* no test on change? the printf below might be mistaken */
2591
2600
                sgi_write_table();
2592
 
        } else if (sun_label) {
 
2601
        } else if (disklabel == SUN_LABEL) {
2593
2602
                int needw = 0;
2594
2603
 
2595
2604
                for (i=0; i<8; i++)
2648
2657
#define MAX_PER_LINE    16
2649
2658
static void
2650
2659
print_buffer(unsigned char pbuffer[]) {
2651
 
        int     i,
2652
 
                l;
 
2660
        unsigned int i, l;
2653
2661
 
2654
2662
        for (i = 0, l = 0; i < sector_size; i++, l++) {
2655
2663
                if (l == 0)
2670
2678
        int i;
2671
2679
 
2672
2680
        printf(_("Device: %s\n"), disk_device);
2673
 
        if (sun_label || sgi_label)
 
2681
        if (disklabel == SUN_LABEL || disklabel == SGI_LABEL)
2674
2682
                print_buffer(MBRbuffer);
2675
2683
        else for (i = 3; i < partitions; i++)
2676
2684
                print_buffer(ptes[i].sectorbuffer);
2734
2742
                c = tolower(read_char(_("Expert command (m for help): ")));
2735
2743
                switch (c) {
2736
2744
                case 'a':
2737
 
                        if (sun_label)
 
2745
                        if (disklabel == SUN_LABEL)
2738
2746
                                sun_set_alt_cyl();
2739
2747
                        break;
2740
2748
                case 'b':
2741
 
                        if (dos_label)
 
2749
                        if (disklabel == DOS_LABEL)
2742
2750
                                move_begin(get_partition(0, partitions));
2743
2751
                        break;
2744
2752
                case 'c':
2745
2753
                        user_cylinders = cylinders =
2746
2754
                                read_int(1, cylinders, 1048576, 0,
2747
2755
                                         _("Number of cylinders"));
2748
 
                        if (sun_label)
 
2756
                        if (disklabel == SUN_LABEL)
2749
2757
                                sun_set_ncyl(cylinders);
2750
2758
                        break;
2751
2759
                case 'd':
2752
2760
                        print_raw();
2753
2761
                        break;
2754
2762
                case 'e':
2755
 
                        if (sgi_label)
 
2763
                        if (disklabel == SGI_LABEL)
2756
2764
                                sgi_set_xcyl();
2757
 
                        else if (sun_label)
 
2765
                        else if (disklabel == SUN_LABEL)
2758
2766
                                sun_set_xcyl();
2759
2767
                        else
2760
 
                        if (dos_label)
 
2768
                        if (disklabel == DOS_LABEL)
2761
2769
                                x_list_table(1);
2762
2770
                        break;
2763
2771
                case 'f':
2764
 
                        if (dos_label)
 
2772
                        if (disklabel == DOS_LABEL)
2765
2773
                                fix_partition_table_order();
2766
2774
                        break;
2767
2775
                case 'g':
2773
2781
                        update_units();
2774
2782
                        break;
2775
2783
                case 'i':
2776
 
                        if (sun_label)
 
2784
                        if (disklabel == SUN_LABEL)
2777
2785
                                sun_set_ilfact();
2778
 
                        if (dos_label)
 
2786
                        else if (disklabel == DOS_LABEL)
2779
2787
                                dos_set_mbr_id();
2780
2788
                        break;
2781
2789
                case 'o':
2782
 
                        if (sun_label)
 
2790
                        if (disklabel == SUN_LABEL)
2783
2791
                                sun_set_rspeed();
2784
2792
                        break;
2785
2793
                case 'p':
2786
 
                        if (sun_label)
 
2794
                        if (disklabel == SUN_LABEL)
2787
2795
                                list_table(1);
2788
2796
                        else
2789
2797
                                x_list_table(0);
2811
2819
                        write_table();  /* does not return */
2812
2820
                        break;
2813
2821
                case 'y':
2814
 
                        if (sun_label)
 
2822
                        if (disklabel == SUN_LABEL)
2815
2823
                                sun_set_pcylcount();
2816
2824
                        break;
2817
2825
                default:
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);
2929
2937
        fclose(procpt);
2930
2938
}
2931
2939
 
2932
 
static void
2933
 
dummy(int *kk) {}
 
2940
static void dummy(int *kk __attribute__ ((__unused__))) {}
2934
2941
 
2935
2942
static void
2936
2943
unknown_command(int c) {
3071
3078
        gpt_warning(disk_device);
3072
3079
        get_boot(fdisk);
3073
3080
 
3074
 
        if (osf_label) {
 
3081
        if (disklabel == OSF_LABEL) {
3075
3082
                /* OSF label, and no DOS label */
3076
3083
                printf(_("Detected an OSF/1 disklabel on %s, entering "
3077
3084
                         "disklabel mode.\n"),
3078
3085
                       disk_device);
3079
3086
                bselect();
3080
 
                osf_label = 0;
3081
3087
                /* If we return we may want to make an empty DOS label? */
 
3088
                disklabel = DOS_LABEL;
3082
3089
        }
3083
3090
 
3084
3091
        while (1) {
3086
3093
                c = tolower(read_char(_("Command (m for help): ")));
3087
3094
                switch (c) {
3088
3095
                case 'a':
3089
 
                        if (dos_label)
 
3096
                        if (disklabel == DOS_LABEL)
3090
3097
                                toggle_active(get_partition(1, partitions));
3091
 
                        else if (sun_label)
 
3098
                        else if (disklabel == SUN_LABEL)
3092
3099
                                toggle_sunflags(get_partition(1, partitions),
3093
3100
                                                SUN_FLAG_UNMNT);
3094
 
                        else if (sgi_label)
 
3101
                        else if (disklabel == SGI_LABEL)
3095
3102
                                sgi_set_bootpartition(
3096
3103
                                        get_partition(1, partitions));
3097
3104
                        else
3098
3105
                                unknown_command(c);
3099
3106
                        break;
3100
3107
                case 'b':
3101
 
                        if (sgi_label) {
 
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 "
3110
3117
                                bselect();
3111
3118
                        break;
3112
3119
                case 'c':
3113
 
                        if (dos_label)
 
3120
                        if (disklabel == DOS_LABEL)
3114
3121
                                toggle_dos_compatibility_flag();
3115
 
                        else if (sun_label)
 
3122
                        else if (disklabel == SUN_LABEL)
3116
3123
                                toggle_sunflags(get_partition(1, partitions),
3117
3124
                                                SUN_FLAG_RONLY);
3118
 
                        else if (sgi_label)
 
3125
                        else if (disklabel == SGI_LABEL)
3119
3126
                                sgi_set_swappartition(
3120
3127
                                                get_partition(1, partitions));
3121
3128
                        else
3126
3133
                           let the user select a partition, since
3127
3134
                           get_existing_partition() only works for Linux-like
3128
3135
                           partition tables */
3129
 
                        if (!sgi_label) {
 
3136
                        if (disklabel != SGI_LABEL) {
3130
3137
                                j = get_existing_partition(1, partitions);
3131
3138
                        } else {
3132
3139
                                j = get_partition(1, partitions);
3135
3142
                                delete_partition(j);
3136
3143
                        break;
3137
3144
                case 'i':
3138
 
                        if (sgi_label)
 
3145
                        if (disklabel == SGI_LABEL)
3139
3146
                                create_sgiinfo();
3140
3147
                        else
3141
3148
                                unknown_command(c);
3174
3181
                        write_table();          /* does not return */
3175
3182
                        break;
3176
3183
                case 'x':
3177
 
                        if (sgi_label) {
 
3184
                        if (disklabel == SGI_LABEL) {
3178
3185
                                fprintf(stderr,
3179
3186
                                        _("\n\tSorry, no experts menu for SGI "
3180
3187
                                        "partition tables available.\n\n"));