diff options
author | bigbiff bigbiff <bigbiff@teamw.in> | 2013-02-23 02:55:50 +0100 |
---|---|---|
committer | bigbiff bigbiff <bigbiff@teamw.in> | 2013-02-25 15:06:46 +0100 |
commit | e60683a0d553b6488c564863f4e48954944fb0f8 (patch) | |
tree | 9364f97cb88b7c1359f5f06dfb32150a78168c31 /libblkid/dos.h | |
parent | Fix building of updater for 4.2 environment (diff) | |
download | android_bootable_recovery-e60683a0d553b6488c564863f4e48954944fb0f8.tar android_bootable_recovery-e60683a0d553b6488c564863f4e48954944fb0f8.tar.gz android_bootable_recovery-e60683a0d553b6488c564863f4e48954944fb0f8.tar.bz2 android_bootable_recovery-e60683a0d553b6488c564863f4e48954944fb0f8.tar.lz android_bootable_recovery-e60683a0d553b6488c564863f4e48954944fb0f8.tar.xz android_bootable_recovery-e60683a0d553b6488c564863f4e48954944fb0f8.tar.zst android_bootable_recovery-e60683a0d553b6488c564863f4e48954944fb0f8.zip |
Diffstat (limited to 'libblkid/dos.h')
-rw-r--r-- | libblkid/dos.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/libblkid/dos.h b/libblkid/dos.h new file mode 100644 index 000000000..d7588a856 --- /dev/null +++ b/libblkid/dos.h @@ -0,0 +1,41 @@ +#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 */ |