diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-12-19 20:32:02 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-12-19 20:32:02 +0000 |
commit | 28703015ab71784f40bc97f720ed900e26bd03ca (patch) | |
tree | ff0f9a21d1822c9a2f35819db4156d9555f56116 /util-linux/fdisk_osf.c | |
parent | f58906b6463436f6a19f72d43c3ab4ba69d79104 (diff) | |
download | busybox-w32-28703015ab71784f40bc97f720ed900e26bd03ca.tar.gz busybox-w32-28703015ab71784f40bc97f720ed900e26bd03ca.tar.bz2 busybox-w32-28703015ab71784f40bc97f720ed900e26bd03ca.zip |
u_short, ulong exterminated
fdiskXXX: add a bit of sanity (not enough by far)
Diffstat (limited to 'util-linux/fdisk_osf.c')
-rw-r--r-- | util-linux/fdisk_osf.c | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/util-linux/fdisk_osf.c b/util-linux/fdisk_osf.c index bff2371e4..3d654d392 100644 --- a/util-linux/fdisk_osf.c +++ b/util-linux/fdisk_osf.c | |||
@@ -253,7 +253,7 @@ static void xbsd_change_fstype(void); | |||
253 | static int xbsd_get_part_index(int max); | 253 | static int xbsd_get_part_index(int max); |
254 | static int xbsd_check_new_partition(int *i); | 254 | static int xbsd_check_new_partition(int *i); |
255 | static void xbsd_list_types(void); | 255 | static void xbsd_list_types(void); |
256 | static u_short xbsd_dkcksum(struct xbsd_disklabel *lp); | 256 | static uint16_t xbsd_dkcksum(struct xbsd_disklabel *lp); |
257 | static int xbsd_initlabel(struct partition *p, struct xbsd_disklabel *d); | 257 | static int xbsd_initlabel(struct partition *p, struct xbsd_disklabel *d); |
258 | static int xbsd_readlabel(struct partition *p, struct xbsd_disklabel *d); | 258 | static int xbsd_readlabel(struct partition *p, struct xbsd_disklabel *d); |
259 | static int xbsd_writelabel(struct partition *p, struct xbsd_disklabel *d); | 259 | static int xbsd_writelabel(struct partition *p, struct xbsd_disklabel *d); |
@@ -650,37 +650,38 @@ xbsd_edit_disklabel(void) | |||
650 | d = &xbsd_dlabel; | 650 | d = &xbsd_dlabel; |
651 | 651 | ||
652 | #if defined (__alpha__) || defined (__ia64__) | 652 | #if defined (__alpha__) || defined (__ia64__) |
653 | d->d_secsize = (u_long) edit_int((u_long) d->d_secsize ,_("bytes/sector")); | 653 | d->d_secsize = edit_int(d->d_secsize ,_("bytes/sector")); |
654 | d->d_nsectors = (u_long) edit_int((u_long) d->d_nsectors ,_("sectors/track")); | 654 | d->d_nsectors = edit_int(d->d_nsectors ,_("sectors/track")); |
655 | d->d_ntracks = (u_long) edit_int((u_long) d->d_ntracks ,_("tracks/cylinder")); | 655 | d->d_ntracks = edit_int(d->d_ntracks ,_("tracks/cylinder")); |
656 | d->d_ncylinders = (u_long) edit_int((u_long) d->d_ncylinders ,_("cylinders")); | 656 | d->d_ncylinders = edit_int(d->d_ncylinders ,_("cylinders")); |
657 | #endif | 657 | #endif |
658 | 658 | ||
659 | /* d->d_secpercyl can be != d->d_nsectors * d->d_ntracks */ | 659 | /* d->d_secpercyl can be != d->d_nsectors * d->d_ntracks */ |
660 | while (1) { | 660 | while (1) { |
661 | d->d_secpercyl = (u_long) edit_int((u_long) d->d_nsectors * d->d_ntracks, | 661 | d->d_secpercyl = edit_int(d->d_nsectors * d->d_ntracks, |
662 | _("sectors/cylinder")); | 662 | _("sectors/cylinder")); |
663 | if (d->d_secpercyl <= d->d_nsectors * d->d_ntracks) | 663 | if (d->d_secpercyl <= d->d_nsectors * d->d_ntracks) |
664 | break; | 664 | break; |
665 | 665 | ||
666 | printf(_("Must be <= sectors/track * tracks/cylinder (default).\n")); | 666 | printf(_("Must be <= sectors/track * tracks/cylinder (default).\n")); |
667 | } | 667 | } |
668 | d->d_rpm = (u_short) edit_int((u_short) d->d_rpm ,_("rpm")); | 668 | d->d_rpm = edit_int(d->d_rpm ,_("rpm")); |
669 | d->d_interleave = (u_short) edit_int((u_short) d->d_interleave,_("interleave")); | 669 | d->d_interleave = edit_int(d->d_interleave,_("interleave")); |
670 | d->d_trackskew = (u_short) edit_int((u_short) d->d_trackskew ,_("trackskew")); | 670 | d->d_trackskew = edit_int(d->d_trackskew ,_("trackskew")); |
671 | d->d_cylskew = (u_short) edit_int((u_short) d->d_cylskew ,_("cylinderskew")); | 671 | d->d_cylskew = edit_int(d->d_cylskew ,_("cylinderskew")); |
672 | d->d_headswitch = (u_long) edit_int((u_long) d->d_headswitch ,_("headswitch")); | 672 | d->d_headswitch = edit_int(d->d_headswitch,_("headswitch")); |
673 | d->d_trkseek = (u_long) edit_int((u_long) d->d_trkseek ,_("track-to-track seek")); | 673 | d->d_trkseek = edit_int(d->d_trkseek ,_("track-to-track seek")); |
674 | 674 | ||
675 | d->d_secperunit = d->d_secpercyl * d->d_ncylinders; | 675 | d->d_secperunit = d->d_secpercyl * d->d_ncylinders; |
676 | } | 676 | } |
677 | 677 | ||
678 | static int | 678 | static int |
679 | xbsd_get_bootstrap (char *path, void *ptr, int size) | 679 | xbsd_get_bootstrap(char *path, void *ptr, int size) |
680 | { | 680 | { |
681 | int fdb; | 681 | int fdb; |
682 | 682 | ||
683 | if ((fdb = open (path, O_RDONLY)) < 0) { | 683 | fdb = open(path, O_RDONLY); |
684 | if (fdb < 0) { | ||
684 | perror(path); | 685 | perror(path); |
685 | return 0; | 686 | return 0; |
686 | } | 687 | } |
@@ -736,7 +737,7 @@ xbsd_write_bootstrap(void) | |||
736 | 737 | ||
737 | snprintf(path, sizeof(path), "%s/boot%s", bootdir, dkbasename); | 738 | snprintf(path, sizeof(path), "%s/boot%s", bootdir, dkbasename); |
738 | if (!xbsd_get_bootstrap(path, &disklabelbuffer[xbsd_dlabel.d_secsize], | 739 | if (!xbsd_get_bootstrap(path, &disklabelbuffer[xbsd_dlabel.d_secsize], |
739 | (int) xbsd_dlabel.d_bbsize - xbsd_dlabel.d_secsize)) | 740 | (int) xbsd_dlabel.d_bbsize - xbsd_dlabel.d_secsize)) |
740 | return; | 741 | return; |
741 | 742 | ||
742 | e = d + sizeof(struct xbsd_disklabel); | 743 | e = d + sizeof(struct xbsd_disklabel); |
@@ -748,9 +749,9 @@ xbsd_write_bootstrap(void) | |||
748 | 749 | ||
749 | memmove(d, &dl, sizeof(struct xbsd_disklabel)); | 750 | memmove(d, &dl, sizeof(struct xbsd_disklabel)); |
750 | 751 | ||
751 | #if defined (__powerpc__) || defined (__hppa__) | 752 | #if defined(__powerpc__) || defined(__hppa__) |
752 | sector = 0; | 753 | sector = 0; |
753 | #elif defined (__alpha__) | 754 | #elif defined(__alpha__) |
754 | sector = 0; | 755 | sector = 0; |
755 | alpha_bootblock_checksum(disklabelbuffer); | 756 | alpha_bootblock_checksum(disklabelbuffer); |
756 | #else | 757 | #else |
@@ -762,11 +763,11 @@ xbsd_write_bootstrap(void) | |||
762 | if (BSD_BBSIZE != write(fd, disklabelbuffer, BSD_BBSIZE)) | 763 | if (BSD_BBSIZE != write(fd, disklabelbuffer, BSD_BBSIZE)) |
763 | fdisk_fatal(unable_to_write); | 764 | fdisk_fatal(unable_to_write); |
764 | 765 | ||
765 | #if defined (__alpha__) | 766 | #if defined(__alpha__) |
766 | printf(_("Bootstrap installed on %s.\n"), disk_device); | 767 | printf(_("Bootstrap installed on %s.\n"), disk_device); |
767 | #else | 768 | #else |
768 | printf(_("Bootstrap installed on %s.\n"), | 769 | printf(_("Bootstrap installed on %s.\n"), |
769 | partname (disk_device, xbsd_part_index+1, 0)); | 770 | partname(disk_device, xbsd_part_index+1, 0)); |
770 | #endif | 771 | #endif |
771 | 772 | ||
772 | sync_disks(); | 773 | sync_disks(); |
@@ -812,7 +813,7 @@ xbsd_check_new_partition(int *i) | |||
812 | } | 813 | } |
813 | } | 814 | } |
814 | 815 | ||
815 | *i = xbsd_get_part_index (BSD_MAXPARTITIONS); | 816 | *i = xbsd_get_part_index(BSD_MAXPARTITIONS); |
816 | 817 | ||
817 | if (*i >= xbsd_dlabel.d_npartitions) | 818 | if (*i >= xbsd_dlabel.d_npartitions) |
818 | xbsd_dlabel.d_npartitions = (*i) + 1; | 819 | xbsd_dlabel.d_npartitions = (*i) + 1; |
@@ -831,14 +832,14 @@ xbsd_list_types(void) | |||
831 | list_types(xbsd_fstypes); | 832 | list_types(xbsd_fstypes); |
832 | } | 833 | } |
833 | 834 | ||
834 | static u_short | 835 | static uint16_t |
835 | xbsd_dkcksum(struct xbsd_disklabel *lp) | 836 | xbsd_dkcksum(struct xbsd_disklabel *lp) |
836 | { | 837 | { |
837 | u_short *start, *end; | 838 | uint16_t *start, *end; |
838 | u_short sum = 0; | 839 | uint16_t sum = 0; |
839 | 840 | ||
840 | start = (u_short *) lp; | 841 | start = (uint16_t *) lp; |
841 | end = (u_short *) &lp->d_partitions[lp->d_npartitions]; | 842 | end = (uint16_t *) &lp->d_partitions[lp->d_npartitions]; |
842 | while (start < end) | 843 | while (start < end) |
843 | sum ^= *start++; | 844 | sum ^= *start++; |
844 | return sum; | 845 | return sum; |