Ignore:
Timestamp:
Feb 25, 2011, 9:26:54 PM (13 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mindi-busybox/util-linux/fdisk_sgi.c

    r1765 r2725  
    1 #if ENABLE_FEATURE_SGI_LABEL
    2 
    31/*
    42 * Copyright (C) Andreas Neuper, Sep 1998.
    5  *      This file may be modified and redistributed under
    6  *      the terms of the GNU Public License.
     3 *
     4 * Licensed under GPLv2, see file LICENSE in this source tree.
    75 */
     6
     7#if ENABLE_FEATURE_SGI_LABEL
     8
     9#define SGI_DEBUG 0
    810
    911#define SGI_VOLHDR      0x00
     
    3537    unsigned short bytes;
    3638    unsigned short ilfact;
    37     unsigned int   flags;           /* controller flags */
     39    unsigned int   flags;   /* controller flags */
    3840    unsigned int   datarate;
    3941    unsigned int   retries_on_error;
     
    6971        unsigned int  vol_file_size;    /* number of bytes */
    7072    } directory[15];
    71     struct sgi_partinfo {                  /* 16 * 12 bytes */
     73    struct sgi_partinfo {                   /* 16 * 12 bytes */
    7274        unsigned int num_sectors;       /* number of blocks */
    7375        unsigned int start_sector;      /* must be cylinder aligned */
     
    118120
    119121
    120 static int sgi_other_endian;
    121 static int debug;
    122 static short sgi_volumes = 1;
     122static smallint sgi_other_endian; /* bool */
     123static smallint sgi_volumes = 1; /* max 15 */
    123124
    124125/*
     
    235236     && sgilabel->magic != SGI_LABEL_MAGIC_SWAPPED
    236237    ) {
    237         current_label_type = label_dos;
     238        current_label_type = LABEL_DOS;
    238239        return 0;
    239240    }
     
    248249    }
    249250    update_units();
    250     current_label_type = label_sgi;
    251     partitions = 16;
     251    current_label_type = LABEL_SGI;
     252    g_partitions = 16;
    252253    sgi_volumes = 15;
    253254    return 1;
     
    291292
    292293    if (xtra) {
    293         printf("\nDisk %s (SGI disk label): %d heads, %d sectors\n"
    294             "%d cylinders, %d physical cylinders\n"
    295             "%d extra sects/cyl, interleave %d:1\n"
     294        printf("\nDisk %s (SGI disk label): %u heads, %u sectors\n"
     295            "%u cylinders, %u physical cylinders\n"
     296            "%u extra sects/cyl, interleave %u:1\n"
    296297            "%s\n"
    297             "Units = %s of %d * 512 bytes\n\n",
    298             disk_device, heads, sectors, cylinders,
     298            "Units = %s of %u * 512 bytes\n\n",
     299            disk_device, g_heads, g_sectors, g_cylinders,
    299300            SGI_SSWAP16(sgiparam.pcylcount),
    300301            SGI_SSWAP16(sgiparam.sparecyl),
     
    304305    } else {
    305306        printf("\nDisk %s (SGI disk label): "
    306             "%d heads, %d sectors, %d cylinders\n"
    307             "Units = %s of %d * 512 bytes\n\n",
    308             disk_device, heads, sectors, cylinders,
     307            "%u heads, %u sectors, %u cylinders\n"
     308            "Units = %s of %u * 512 bytes\n\n",
     309            disk_device, g_heads, g_sectors, g_cylinders,
    309310            str_units(PLURAL), units_per_sector );
    310311    }
     
    318319        "Pt# %*s  Info     Start       End   Sectors  Id  System\n",
    319320        w + 2, "Device");
    320     for (i = 0; i < partitions; i++) {
    321         if (sgi_get_num_sectors(i) || debug ) {
     321    for (i = 0; i < g_partitions; i++) {
     322        if (sgi_get_num_sectors(i) || SGI_DEBUG) {
    322323            uint32_t start = sgi_get_start_sector(i);
    323324            uint32_t len = sgi_get_num_sectors(i);
    324325            kpi++;              /* only count nonempty partitions */
    325326            printf(
    326             "%2d: %s %4s %9ld %9ld %9ld  %2x  %s\n",
     327            "%2u: %s %4s %9lu %9lu %9lu  %2x  %s\n",
    327328/* fdisk part number */ i+1,
    328329/* device */            partname(disk_device, kpi, w+3),
     
    345346            unsigned char *name = sgilabel->directory[i].vol_file_name;
    346347
    347             printf("%2d: %-10s sector%5u size%8u\n",
     348            printf("%2u: %-10s sector%5u size%8u\n",
    348349                i, (char*)name, (unsigned int) start, (unsigned int) len);
    349350        }
     
    360361sgi_get_lastblock(void)
    361362{
    362     return heads * sectors * cylinders;
     363    return g_heads * g_sectors * g_cylinders;
    363364}
    364365
     
    439440        (unsigned int*)sgilabel, sizeof(*sgilabel)) == 0);
    440441
    441     if (lseek(fd, 0, SEEK_SET) < 0)
    442         fdisk_fatal(unable_to_seek);
    443     if (write(fd, sgilabel, SECTOR_SIZE) != SECTOR_SIZE)
    444         fdisk_fatal(unable_to_write);
     442    write_sector(0, sgilabel);
    445443    if (!strncmp((char*)sgilabel->directory[0].vol_file_name, "sgilabel", 8)) {
    446444        /*
     
    450448        sgiinfo *info = fill_sgiinfo();
    451449        int infostartblock = SGI_SSWAP32(sgilabel->directory[0].vol_file_start);
    452         if (lseek(fd, infostartblock*SECTOR_SIZE, SEEK_SET) < 0)
    453             fdisk_fatal(unable_to_seek);
    454         if (write(fd, info, SECTOR_SIZE) != SECTOR_SIZE)
    455             fdisk_fatal(unable_to_write);
     450        write_sector(infostartblock, info);
    456451        free(info);
    457452    }
     
    513508            printf("The entire disk partition should start "
    514509                "at block 0,\n"
    515                 "not at diskblock %d\n",
     510                "not at diskblock %u\n",
    516511                sgi_get_start_sector(Index[0]));
    517         if (debug)      /* I do not understand how some disks fulfil it */
     512        if (SGI_DEBUG)      /* I do not understand how some disks fulfil it */
    518513            if ((sgi_get_num_sectors(Index[0]) != lastblock) && verbose)
    519                 printf("The entire disk partition is only %d diskblock large,\n"
    520                     "but the disk is %d diskblocks long\n",
     514                printf("The entire disk partition is only %u diskblock large,\n"
     515                    "but the disk is %u diskblocks long\n",
    521516                    sgi_get_num_sectors(Index[0]), lastblock);
    522517            lastblock = sgi_get_num_sectors(Index[0]);
     
    524519        if (verbose)
    525520            printf("One Partition (#11) should cover the entire disk\n");
    526         if (debug > 2)
    527             printf("sysid=%d\tpartition=%d\n",
     521        if (SGI_DEBUG > 2)
     522            printf("sysid=%u\tpartition=%u\n",
    528523                sgi_get_sysid(Index[0]), Index[0]+1);
    529524    }
     
    532527
    533528        if ((sgi_get_start_sector(Index[i]) % cylsize) != 0) {
    534             if (debug)      /* I do not understand how some disks fulfil it */
     529            if (SGI_DEBUG)      /* I do not understand how some disks fulfil it */
    535530                if (verbose)
    536                     printf("Partition %d does not start on cylinder boundary\n",
     531                    printf("Partition %u does not start on cylinder boundary\n",
    537532                        Index[i]+1);
    538533        }
    539534        if (sgi_get_num_sectors(Index[i]) % cylsize != 0) {
    540             if (debug)      /* I do not understand how some disks fulfil it */
     535            if (SGI_DEBUG)      /* I do not understand how some disks fulfil it */
    541536                if (verbose)
    542                     printf("Partition %d does not end on cylinder boundary\n",
     537                    printf("Partition %u does not end on cylinder boundary\n",
    543538                        Index[i]+1);
    544539        }
     
    547542        if (start > sgi_get_start_sector(Index[i])) {
    548543            if (verbose)
    549                 printf("Partitions %d and %d overlap by %d sectors\n",
     544                printf("Partitions %u and %u overlap by %u sectors\n",
    550545                    Index[i-1]+1, Index[i]+1,
    551546                    start - sgi_get_start_sector(Index[i]));
     
    555550        if (start < sgi_get_start_sector(Index[i])) {
    556551            if (verbose)
    557                 printf("Unused gap of %8u sectors - sectors %8u-%8u\n",
     552                printf("Unused gap of %u sectors - sectors %u-%u\n",
    558553                    sgi_get_start_sector(Index[i]) - start,
    559554                    start, sgi_get_start_sector(Index[i])-1);
     
    563558        start = sgi_get_start_sector(Index[i])
    564559               + sgi_get_num_sectors(Index[i]);
    565         if (debug > 1) {
     560        if (SGI_DEBUG > 1) {
    566561            if (verbose)
    567                 printf("%2d:%12d\t%12d\t%12d\n", Index[i],
     562                printf("%2u:%12u\t%12u\t%12u\n", Index[i],
    568563                    sgi_get_start_sector(Index[i]),
    569564                    sgi_get_num_sectors(Index[i]),
     
    573568    if (start < lastblock) {
    574569        if (verbose)
    575             printf("Unused gap of %8u sectors - sectors %8u-%8u\n",
     570            printf("Unused gap of %u sectors - sectors %u-%u\n",
    576571                lastblock - start, start, lastblock-1);
    577572        gap += lastblock - start;
     
    661656    int n;
    662657
    663     for (n = 10; n < partitions; n++) {
     658    for (n = 10; n < g_partitions; n++) {
    664659        if (!sgi_get_num_sectors(n) ) {
    665660            sgi_set_partition(n, 0, sgi_get_lastblock(), SGI_VOLUME);
     
    674669    int n;
    675670
    676     for (n = 8; n < partitions; n++) {
     671    for (n = 8; n < g_partitions; n++) {
    677672    if (!sgi_get_num_sectors(n)) {
    678673        /*
     
    682677         * sectors.
    683678         */
    684         if (heads * sectors * 5 < sgi_get_lastblock())
    685             sgi_set_partition(n, 0, heads * sectors * 5, SGI_VOLHDR);
     679        if (g_heads * g_sectors * 5 < sgi_get_lastblock())
     680            sgi_set_partition(n, 0, g_heads * g_sectors * 5, SGI_VOLHDR);
    686681            break;
    687682        }
     
    781776    printf(msg_building_new_label, "SGI disklabel");
    782777
    783     sgi_other_endian = (BYTE_ORDER == LITTLE_ENDIAN);
    784     res = ioctl(fd, BLKGETSIZE, &longsectors);
    785     if (!ioctl(fd, HDIO_GETGEO, &geometry)) {
    786         heads = geometry.heads;
    787         sectors = geometry.sectors;
     778    sgi_other_endian = BB_LITTLE_ENDIAN;
     779    res = ioctl(dev_fd, BLKGETSIZE, &longsectors);
     780    if (!ioctl(dev_fd, HDIO_GETGEO, &geometry)) {
     781        g_heads = geometry.heads;
     782        g_sectors = geometry.sectors;
    788783        if (res == 0) {
    789784            /* the get device size ioctl was successful */
    790             cylinders = longsectors / (heads * sectors);
    791             cylinders /= sec_fac;
     785            g_cylinders = longsectors / (g_heads * g_sectors);
     786            g_cylinders /= sec_fac;
    792787        } else {
    793788            /* otherwise print error and use truncated version */
    794             cylinders = geometry.cylinders;
     789            g_cylinders = geometry.cylinders;
    795790            printf(
    796 "Warning: BLKGETSIZE ioctl failed on %s.  Using geometry cylinder value of %d.\n"
    797 "This value may be truncated for devices > 33.8 GB.\n", disk_device, cylinders);
     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);
    798793        }
    799794    }
     
    805800                old[i].start = get_start_sect(get_part_table(i));
    806801                old[i].nsect = get_nr_sects(get_part_table(i));
    807                 printf("Trying to keep parameters of partition %d\n", i);
    808                 if (debug)
    809                     printf("ID=%02x\tSTART=%d\tLENGTH=%d\n",
     802                printf("Trying to keep parameters of partition %u\n", i);
     803                if (SGI_DEBUG)
     804                    printf("ID=%02x\tSTART=%u\tLENGTH=%u\n",
    810805                old[i].sysid, old[i].start, old[i].nsect);
    811806            }
     
    851846    //memset( &(sgilabel->directory), 0, sizeof(struct volume_directory)*15 );
    852847    //memset( &(sgilabel->partitions), 0, sizeof(struct sgi_partinfo)*16 );
    853     current_label_type = label_sgi;
    854     partitions = 16;
     848    current_label_type = LABEL_SGI;
     849    g_partitions = 16;
    855850    sgi_volumes = 15;
    856851    sgi_set_entire();
Note: See TracChangeset for help on using the changeset viewer.