diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-07-09 21:20:50 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-07-09 21:20:50 +0000 |
commit | 9764d6908a9e613f9192e0a3e642e1b0017e521d (patch) | |
tree | e6957e352c843d756b8e0af379b7beaa69a6af86 | |
parent | 6bdff08e6c048106de55998908af7c2f139b10a0 (diff) | |
download | busybox-w32-9764d6908a9e613f9192e0a3e642e1b0017e521d.tar.gz busybox-w32-9764d6908a9e613f9192e0a3e642e1b0017e521d.tar.bz2 busybox-w32-9764d6908a9e613f9192e0a3e642e1b0017e521d.zip |
fdisk: fix compile failure
-rw-r--r-- | util-linux/fdisk.c | 79 |
1 files changed, 41 insertions, 38 deletions
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c index b44a2b425..eeef18e2f 100644 --- a/util-linux/fdisk.c +++ b/util-linux/fdisk.c | |||
@@ -75,7 +75,7 @@ struct partition { | |||
75 | unsigned char head; /* starting head */ | 75 | unsigned char head; /* starting head */ |
76 | unsigned char sector; /* starting sector */ | 76 | unsigned char sector; /* starting sector */ |
77 | unsigned char cyl; /* starting cylinder */ | 77 | unsigned char cyl; /* starting cylinder */ |
78 | unsigned char sys_ind; /* What partition type */ | 78 | unsigned char sys_ind; /* what partition type */ |
79 | unsigned char end_head; /* end head */ | 79 | unsigned char end_head; /* end head */ |
80 | unsigned char end_sector; /* end sector */ | 80 | unsigned char end_sector; /* end sector */ |
81 | unsigned char end_cyl; /* end cylinder */ | 81 | unsigned char end_cyl; /* end cylinder */ |
@@ -86,7 +86,6 @@ struct partition { | |||
86 | static const char unable_to_open[] ALIGN1 = "cannot open %s"; | 86 | static const char unable_to_open[] ALIGN1 = "cannot open %s"; |
87 | static const char unable_to_read[] ALIGN1 = "cannot read from %s"; | 87 | static const char unable_to_read[] ALIGN1 = "cannot read from %s"; |
88 | static const char unable_to_seek[] ALIGN1 = "cannot seek on %s"; | 88 | static const char unable_to_seek[] ALIGN1 = "cannot seek on %s"; |
89 | static void fdisk_fatal(const char *why) NORETURN; | ||
90 | 89 | ||
91 | enum label_type { | 90 | enum label_type { |
92 | LABEL_DOS, LABEL_SUN, LABEL_SGI, LABEL_AIX, LABEL_OSF | 91 | LABEL_DOS, LABEL_SUN, LABEL_SGI, LABEL_AIX, LABEL_OSF |
@@ -518,7 +517,8 @@ write_part_table_flag(char *b) | |||
518 | static char | 517 | static char |
519 | read_nonempty(const char *mesg) | 518 | read_nonempty(const char *mesg) |
520 | { | 519 | { |
521 | while (!read_line(mesg)) /* repeat */; | 520 | while (!read_line(mesg)) |
521 | continue; | ||
522 | return *line_ptr; | 522 | return *line_ptr; |
523 | } | 523 | } |
524 | 524 | ||
@@ -552,6 +552,41 @@ read_hex(const char *const *sys) | |||
552 | } | 552 | } |
553 | #endif /* FEATURE_FDISK_WRITABLE */ | 553 | #endif /* FEATURE_FDISK_WRITABLE */ |
554 | 554 | ||
555 | static void fdisk_fatal(const char *why) | ||
556 | { | ||
557 | if (listing) { | ||
558 | close_dev_fd(); | ||
559 | longjmp(listingbuf, 1); | ||
560 | } | ||
561 | bb_error_msg_and_die(why, disk_device); | ||
562 | } | ||
563 | |||
564 | static void | ||
565 | seek_sector(ullong secno) | ||
566 | { | ||
567 | secno *= sector_size; | ||
568 | #if ENABLE_FDISK_SUPPORT_LARGE_DISKS | ||
569 | if (lseek64(dev_fd, (off64_t)secno, SEEK_SET) == (off64_t) -1) | ||
570 | fdisk_fatal(unable_to_seek); | ||
571 | #else | ||
572 | if (secno > MAXINT(off_t) | ||
573 | || lseek(dev_fd, (off_t)secno, SEEK_SET) == (off_t) -1 | ||
574 | ) { | ||
575 | fdisk_fatal(unable_to_seek); | ||
576 | } | ||
577 | #endif | ||
578 | } | ||
579 | |||
580 | #if ENABLE_FEATURE_FDISK_WRITABLE | ||
581 | static void | ||
582 | write_sector(ullong secno, const void *buf) | ||
583 | { | ||
584 | seek_sector(secno); | ||
585 | xwrite(dev_fd, buf, sector_size); | ||
586 | } | ||
587 | #endif | ||
588 | |||
589 | |||
555 | #include "fdisk_aix.c" | 590 | #include "fdisk_aix.c" |
556 | 591 | ||
557 | typedef struct { | 592 | typedef struct { |
@@ -640,6 +675,7 @@ STATIC_SUN void verify_sun(void); | |||
640 | STATIC_SUN void sun_write_table(void); | 675 | STATIC_SUN void sun_write_table(void); |
641 | #include "fdisk_sun.c" | 676 | #include "fdisk_sun.c" |
642 | 677 | ||
678 | |||
643 | #if ENABLE_FEATURE_FDISK_WRITABLE | 679 | #if ENABLE_FEATURE_FDISK_WRITABLE |
644 | /* start_sect and nr_sects are stored little endian on all machines */ | 680 | /* start_sect and nr_sects are stored little endian on all machines */ |
645 | /* moreover, they are not aligned correctly */ | 681 | /* moreover, they are not aligned correctly */ |
@@ -687,40 +723,6 @@ get_nr_sects(const struct partition *p) | |||
687 | return read4_little_endian(p->size4); | 723 | return read4_little_endian(p->size4); |
688 | } | 724 | } |
689 | 725 | ||
690 | static void fdisk_fatal(const char *why) | ||
691 | { | ||
692 | if (listing) { | ||
693 | close_dev_fd(); | ||
694 | longjmp(listingbuf, 1); | ||
695 | } | ||
696 | bb_error_msg_and_die(why, disk_device); | ||
697 | } | ||
698 | |||
699 | static void | ||
700 | seek_sector(ullong secno) | ||
701 | { | ||
702 | secno *= sector_size; | ||
703 | #if ENABLE_FDISK_SUPPORT_LARGE_DISKS | ||
704 | if (lseek64(dev_fd, (off64_t)secno, SEEK_SET) == (off64_t) -1) | ||
705 | fdisk_fatal(unable_to_seek); | ||
706 | #else | ||
707 | if (secno > MAXINT(off_t) | ||
708 | || lseek(dev_fd, (off_t)secno, SEEK_SET) == (off_t) -1 | ||
709 | ) { | ||
710 | fdisk_fatal(unable_to_seek); | ||
711 | } | ||
712 | #endif | ||
713 | } | ||
714 | |||
715 | #if ENABLE_FEATURE_FDISK_WRITABLE | ||
716 | static void | ||
717 | write_sector(ullong secno, char *buf) | ||
718 | { | ||
719 | seek_sector(secno); | ||
720 | xwrite(dev_fd, buf, sector_size); | ||
721 | } | ||
722 | #endif | ||
723 | |||
724 | /* Allocate a buffer and read a partition table sector */ | 726 | /* Allocate a buffer and read a partition table sector */ |
725 | static void | 727 | static void |
726 | read_pte(struct pte *pe, ullong offset) | 728 | read_pte(struct pte *pe, ullong offset) |
@@ -937,7 +939,8 @@ list_types(const char *const *sys) | |||
937 | unsigned done, next, size; | 939 | unsigned done, next, size; |
938 | int i; | 940 | int i; |
939 | 941 | ||
940 | for (size = 0; sys[size]; size++) /* */; | 942 | for (size = 0; sys[size]; size++) |
943 | continue; | ||
941 | 944 | ||
942 | done = 0; | 945 | done = 0; |
943 | for (i = COLS-1; i >= 0; i--) { | 946 | for (i = COLS-1; i >= 0; i--) { |