aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-07-09 21:20:50 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-07-09 21:20:50 +0000
commit9764d6908a9e613f9192e0a3e642e1b0017e521d (patch)
treee6957e352c843d756b8e0af379b7beaa69a6af86
parent6bdff08e6c048106de55998908af7c2f139b10a0 (diff)
downloadbusybox-w32-9764d6908a9e613f9192e0a3e642e1b0017e521d.tar.gz
busybox-w32-9764d6908a9e613f9192e0a3e642e1b0017e521d.tar.bz2
busybox-w32-9764d6908a9e613f9192e0a3e642e1b0017e521d.zip
fdisk: fix compile failure
-rw-r--r--util-linux/fdisk.c79
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 {
86static const char unable_to_open[] ALIGN1 = "cannot open %s"; 86static const char unable_to_open[] ALIGN1 = "cannot open %s";
87static const char unable_to_read[] ALIGN1 = "cannot read from %s"; 87static const char unable_to_read[] ALIGN1 = "cannot read from %s";
88static const char unable_to_seek[] ALIGN1 = "cannot seek on %s"; 88static const char unable_to_seek[] ALIGN1 = "cannot seek on %s";
89static void fdisk_fatal(const char *why) NORETURN;
90 89
91enum label_type { 90enum 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)
518static char 517static char
519read_nonempty(const char *mesg) 518read_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
555static 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
564static void
565seek_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
581static void
582write_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
557typedef struct { 592typedef struct {
@@ -640,6 +675,7 @@ STATIC_SUN void verify_sun(void);
640STATIC_SUN void sun_write_table(void); 675STATIC_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
690static 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
699static void
700seek_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
716static void
717write_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 */
725static void 727static void
726read_pte(struct pte *pe, ullong offset) 728read_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--) {