diff options
| author | Alejandro Sior <aho@sior.be> | 2022-06-18 13:54:25 +0200 |
|---|---|---|
| committer | Alejandro Sior <aho@sior.be> | 2022-06-18 13:54:25 +0200 |
| commit | 6117a803ad717fd50003c0bd8fbe393db2dcac6b (patch) | |
| tree | a01ba73f37570b96bebef8c193abaf686ef9f696 /convert/convert.ha | |
| parent | d6181b5e4f6f2dc72907e9f2e73db9ce0075cddd (diff) | |
add header command
Diffstat (limited to 'convert/convert.ha')
| -rw-r--r-- | convert/convert.ha | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/convert/convert.ha b/convert/convert.ha index 7ba6bf0..5404bd8 100644 --- a/convert/convert.ha +++ b/convert/convert.ha @@ -12,8 +12,8 @@ use errors; use rt; -export fn convert(args: []str) void = { - if (len(args) < 3) { +export fn convert(vol: io::file, args: []str) void = { + if (len(args) < 2) { fmt::fatalf("gptman.convert: needs disk"); }; @@ -22,28 +22,13 @@ export fn convert(args: []str) void = { const source = mbr::from(source)!; - let freeno: size = 0z; - for (let i = 0z; i < 4; i += 1) { - const entry = &source.bootsector.entries[i]; - - if (entry.lba_begin == 0 && entry.length == 0) - continue; - - freeno += entry.length: size; - }; - - let file = os::create(args[2], fs::mode::USER_RWX | fs::mode::GROUP_RX | fs::mode::OTHER_RX, fs::flags::RDWR)!; - defer io::close(file)!; - - let vol = gpt::create(file, freeno); - gpt::mkbackup(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) |
