diff options
| author | Alejandro Sior <aho@sior.be> | 2022-06-21 15:38:48 +0200 |
|---|---|---|
| committer | Alejandro Sior <aho@sior.be> | 2022-06-21 15:38:48 +0200 |
| commit | f42a480cbe487fc5fb9b3772990e80926201f6e4 (patch) | |
| tree | d6af05ea6942732fafa721c97895b66cd42298b3 /convert/convert.ha | |
| parent | d000a6edf4ad9fcc2302a80080fdbebb23fb7378 (diff) | |
gptman: reorganize commands in a cmd module
Diffstat (limited to 'convert/convert.ha')
| -rw-r--r-- | convert/convert.ha | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/convert/convert.ha b/convert/convert.ha deleted file mode 100644 index dbf4ef4..0000000 --- a/convert/convert.ha +++ /dev/null @@ -1,59 +0,0 @@ -use fmt; - -use mbr; -use gpt; -use sector; - -use os; -use io; -use fs; -use strings; -use errors; -use rt; - -use volume; - -export fn convert(vol: str, args: []str) void = { - if (len(args) < 2) { - fmt::fatalf("convert: needs disk"); - }; - - let source = os::open(args[1], fs::flags::RDONLY)!; - defer io::close(source)!; - - const source = mbr::from(source)!; - - const vol = volume::openvol(vol); - let vol = gpt::from(vol)!; - defer { - gpt::chksums(vol); - gpt::commit(vol)!; - gpt::finish(vol); - }; - - rt::memcpy(vol.mbr, source.bootsector, size(mbr::bootsector)); - for (let i = 0z; i < 4; i += 1) { - const entry = &source.bootsector.entries[i]; - if (entry.lba_begin == 0 && entry.length == 0) - continue; - - const reader = mbr::partstream_reader(source, entry)!; - const partlength = entry.length; - - const part = gpt::allocate(vol, partlength) as *gpt::entry; - - const writer = gpt::partstream_writer(vol, part)!; - - io::copy(&writer, &reader)!; - - vol.mbr.entries[i].lba_begin = part.lba_begin: u32; - vol.mbr.entries[i].length = (part.lba_end - part.lba_begin + 1): u32; - }; - - vol.mbr.entries[3] = mbr::entry { - part_type = 0xEE, - lba_begin = 0, - length = -1: u32, - ... - }; -}; |
