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_osf.c

    r1765 r2725  
    1 #if ENABLE_FEATURE_OSF_LABEL
    21/*
    32 * Copyright (c) 1987, 1988 Regents of the University of California.
     
    3332 */
    3433
     34#if ENABLE_FEATURE_OSF_LABEL
    3535
    3636#ifndef BSD_DISKMAGIC
     
    4646#if defined(i386) || defined(__sparc__) || defined(__arm__) \
    4747 || defined(__m68k__) || defined(__mips__) || defined(__s390__) \
    48  || defined(__sh__) || defined(__x86_64__)
    49 #define BSD_LABELSECTOR   1
    50 #define BSD_LABELOFFSET   0
     48 || defined(__s390__) || defined(__s390x__) \
     49 || defined(__sh__) || defined(__x86_64__) || defined(__avr32__) \
     50 || defined(__nds32__)
     51# define BSD_LABELSECTOR   1
     52# define BSD_LABELOFFSET   0
    5153#elif defined(__alpha__) || defined(__powerpc__) || defined(__ia64__) \
    5254 || defined(__hppa__)
    53 #define BSD_LABELSECTOR   0
    54 #define BSD_LABELOFFSET   64
    55 #elif defined(__s390__) || defined(__s390x__)
    56 #define BSD_LABELSECTOR   1
    57 #define BSD_LABELOFFSET   0
    58 #else
    59 #error unknown architecture
     55# define BSD_LABELSECTOR   0
     56# define BSD_LABELOFFSET   64
     57#else
     58# error unknown architecture
    6059#endif
    6160
     
    6867    int16_t    d_subtype;              /* controller/d_type specific */
    6968    char       d_typename[16];         /* type name, e.g. "eagle" */
    70     char       d_packname[16];                 /* pack identifier */
    71             /* disk geometry: */
     69    char       d_packname[16];         /* pack identifier */
     70    /* disk geometry: */
    7271    uint32_t   d_secsize;              /* # of bytes per sector */
    7372    uint32_t   d_nsectors;             /* # of data sectors per track */
     
    9089    uint32_t   d_acylinders;           /* # of alt. cylinders per unit */
    9190
    92             /* hardware characteristics: */
     91    /* hardware characteristics: */
    9392    /*
    9493     * d_interleave, d_trackskew and d_cylskew describe perturbations
     
    120119    uint32_t   d_magic2;               /* the magic number (again) */
    121120    uint16_t   d_checksum;             /* xor of data incl. partitions */
    122             /* filesystem and partition information: */
     121    /* filesystem and partition information: */
    123122    uint16_t   d_npartitions;          /* number of partitions in following */
    124123    uint32_t   d_bbsize;               /* size of boot area at sn0, bytes */
    125124    uint32_t   d_sbsize;               /* max size of fs superblock, bytes */
    126     struct xbsd_partition    {      /* the partition table */
     125    struct xbsd_partition { /* the partition table */
    127126        uint32_t   p_size;         /* number of sectors in partition */
    128127        uint32_t   p_offset;       /* starting sector */
     
    241240*/
    242241
    243 static int possibly_osf_label;
    244 
    245242#define FREEBSD_PARTITION       0xa5
    246243#define NETBSD_PARTITION        0xa9
     
    372369                return;
    373370            }
    374                 printf("Reading disklabel of %s at sector %d\n",
     371                printf("Reading disklabel of %s at sector %u\n",
    375372                    partname(disk_device, t+1, 0), ss + BSD_LABELSECTOR);
    376373            if (xbsd_readlabel(xbsd_part) == 0)
     
    395392
    396393    while (1) {
    397         putchar('\n');
     394        bb_putchar('\n');
    398395        switch (tolower(read_nonempty("BSD disklabel command (m for help): "))) {
    399396        case 'd':
     
    416413            break;
    417414        case 'q':
    418             close(fd);
     415            if (ENABLE_FEATURE_CLEAN_UP)
     416                close_dev_fd();
    419417            exit(EXIT_SUCCESS);
    420418        case 'r':
     
    504502
    505503    if (show_all) {
     504        static const int d_masks[] = { BSD_D_REMOVABLE, BSD_D_ECC, BSD_D_BADSECT };
     505
    506506#if defined(__alpha__)
    507507        printf("# %s:\n", disk_device);
     
    512512            printf("type: %s\n", xbsd_dktypenames[lp->d_type]);
    513513        else
    514             printf("type: %d\n", lp->d_type);
     514            printf("type: %u\n", lp->d_type);
    515515        printf("disk: %.*s\n", (int) sizeof(lp->d_typename), lp->d_typename);
    516516        printf("label: %.*s\n", (int) sizeof(lp->d_packname), lp->d_packname);
    517         printf("flags:");
    518         if (lp->d_flags & BSD_D_REMOVABLE)
    519             printf(" removable");
    520         if (lp->d_flags & BSD_D_ECC)
    521             printf(" ecc");
    522         if (lp->d_flags & BSD_D_BADSECT)
    523             printf(" badsect");
    524         puts("");
     517        printf("flags: ");
     518        print_flags_separated(d_masks, "removable\0""ecc\0""badsect\0", lp->d_flags, " ");
     519        bb_putchar('\n');
    525520        /* On various machines the fields of *lp are short/int/long */
    526521        /* In order to avoid problems, we cast them all to long. */
    527         printf("bytes/sector: %ld\n", (long) lp->d_secsize);
    528         printf("sectors/track: %ld\n", (long) lp->d_nsectors);
    529         printf("tracks/cylinder: %ld\n", (long) lp->d_ntracks);
    530         printf("sectors/cylinder: %ld\n", (long) lp->d_secpercyl);
    531         printf("cylinders: %ld\n", (long) lp->d_ncylinders);
    532         printf("rpm: %d\n", lp->d_rpm);
    533         printf("interleave: %d\n", lp->d_interleave);
    534         printf("trackskew: %d\n", lp->d_trackskew);
    535         printf("cylinderskew: %d\n", lp->d_cylskew);
    536         printf("headswitch: %ld\t\t# milliseconds\n",
     522        printf("bytes/sector: %lu\n", (long) lp->d_secsize);
     523        printf("sectors/track: %lu\n", (long) lp->d_nsectors);
     524        printf("tracks/cylinder: %lu\n", (long) lp->d_ntracks);
     525        printf("sectors/cylinder: %lu\n", (long) lp->d_secpercyl);
     526        printf("cylinders: %lu\n", (long) lp->d_ncylinders);
     527        printf("rpm: %u\n", lp->d_rpm);
     528        printf("interleave: %u\n", lp->d_interleave);
     529        printf("trackskew: %u\n", lp->d_trackskew);
     530        printf("cylinderskew: %u\n", lp->d_cylskew);
     531        printf("headswitch: %lu\t\t# milliseconds\n",
    537532            (long) lp->d_headswitch);
    538         printf("track-to-track seek: %ld\t# milliseconds\n",
     533        printf("track-to-track seek: %lu\t# milliseconds\n",
    539534            (long) lp->d_trkseek);
    540535        printf("drivedata: ");
     
    545540            i = 0;
    546541        for (j = 0; j <= i; j++)
    547             printf("%ld ", (long) lp->d_drivedata[j]);
    548     }
    549     printf("\n%d partitions:\n", lp->d_npartitions);
     542            printf("%lu ", (long) lp->d_drivedata[j]);
     543    }
     544    printf("\n%u partitions:\n", lp->d_npartitions);
    550545    printf("#       start       end      size     fstype   [fsize bsize   cpg]\n");
    551546    pp = lp->d_partitions;
     
    553548        if (pp->p_size) {
    554549            if (display_in_cyl_units && lp->d_secpercyl) {
    555                 printf("  %c: %8ld%c %8ld%c %8ld%c  ",
     550                printf("  %c: %8lu%c %8lu%c %8lu%c  ",
    556551                    'a' + i,
    557                     (long) pp->p_offset / lp->d_secpercyl + 1,
     552                    (unsigned long) pp->p_offset / lp->d_secpercyl + 1,
    558553                    (pp->p_offset % lp->d_secpercyl) ? '*' : ' ',
    559                     (long) (pp->p_offset + pp->p_size + lp->d_secpercyl - 1) / lp->d_secpercyl,
     554                    (unsigned long) (pp->p_offset + pp->p_size + lp->d_secpercyl - 1) / lp->d_secpercyl,
    560555                    ((pp->p_offset + pp->p_size) % lp->d_secpercyl) ? '*' : ' ',
    561556                    (long) pp->p_size / lp->d_secpercyl,
     
    563558                );
    564559            } else {
    565                 printf("  %c: %8ld  %8ld  %8ld   ",
     560                printf("  %c: %8lu  %8lu  %8lu   ",
    566561                    'a' + i,
    567562                    (long) pp->p_offset,
     
    578573            switch (pp->p_fstype) {
    579574            case BSD_FS_UNUSED:
    580                 printf("    %5ld %5ld %5.5s ",
     575                printf("    %5lu %5lu %5.5s ",
    581576                    (long) pp->p_fsize, (long) pp->p_fsize * pp->p_frag, "");
    582577                break;
    583578            case BSD_FS_BSDFFS:
    584                 printf("    %5ld %5ld %5d ",
     579                printf("    %5lu %5lu %5u ",
    585580                    (long) pp->p_fsize, (long) pp->p_fsize * pp->p_frag, pp->p_cpg);
    586581                break;
     
    589584                break;
    590585            }
    591             puts("");
     586            bb_putchar('\n');
    592587        }
    593588    }
     
    622617    while (1) {
    623618        c = read_nonempty("Do you want to create a disklabel? (y/n) ");
    624         if (c == 'y' || c == 'Y') {
     619        if ((c|0x20) == 'y') {
    625620            if (xbsd_initlabel(
    626621#if defined(__alpha__) || defined(__powerpc__) || defined(__hppa__) || \
     
    630625                xbsd_part
    631626#endif
    632                 ) == 1) {
     627            ) == 1) {
    633628                xbsd_print_disklabel(1);
    634629                return 1;
    635             } else
    636                 return 0;
    637         } else if (c == 'n')
     630            }
    638631            return 0;
     632        }
     633        if ((c|0x20) == 'n')
     634            return 0;
    639635    }
    640636}
     
    643639edit_int(int def, const char *mesg)
    644640{
    645     mesg = xasprintf("%s (%d): ", mesg, def);
     641    mesg = xasprintf("%s (%u): ", mesg, def);
    646642    do {
    647643        if (!read_line(mesg))
     
    692688    int fdb;
    693689
    694     fdb = open(path, O_RDONLY);
     690    fdb = open_or_warn(path, O_RDONLY);
    695691    if (fdb < 0) {
    696         perror(path);
    697692        return 0;
    698693    }
    699     if (read(fdb, ptr, size) < 0) {
    700         perror(path);
     694    if (full_read(fdb, ptr, size) < 0) {
     695        bb_simple_perror_msg(path);
    701696        close(fdb);
    702697        return 0;
     
    769764#endif
    770765
    771     if (lseek(fd, sector * SECTOR_SIZE, SEEK_SET) == -1)
    772         fdisk_fatal(unable_to_seek);
    773     if (BSD_BBSIZE != write(fd, disklabelbuffer, BSD_BBSIZE))
    774         fdisk_fatal(unable_to_write);
     766    seek_sector(sector);
     767    xwrite(dev_fd, disklabelbuffer, BSD_BBSIZE);
    775768
    776769#if defined(__alpha__)
     
    877870#endif
    878871    d->d_secsize = SECTOR_SIZE;           /* bytes/sector  */
    879     d->d_nsectors = sectors;              /* sectors/track */
    880     d->d_ntracks = heads;                 /* tracks/cylinder (heads) */
    881     d->d_ncylinders = cylinders;
    882     d->d_secpercyl  = sectors * heads;    /* sectors/cylinder */
     872    d->d_nsectors = g_sectors;            /* sectors/track */
     873    d->d_ntracks = g_heads;               /* tracks/cylinder (heads) */
     874    d->d_ncylinders = g_cylinders;
     875    d->d_secpercyl  = g_sectors * g_heads;/* sectors/cylinder */
    883876    if (d->d_secpercyl == 0)
    884877        d->d_secpercyl = 1;           /* avoid segfaults */
     
    942935#endif
    943936
    944     if (lseek(fd, sector * SECTOR_SIZE, SEEK_SET) == -1)
    945         fdisk_fatal(unable_to_seek);
    946     if (BSD_BBSIZE != read(fd, disklabelbuffer, BSD_BBSIZE))
     937    seek_sector(sector);
     938    if (BSD_BBSIZE != full_read(dev_fd, disklabelbuffer, BSD_BBSIZE))
    947939        fdisk_fatal(unable_to_read);
    948940
     
    960952
    961953    if (d->d_npartitions > BSD_MAXPARTITIONS)
    962         printf("Warning: too many partitions (%d, maximum is %d)\n",
     954        printf("Warning: too many partitions (%u, maximum is %u)\n",
    963955            d->d_npartitions, BSD_MAXPARTITIONS);
    964956    return 1;
     
    974966    sector = get_start_sect(p) + BSD_LABELSECTOR;
    975967#else
     968    (void)p; /* silence warning */
    976969    sector = BSD_LABELSECTOR;
    977970#endif
     
    988981#if defined(__alpha__) && BSD_LABELSECTOR == 0
    989982    alpha_bootblock_checksum(disklabelbuffer);
    990     if (lseek(fd, 0, SEEK_SET) == -1)
    991         fdisk_fatal(unable_to_seek);
    992     if (BSD_BBSIZE != write(fd, disklabelbuffer, BSD_BBSIZE))
    993         fdisk_fatal(unable_to_write);
    994 #else
    995     if (lseek(fd, sector * SECTOR_SIZE + BSD_LABELOFFSET, SEEK_SET) == -1)
    996         fdisk_fatal(unable_to_seek);
    997     if (sizeof(struct xbsd_disklabel) != write(fd, d, sizeof(struct xbsd_disklabel)))
    998         fdisk_fatal(unable_to_write);
     983    seek_sector(0);
     984    xwrite(dev_fd, disklabelbuffer, BSD_BBSIZE);
     985#else
     986    seek_sector(sector);
     987    lseek(dev_fd, BSD_LABELOFFSET, SEEK_CUR);
     988    xwrite(dev_fd, d, sizeof(*d));
    999989#endif
    1000990    sync_disks();
     
    10281018    struct partition *p;
    10291019
    1030     k = get_partition(1, partitions);
     1020    k = get_partition(1, g_partitions);
    10311021
    10321022    if (!xbsd_check_new_partition(&i))
Note: See TracChangeset for help on using the changeset viewer.