]> git.wh0rd.org - ICEs.git/blame - 568732/writepart.i
more
[ICEs.git] / 568732 / writepart.i
CommitLineData
bd3239d2
MF
1typedef long unsigned int size_t;
2extern __inline __attribute__ ((__always_inline__))
3 __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__))
4void *
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
13struct apartition {
14 unsigned char flag;
15 char id[3];
16 unsigned long start;
17 unsigned long size;
18} __attribute((packed));
19struct rootsector {
20 char unused[0x156];
21 struct apartition icdpart[8];
22 char unused2[0xc];
23 struct apartition part[4];
24} __attribute((packed));
25typedef struct _PARTITION {
26 unsigned long start;
27 char id[4];
28 unsigned long rootsec;
29} PARTITION;
30extern int partitions;
31extern PARTITION part_table[64];
32static void PART2diskpart(PARTITION * cp, struct apartition *dp,
33 unsigned long relto)
34{
35 memcpy(dp->id, cp->id, 3);
36}
37
38void 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}