summaryrefslogtreecommitdiff
path: root/convert/convert.ha
diff options
context:
space:
mode:
Diffstat (limited to 'convert/convert.ha')
-rw-r--r--convert/convert.ha49
1 files changed, 45 insertions, 4 deletions
diff --git a/convert/convert.ha b/convert/convert.ha
index 10f73c7..98ad124 100644
--- a/convert/convert.ha
+++ b/convert/convert.ha
@@ -16,18 +16,59 @@ export fn convert(args: []str) void = {
fmt::fatalf("gptman.convert: needs disk");
};
- fmt::println(args[1])!;
let file = os::open(args[1], fs::flags::RDWR)!;
defer io::close(file)!;
+ // let vol = gpt::create(file, 69);
+ // gpt::mkbackup(vol);
+ // defer {
+ // gpt::chksums(vol);
+ // gpt::commit(vol)!;
+ // gpt::finish(vol);
+ // };
+
+ // vol.mbr.entries[0] = mbr::mbr_entry {
+ // attributes = 0,
+ // part_type = 0xEE,
+ // lba_begin = 1,
+ // lba_end = -1: u32,
+ // };
+ // vol.mbr.magic = 0xaa55;
+
let vol = gpt::from(file)!;
gpt::mkbackup(vol);
defer {
gpt::chksums(vol);
- gpt::commit(vol);
+ gpt::commit(vol)!;
gpt::finish(vol);
};
- vol.primary.header.disk_guid[0] = 0xcafebabe;
- vol.primary.header.disk_guid[1] = 0xabababababababab;
+ // fmt::printfln("rev {}", vol.primary.header.revision)!;
+
+ // for (let i = 0z; i < 4; i += 1) {
+ // fmt::printfln("type {} from {} to {}", vol.mbr.entries[i].part_type, vol.mbr.entries[i].lba_begin, vol.mbr.entries[i].lba_end)!;
+ // };
+
+ // vol.primary.header.disk_guid[0] = 0xcafababe;
+ // vol.primary.header.disk_guid[1] = 0xabababababababab;
+
+ // // 516E7CB6-6ECF-11D6-8FF8-00022D09712B
+
+ // vol.primary.entries[4].part_type[0] = 0x516E7CB66ECF;
+ // vol.primary.entries[4].lba_begin = 35;
+ // vol.primary.entries[4].lba_end = 37;
+ // vol.primary.entries[5].part_type[0] = 0x516E7CB66ECF;
+ // vol.primary.entries[5].lba_begin = 40;
+ // vol.primary.entries[5].lba_end = 41;
+
+
+ const much = 4z;
+ const addr = gpt::findfree(vol, much);
+ const where = gpt::findfreeentry(vol) as *gpt::entry;
+
+ where.part_type = [0xCAFEBABE, 0xBABABA];
+ where.lba_begin = addr;
+ where.lba_end = addr + much: u64 - 1;
+
+ fmt::printfln("fitting {}: {} and could be put at {}", much, addr, where)!;
};