Statistics
| Branch: | Revision:

root / part / partition.h @ abdb293f

History | View | Annotate | Download (1.3 kB)

1
#ifndef _PARTITION_H_
2
#define _PARTITION_H_
3

    
4
#include <inttypes.h>
5

    
6
#define PARTITION_BOOTABLE            0x80
7
#define PARTITION_NON_BOOTABLE        0x00
8

    
9
#define MBR_SIGNATURE                 0xAA55
10
#define MBR_START_SECTOR              0x80
11

    
12
struct partition_geometry {
13
        unsigned char                 heads;
14
        unsigned char                 sectors;
15
        unsigned int                  cylinders;
16
};
17

    
18
struct partition_chs {
19
        uint8_t                       chs[3];
20
} __attribute__((__packed__));
21

    
22
struct primary_partition {
23
        uint8_t                       status;
24
        struct partition_chs          chs_first;
25
        uint8_t                       type;
26
        struct partition_chs          chs_last;
27
        uint32_t                      lba;
28
        uint32_t                      blocks;
29
} __attribute__((__packed__));
30

    
31
struct partition_table {
32
        uint8_t                       code[0x1b8];
33
        uint32_t                      disk_signature;
34
        uint8_t                       pad[0x2];
35
        struct primary_partition      partitions[4];
36
        uint16_t                      mbr_signature;
37
} __attribute__((__packed__));
38

    
39
void partition_table_in(struct partition_table *);
40
void partition_table_out(struct partition_table *);
41
int partition_table_validate(struct partition_table *);
42
void partition_table_dump(struct partition_table *);
43
struct partition_chs lba_to_chs(struct partition_geometry *, uint64_t);
44

    
45
#endif