1
0
Fork 0
mirror of https://github.com/tailix/libkernaux.git synced 2024-11-13 11:04:27 -05:00
libkernaux/include/kernaux/mbr.h

51 lines
1.1 KiB
C
Raw Normal View History

#ifndef KERNAUX_INCLUDED_MBR
#define KERNAUX_INCLUDED_MBR
#ifdef __cplusplus
extern "C" {
#endif
2022-01-17 01:34:42 -05:00
#include <stdbool.h>
#include <stdint.h>
#define KERNAUX_MBR_SIZE 512
2022-01-23 21:50:16 -05:00
#define KERNAUX_MBR_MAGIC 0xaa55
#define KERNAUX_MBR_ENTRIES 4
#define KERNAUX_MBR_BOOTSTRAP_SIZE \
(KERNAUX_MBR_SIZE - sizeof(struct KernAux_Mbr_Info))
struct KernAux_Mbr_Entry {
uint8_t drive_attributes;
2022-01-17 01:22:41 -05:00
unsigned first_sector_chs_addr : 24;
uint8_t partition_type;
2022-01-17 01:22:41 -05:00
unsigned last_sector_chs_addr : 24;
uint32_t first_sector_lba_addr;
uint32_t sectors_count;
}
__attribute__((packed));
struct KernAux_Mbr_Info {
uint32_t disk_id;
uint16_t reserved;
struct KernAux_Mbr_Entry entries[KERNAUX_MBR_ENTRIES];
uint16_t magic;
}
__attribute__((packed));
struct KernAux_Mbr {
uint8_t bootstrap[KERNAUX_MBR_BOOTSTRAP_SIZE];
struct KernAux_Mbr_Info info;
}
__attribute__((packed));
2022-01-17 01:34:42 -05:00
bool KernAux_Mbr_is_valid(const struct KernAux_Mbr *mbr);
bool KernAux_Mbr_Info_is_valid(const struct KernAux_Mbr_Info *mbr_info);
bool KernAux_Mbr_Entry_is_valid(const struct KernAux_Mbr_Entry *mbr_entry);
#ifdef __cplusplus
}
#endif
#endif