#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,
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 \
#include <stdint.h>
#include "partitions.h"
-#include "dos.h"
#include "aix.h"
/* see superblocks/vfat.c */
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,
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.
}
}
- 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)
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;
+++ /dev/null
-#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 */
#include "partitions.h"
#include "crc32.h"
-#include "dos.h"
#define GPT_PRIMARY_LBA 1
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)
#include <stdint.h>
#include "partitions.h"
-#include "dos.h"
#include "minix.h"
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;