X-Git-Url: https://git.wh0rd.org/?p=ICEs.git;a=blobdiff_plain;f=568732%2Fwritepart.i;fp=568732%2Fwritepart.i;h=b01cd63397d16badaa3e32fffe321671aed92fd5;hp=0000000000000000000000000000000000000000;hb=bd3239d2bbe0de3a200b266503e3330b1e391489;hpb=dbff64cb4b7530861c2309c794efdd4e0cf47a23 diff --git a/568732/writepart.i b/568732/writepart.i new file mode 100644 index 0000000..b01cd63 --- /dev/null +++ b/568732/writepart.i @@ -0,0 +1,57 @@ +typedef long unsigned int size_t; +extern __inline __attribute__ ((__always_inline__)) + __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) +void * + __attribute__ ((__nothrow__, __leaf__)) memcpy(void *__restrict __dest, + const void *__restrict __src, + size_t __len) +{ + return __builtin___memcpy_chk(__dest, __src, __len, + __builtin_object_size(__dest, 0)); +} + +struct apartition { + unsigned char flag; + char id[3]; + unsigned long start; + unsigned long size; +} __attribute((packed)); +struct rootsector { + char unused[0x156]; + struct apartition icdpart[8]; + char unused2[0xc]; + struct apartition part[4]; +} __attribute((packed)); +typedef struct _PARTITION { + unsigned long start; + char id[4]; + unsigned long rootsec; +} PARTITION; +extern int partitions; +extern PARTITION part_table[64]; +static void PART2diskpart(PARTITION * cp, struct apartition *dp, + unsigned long relto) +{ + memcpy(dp->id, cp->id, 3); +} + +void put_boot(int first_ext, int last_ext, PARTITION * master_XGM) +{ + char buffer[512]; + struct rootsector *rs = (struct rootsector *)buffer; + struct apartition *pi; + int i, bootable; + PARTITION cont_XGM; + pi = &rs->part[0]; + for (i = 0; i < partitions; ++i) { + if (i == first_ext) { + PART2diskpart(master_XGM, pi, 0); + PART2diskpart(&part_table[i], &rs->part[0], + part_table[i].rootsec); + if (i == last_ext) { + PART2diskpart(&cont_XGM, &rs->part[1], + master_XGM->start); + } + } + } +}