Changeset 2725 in MondoRescue for branches/2.2.9/mindi-busybox/util-linux/fdisk_osf.c
- Timestamp:
- Feb 25, 2011, 9:26:54 PM (13 years ago)
- 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_LABEL2 1 /* 3 2 * Copyright (c) 1987, 1988 Regents of the University of California. … … 33 32 */ 34 33 34 #if ENABLE_FEATURE_OSF_LABEL 35 35 36 36 #ifndef BSD_DISKMAGIC … … 46 46 #if defined(i386) || defined(__sparc__) || defined(__arm__) \ 47 47 || 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 51 53 #elif defined(__alpha__) || defined(__powerpc__) || defined(__ia64__) \ 52 54 || 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 60 59 #endif 61 60 … … 68 67 int16_t d_subtype; /* controller/d_type specific */ 69 68 char d_typename[16]; /* type name, e.g. "eagle" */ 70 char d_packname[16]; 71 69 char d_packname[16]; /* pack identifier */ 70 /* disk geometry: */ 72 71 uint32_t d_secsize; /* # of bytes per sector */ 73 72 uint32_t d_nsectors; /* # of data sectors per track */ … … 90 89 uint32_t d_acylinders; /* # of alt. cylinders per unit */ 91 90 92 91 /* hardware characteristics: */ 93 92 /* 94 93 * d_interleave, d_trackskew and d_cylskew describe perturbations … … 120 119 uint32_t d_magic2; /* the magic number (again) */ 121 120 uint16_t d_checksum; /* xor of data incl. partitions */ 122 121 /* filesystem and partition information: */ 123 122 uint16_t d_npartitions; /* number of partitions in following */ 124 123 uint32_t d_bbsize; /* size of boot area at sn0, bytes */ 125 124 uint32_t d_sbsize; /* max size of fs superblock, bytes */ 126 struct xbsd_partition {/* the partition table */125 struct xbsd_partition { /* the partition table */ 127 126 uint32_t p_size; /* number of sectors in partition */ 128 127 uint32_t p_offset; /* starting sector */ … … 241 240 */ 242 241 243 static int possibly_osf_label;244 245 242 #define FREEBSD_PARTITION 0xa5 246 243 #define NETBSD_PARTITION 0xa9 … … 372 369 return; 373 370 } 374 printf("Reading disklabel of %s at sector % d\n",371 printf("Reading disklabel of %s at sector %u\n", 375 372 partname(disk_device, t+1, 0), ss + BSD_LABELSECTOR); 376 373 if (xbsd_readlabel(xbsd_part) == 0) … … 395 392 396 393 while (1) { 397 putchar('\n');394 bb_putchar('\n'); 398 395 switch (tolower(read_nonempty("BSD disklabel command (m for help): "))) { 399 396 case 'd': … … 416 413 break; 417 414 case 'q': 418 close(fd); 415 if (ENABLE_FEATURE_CLEAN_UP) 416 close_dev_fd(); 419 417 exit(EXIT_SUCCESS); 420 418 case 'r': … … 504 502 505 503 if (show_all) { 504 static const int d_masks[] = { BSD_D_REMOVABLE, BSD_D_ECC, BSD_D_BADSECT }; 505 506 506 #if defined(__alpha__) 507 507 printf("# %s:\n", disk_device); … … 512 512 printf("type: %s\n", xbsd_dktypenames[lp->d_type]); 513 513 else 514 printf("type: % d\n", lp->d_type);514 printf("type: %u\n", lp->d_type); 515 515 printf("disk: %.*s\n", (int) sizeof(lp->d_typename), lp->d_typename); 516 516 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'); 525 520 /* On various machines the fields of *lp are short/int/long */ 526 521 /* In order to avoid problems, we cast them all to long. */ 527 printf("bytes/sector: %l d\n", (long) lp->d_secsize);528 printf("sectors/track: %l d\n", (long) lp->d_nsectors);529 printf("tracks/cylinder: %l d\n", (long) lp->d_ntracks);530 printf("sectors/cylinder: %l d\n", (long) lp->d_secpercyl);531 printf("cylinders: %l d\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: %l d\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", 537 532 (long) lp->d_headswitch); 538 printf("track-to-track seek: %l d\t# milliseconds\n",533 printf("track-to-track seek: %lu\t# milliseconds\n", 539 534 (long) lp->d_trkseek); 540 535 printf("drivedata: "); … … 545 540 i = 0; 546 541 for (j = 0; j <= i; j++) 547 printf("%l d", (long) lp->d_drivedata[j]);548 } 549 printf("\n% dpartitions:\n", lp->d_npartitions);542 printf("%lu ", (long) lp->d_drivedata[j]); 543 } 544 printf("\n%u partitions:\n", lp->d_npartitions); 550 545 printf("# start end size fstype [fsize bsize cpg]\n"); 551 546 pp = lp->d_partitions; … … 553 548 if (pp->p_size) { 554 549 if (display_in_cyl_units && lp->d_secpercyl) { 555 printf(" %c: %8l d%c %8ld%c %8ld%c ",550 printf(" %c: %8lu%c %8lu%c %8lu%c ", 556 551 'a' + i, 557 ( long) pp->p_offset / lp->d_secpercyl + 1,552 (unsigned long) pp->p_offset / lp->d_secpercyl + 1, 558 553 (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, 560 555 ((pp->p_offset + pp->p_size) % lp->d_secpercyl) ? '*' : ' ', 561 556 (long) pp->p_size / lp->d_secpercyl, … … 563 558 ); 564 559 } else { 565 printf(" %c: %8l d %8ld %8ld",560 printf(" %c: %8lu %8lu %8lu ", 566 561 'a' + i, 567 562 (long) pp->p_offset, … … 578 573 switch (pp->p_fstype) { 579 574 case BSD_FS_UNUSED: 580 printf(" %5l d %5ld%5.5s ",575 printf(" %5lu %5lu %5.5s ", 581 576 (long) pp->p_fsize, (long) pp->p_fsize * pp->p_frag, ""); 582 577 break; 583 578 case BSD_FS_BSDFFS: 584 printf(" %5l d %5ld %5d",579 printf(" %5lu %5lu %5u ", 585 580 (long) pp->p_fsize, (long) pp->p_fsize * pp->p_frag, pp->p_cpg); 586 581 break; … … 589 584 break; 590 585 } 591 puts("");586 bb_putchar('\n'); 592 587 } 593 588 } … … 622 617 while (1) { 623 618 c = read_nonempty("Do you want to create a disklabel? (y/n) "); 624 if ( c == 'y' || c == 'Y') {619 if ((c|0x20) == 'y') { 625 620 if (xbsd_initlabel( 626 621 #if defined(__alpha__) || defined(__powerpc__) || defined(__hppa__) || \ … … 630 625 xbsd_part 631 626 #endif 632 627 ) == 1) { 633 628 xbsd_print_disklabel(1); 634 629 return 1; 635 } else 636 return 0; 637 } else if (c == 'n') 630 } 638 631 return 0; 632 } 633 if ((c|0x20) == 'n') 634 return 0; 639 635 } 640 636 } … … 643 639 edit_int(int def, const char *mesg) 644 640 { 645 mesg = xasprintf("%s (% d): ", mesg, def);641 mesg = xasprintf("%s (%u): ", mesg, def); 646 642 do { 647 643 if (!read_line(mesg)) … … 692 688 int fdb; 693 689 694 fdb = open (path, O_RDONLY);690 fdb = open_or_warn(path, O_RDONLY); 695 691 if (fdb < 0) { 696 perror(path);697 692 return 0; 698 693 } 699 if ( read(fdb, ptr, size) < 0) {700 perror(path);694 if (full_read(fdb, ptr, size) < 0) { 695 bb_simple_perror_msg(path); 701 696 close(fdb); 702 697 return 0; … … 769 764 #endif 770 765 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); 775 768 776 769 #if defined(__alpha__) … … 877 870 #endif 878 871 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 */ 883 876 if (d->d_secpercyl == 0) 884 877 d->d_secpercyl = 1; /* avoid segfaults */ … … 942 935 #endif 943 936 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)) 947 939 fdisk_fatal(unable_to_read); 948 940 … … 960 952 961 953 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", 963 955 d->d_npartitions, BSD_MAXPARTITIONS); 964 956 return 1; … … 974 966 sector = get_start_sect(p) + BSD_LABELSECTOR; 975 967 #else 968 (void)p; /* silence warning */ 976 969 sector = BSD_LABELSECTOR; 977 970 #endif … … 988 981 #if defined(__alpha__) && BSD_LABELSECTOR == 0 989 982 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)); 999 989 #endif 1000 990 sync_disks(); … … 1028 1018 struct partition *p; 1029 1019 1030 k = get_partition(1, partitions);1020 k = get_partition(1, g_partitions); 1031 1021 1032 1022 if (!xbsd_check_new_partition(&i))
Note:
See TracChangeset
for help on using the changeset viewer.