]> git.wh0rd.org Git - ICEs.git/blob - 568732/writepart.i
more
[ICEs.git] / 568732 / writepart.i
1 typedef long unsigned int size_t;
2 extern __inline __attribute__ ((__always_inline__))
3     __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__))
4 void *
5     __attribute__ ((__nothrow__, __leaf__)) memcpy(void *__restrict __dest,
6                                                    const void *__restrict __src,
7                                                    size_t __len)
8 {
9         return __builtin___memcpy_chk(__dest, __src, __len,
10                                       __builtin_object_size(__dest, 0));
11 }
12
13 struct apartition {
14         unsigned char flag;
15         char id[3];
16         unsigned long start;
17         unsigned long size;
18 } __attribute((packed));
19 struct rootsector {
20         char unused[0x156];
21         struct apartition icdpart[8];
22         char unused2[0xc];
23         struct apartition part[4];
24 } __attribute((packed));
25 typedef struct _PARTITION {
26         unsigned long start;
27         char id[4];
28         unsigned long rootsec;
29 } PARTITION;
30 extern int partitions;
31 extern PARTITION part_table[64];
32 static void PART2diskpart(PARTITION * cp, struct apartition *dp,
33                           unsigned long relto)
34 {
35         memcpy(dp->id, cp->id, 3);
36 }
37
38 void put_boot(int first_ext, int last_ext, PARTITION * master_XGM)
39 {
40         char buffer[512];
41         struct rootsector *rs = (struct rootsector *)buffer;
42         struct apartition *pi;
43         int i, bootable;
44         PARTITION cont_XGM;
45         pi = &rs->part[0];
46         for (i = 0; i < partitions; ++i) {
47                 if (i == first_ext) {
48                         PART2diskpart(master_XGM, pi, 0);
49                         PART2diskpart(&part_table[i], &rs->part[0],
50                                       part_table[i].rootsec);
51                         if (i == last_ext) {
52                                 PART2diskpart(&cont_XGM, &rs->part[1],
53                                               master_XGM->start);
54                         }
55                 }
56         }
57 }