]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fdisk: fix fdiskdoslabel.c global variables
authorKarel Zak <kzak@redhat.com>
Wed, 2 May 2012 12:05:51 +0000 (14:05 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 2 May 2012 12:05:51 +0000 (14:05 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
fdisk/fdisk.c
fdisk/fdisk.h
fdisk/fdiskdoslabel.c
fdisk/fdiskdoslabel.h

index 66952668e207fd49b2b5ab5700d7cf0e53512a4c..acc84d1c845fe135d6b54fbdc27a459a0c783a48 100644 (file)
@@ -54,6 +54,9 @@
 
 static void delete_partition(int i);
 
+unsigned char *MBRbuffer;
+int MBRbuffer_changed;
+
 #define hex_val(c)     ({ \
                                char _c = (c); \
                                isdigit(_c) ? _c - '0' : \
@@ -145,7 +148,6 @@ char        *disk_device,                   /* must be specified */
        line_buffer[LINE_LENGTH];
 
 int    fd,                             /* the disk */
-       ext_index,                      /* the prime extended partition */
        nowarn = 0,                     /* no warnings for fdisk -l/-s */
        dos_compatible_flag = 0,        /* disabled by default */
        dos_changed = 0,
index da86e30dda75b07b2145516f6e0aef8f0a5a9c7f..3a1cfd7c0e4bafe1180f1b8797b19e89854a4347 100644 (file)
@@ -77,7 +77,6 @@ extern unsigned int read_int(unsigned int low, unsigned int dflt,
 extern void print_menu(enum menutype);
 extern void print_partition_size(int num, unsigned long long start, unsigned long long stop, int sysid);
 
-extern unsigned char *MBRbuffer;
 extern void zeroize_mbr_buffer(void);
 
 extern unsigned int heads, cylinders, sector_size;
@@ -113,12 +112,12 @@ extern enum labeltype disklabel;
  * Raw disk label. For DOS-type partition tables the MBR,
  * with descriptions of the primary partitions.
  */
-int MBRbuffer_changed;
-unsigned char *MBRbuffer;
+extern unsigned char *MBRbuffer;
+extern int MBRbuffer_changed;
 
 /* start_sect and nr_sects are stored little endian on all machines */
 /* moreover, they are not aligned correctly */
-static void
+static inline void
 store4_little_endian(unsigned char *cp, unsigned int val) {
        cp[0] = (val & 0xff);
        cp[1] = ((val >> 8) & 0xff);
@@ -126,45 +125,45 @@ store4_little_endian(unsigned char *cp, unsigned int val) {
        cp[3] = ((val >> 24) & 0xff);
 }
 
-static unsigned int read4_little_endian(const unsigned char *cp)
+static inline unsigned int read4_little_endian(const unsigned char *cp)
 {
        return (unsigned int)(cp[0]) + ((unsigned int)(cp[1]) << 8)
                + ((unsigned int)(cp[2]) << 16)
                + ((unsigned int)(cp[3]) << 24);
 }
 
-static void set_nr_sects(struct partition *p, unsigned long long nr_sects)
+static inline void set_nr_sects(struct partition *p, unsigned long long nr_sects)
 {
        store4_little_endian(p->size4, nr_sects);
 }
 
-static void set_start_sect(struct partition *p, unsigned int start_sect)
+static inline void set_start_sect(struct partition *p, unsigned int start_sect)
 {
        store4_little_endian(p->start4, start_sect);
 }
 
-static void seek_sector(int fd, unsigned long long secno)
+static inline void seek_sector(int fd, unsigned long long secno)
 {
        off_t offset = (off_t) secno * sector_size;
        if (lseek(fd, offset, SEEK_SET) == (off_t) -1)
                fatal(unable_to_seek);
 }
 
-static void read_sector(int fd, unsigned long long secno, unsigned char *buf)
+static inline void read_sector(int fd, unsigned long long secno, unsigned char *buf)
 {
        seek_sector(fd, secno);
        if (read(fd, buf, sector_size) != sector_size)
                fatal(unable_to_read);
 }
 
-static void write_sector(int fd, unsigned long long secno, unsigned char *buf)
+static inline void write_sector(int fd, unsigned long long secno, unsigned char *buf)
 {
        seek_sector(fd, secno);
        if (write(fd, buf, sector_size) != sector_size)
                fatal(unable_to_write);
 }
 
-static unsigned long long get_start_sect(struct partition *p)
+static inline unsigned long long get_start_sect(struct partition *p)
 {
        return read4_little_endian(p->start4);
 }
index 04fdf841d24b761943fce1b21caf1de9cfe9adfb..6a9a0445d822dc89f9f8aea559cf95d25b6271ef 100644 (file)
 #include "fdisk.h"
 #include "fdiskdoslabel.h"
 
+struct pte ptes[MAXIMUM_PARTS];
+unsigned long long extended_offset;
+int ext_index;
+
 /* Allocate a buffer and read a partition table sector */
 static void read_pte(int fd, int pno, unsigned long long offset)
 {
index b4442433bac69e5d3aa7d3a02407f83f940b4926..f5568dff28540d2b3dd617e11d24e48230179ee0 100644 (file)
@@ -15,27 +15,29 @@ struct pte {
        char changed;                   /* boolean */
        unsigned long long offset;      /* disk sector number */
        unsigned char *sectorbuffer;    /* disk sector contents */
-} ptes[MAXIMUM_PARTS];
+};
+
+extern struct pte ptes[MAXIMUM_PARTS];
 
 #define pt_offset(b, n)        ((struct partition *)((b) + 0x1be + \
                                              (n) * sizeof(struct partition)))
 
-int ext_index; /* the prime extended partition */
-unsigned long long extended_offset;
+extern int ext_index; /* the prime extended partition */
+extern unsigned long long extended_offset;
 
-static void write_part_table_flag(unsigned char *b)
+static inline void write_part_table_flag(unsigned char *b)
 {
        b[510] = 0x55;
        b[511] = 0xaa;
 }
 
 /* A valid partition table sector ends in 0x55 0xaa */
-static unsigned int part_table_flag(unsigned char *b)
+static inline unsigned int part_table_flag(unsigned char *b)
 {
        return ((unsigned int) b[510]) + (((unsigned int) b[511]) << 8);
 }
 
-static unsigned long long get_partition_start(struct pte *pe)
+static inline unsigned long long get_partition_start(struct pte *pe)
 {
        return pe->offset + get_start_sect(pe->part_table);
 }