]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: move MBR definitions to include/pt-mbr.h
authorKarel Zak <kzak@redhat.com>
Tue, 18 Jun 2013 13:03:26 +0000 (15:03 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 16 Sep 2013 14:47:02 +0000 (16:47 +0200)
include/pt-mbr.h
libblkid/src/Makemodule.am
libblkid/src/partitions/dos.c
libblkid/src/partitions/dos.h [deleted file]
libblkid/src/partitions/gpt.c
libblkid/src/partitions/minix.c

index a02eaa98b88f248f3b26d28da2962cde85ebd338..eef940b5768901127eac3046c5857359f3aaf76d 100644 (file)
@@ -1,6 +1,43 @@
 #ifndef UTIL_LINUX_PT_MBR_H
 #define UTIL_LINUX_PT_MBR_H
 
+struct dos_partition {
+       unsigned char boot_ind;         /* 0x80 - active */
+       unsigned char bh, bs, bc;       /* begin CHS */
+       unsigned char sys_type;
+       unsigned char eh, es, ec;       /* end CHS */
+       unsigned char start_sect[4];
+       unsigned char nr_sects[4];
+} __attribute__((packed));
+
+#define MBR_PT_OFFSET          0x1be
+
+/* assemble badly aligned little endian integer */
+static inline unsigned int __dos_assemble4le(const unsigned char *p)
+{
+       return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
+}
+
+static inline unsigned int dos_partition_start(struct dos_partition *p)
+{
+       return __dos_assemble4le(&(p->start_sect[0]));
+}
+
+static inline unsigned int dos_partition_size(struct dos_partition *p)
+{
+       return __dos_assemble4le(&(p->nr_sects[0]));
+}
+
+static inline int is_valid_mbr_signature(const unsigned char *mbr)
+{
+       return mbr[510] == 0x55 && mbr[511] == 0xaa ? 1 : 0;
+}
+
+static inline unsigned int dos_parttable_id(const unsigned char *mbr)
+{
+       return __dos_assemble4le(&mbr[440]);
+}
+
 enum {
        MBR_EMPTY_PARTITION             = 0x00,
        MBR_FAT12_PARTITION             = 0x01,
index 3c153ab3773b2b1f8a8a9c3a37d6f37684bedc7f..a335db4ee2d1c72ec3ae50a3139ba32f936480e6 100644 (file)
@@ -32,7 +32,6 @@ libblkid_la_SOURCES = \
        libblkid/src/partitions/aix.h \
        libblkid/src/partitions/bsd.c \
        libblkid/src/partitions/dos.c \
-       libblkid/src/partitions/dos.h \
        libblkid/src/partitions/gpt.c \
        libblkid/src/partitions/mac.c \
        libblkid/src/partitions/minix.c \
index 9b3991ba9e039084e2d4fbbd1eb6cadf20a44e36..0e0413e64bae2e01461f8fb404e4a86dacc5f41f 100644 (file)
@@ -14,7 +14,6 @@
 #include <stdint.h>
 
 #include "partitions.h"
-#include "dos.h"
 #include "aix.h"
 
 /* see superblocks/vfat.c */
@@ -61,7 +60,7 @@ static int parse_dos_extended(blkid_probe pr, blkid_parttable tab,
                if (!is_valid_mbr_signature(data))
                        goto leave;
 
-               p0 = (struct dos_partition *) (data + BLKID_MSDOS_PT_OFFSET);
+               p0 = (struct dos_partition *) (data + MBR_PT_OFFSET);
 
                /* Usually, the first entry is the real data partition,
                 * the 2nd entry is the next extended partition, or empty,
@@ -160,7 +159,7 @@ static int probe_dos_pt(blkid_probe pr,
                goto nothing;
        }
 
-       p0 = (struct dos_partition *) (data + BLKID_MSDOS_PT_OFFSET);
+       p0 = (struct dos_partition *) (data + MBR_PT_OFFSET);
 
        /*
         * Reject PT where boot indicator is not 0 or 0x80.
@@ -181,8 +180,8 @@ static int probe_dos_pt(blkid_probe pr,
                }
        }
 
-       blkid_probe_use_wiper(pr, BLKID_MSDOS_PT_OFFSET,
-                                 512 - BLKID_MSDOS_PT_OFFSET);
+       blkid_probe_use_wiper(pr, MBR_PT_OFFSET,
+                                 512 - MBR_PT_OFFSET);
 
        id = dos_parttable_id(data);
        if (id)
@@ -207,7 +206,7 @@ static int probe_dos_pt(blkid_probe pr,
        ssf = blkid_probe_get_sectorsize(pr) / 512;
 
        /* allocate a new partition table */
-       tab = blkid_partlist_new_parttable(ls, "dos", BLKID_MSDOS_PT_OFFSET);
+       tab = blkid_partlist_new_parttable(ls, "dos", MBR_PT_OFFSET);
        if (!tab)
                goto err;
 
diff --git a/libblkid/src/partitions/dos.h b/libblkid/src/partitions/dos.h
deleted file mode 100644 (file)
index d7588a8..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef BLKID_PARTITIONS_DOS_H
-#define BLKID_PARTITIONS_DOS_H
-
-struct dos_partition {
-       unsigned char boot_ind;         /* 0x80 - active */
-       unsigned char bh, bs, bc;       /* begin CHS */
-       unsigned char sys_type;
-       unsigned char eh, es, ec;       /* end CHS */
-       unsigned char start_sect[4];
-       unsigned char nr_sects[4];
-} __attribute__((packed));
-
-#define BLKID_MSDOS_PT_OFFSET          0x1be
-
-/* assemble badly aligned little endian integer */
-static inline unsigned int assemble4le(const unsigned char *p)
-{
-       return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
-}
-
-static inline unsigned int dos_partition_start(struct dos_partition *p)
-{
-       return assemble4le(&(p->start_sect[0]));
-}
-
-static inline unsigned int dos_partition_size(struct dos_partition *p)
-{
-       return assemble4le(&(p->nr_sects[0]));
-}
-
-static inline int is_valid_mbr_signature(const unsigned char *mbr)
-{
-       return mbr[510] == 0x55 && mbr[511] == 0xaa ? 1 : 0;
-}
-
-static inline unsigned int dos_parttable_id(const unsigned char *mbr)
-{
-       return assemble4le(&mbr[440]);
-}
-
-#endif /* BLKID_PARTITIONS_DOS_H */
index 21b8c98813187384637ab0d23f4167daeef9f4b9..39a41815c6560b223468a0d781e3a7ac8c850948 100644 (file)
@@ -20,7 +20,6 @@
 
 #include "partitions.h"
 #include "crc32.h"
-#include "dos.h"
 
 #define GPT_PRIMARY_LBA        1
 
@@ -173,7 +172,7 @@ static int is_pmbr_valid(blkid_probe pr)
        if (!is_valid_mbr_signature(data))
                goto failed;
 
-       p = (struct dos_partition *) (data + BLKID_MSDOS_PT_OFFSET);
+       p = (struct dos_partition *) (data + MBR_PT_OFFSET);
 
        for (i = 0; i < 4; i++, p++) {
                if (p->sys_type == MBR_GPT_PARTITION)
index f76c86aebd947ba647683a8efde02243e0a0ab65..5730f44c533ddeeadc7a70cdc0b4242ec3d5c1c7 100644 (file)
@@ -12,7 +12,6 @@
 #include <stdint.h>
 
 #include "partitions.h"
-#include "dos.h"
 #include "minix.h"
 
 static int probe_minix_pt(blkid_probe pr,
@@ -47,9 +46,9 @@ static int probe_minix_pt(blkid_probe pr,
                /* caller does not ask for details about partitions */
                return 0;
 
-       p = (struct dos_partition *) (data + BLKID_MSDOS_PT_OFFSET);
+       p = (struct dos_partition *) (data + MBR_PT_OFFSET);
 
-       tab = blkid_partlist_new_parttable(ls, "minix", BLKID_MSDOS_PT_OFFSET);
+       tab = blkid_partlist_new_parttable(ls, "minix", MBR_PT_OFFSET);
        if (!tab)
                goto err;