]>
Commit | Line | Data |
---|---|---|
bd3239d2 MF |
1 | #include <stddef.h> |
2 | #include <stdio.h> | |
3 | #include <stdint.h> | |
4 | #include <string.h> | |
5 | ||
6 | struct apartition { | |
7 | unsigned char flag; | |
8 | char id[3]; | |
9 | uint32_t start; | |
10 | uint32_t size; | |
11 | } __attribute__((packed)); | |
12 | struct rootsector { | |
13 | char unused[0x156]; | |
14 | struct apartition icdpart[8]; | |
15 | char unused2[0xc]; | |
16 | struct apartition part[4]; | |
17 | } __attribute__((packed)); | |
18 | typedef struct _PARTITION { | |
19 | unsigned long start; | |
20 | char id[4]; | |
21 | unsigned long rootsec; | |
22 | } PARTITION; | |
23 | int partitions; | |
24 | PARTITION part_table[64]; | |
25 | static void PART2diskpart(PARTITION * cp, struct apartition *dp, | |
26 | unsigned long relto) | |
27 | { | |
28 | memcpy(dp->id, cp->id, 3); | |
29 | } | |
30 | ||
31 | void put_boot(int first_ext, int last_ext, PARTITION * master_XGM) | |
32 | { | |
33 | char buffer[sizeof(struct rootsector)]; | |
34 | struct rootsector *rs = (struct rootsector *)buffer; | |
35 | struct apartition *pi; | |
36 | int i, bootable; | |
37 | PARTITION cont_XGM; | |
38 | pi = &rs->part[0]; | |
39 | for (i = 0; i < partitions; ++i) { | |
40 | if (i == first_ext) { | |
41 | PART2diskpart(master_XGM, pi, 0); | |
42 | PART2diskpart(&part_table[i], &rs->part[0], | |
43 | part_table[i].rootsec); | |
44 | if (i == last_ext) { | |
45 | PART2diskpart(&cont_XGM, &rs->part[1], | |
46 | master_XGM->start); | |
47 | } | |
48 | } | |
49 | } | |
50 | } | |
51 | ||
52 | main() { | |
53 | printf("%i\n", sizeof(struct rootsector)); | |
54 | printf("%i %i\n", offsetof(struct rootsector, part[0])); | |
55 | } |