summaryrefslogtreecommitdiff
path: root/convert/convert.ha
diff options
context:
space:
mode:
authorAlejandro Sior <aho@sior.be>2022-06-18 14:43:46 +0200
committerAlejandro Sior <aho@sior.be>2022-06-18 14:43:46 +0200
commitfd2f5a94d6ad595e8bed354eca168a82b882e8b4 (patch)
treef30495b2ca343e1baf189e8a9f20f6234848fdea /convert/convert.ha
parent6117a803ad717fd50003c0bd8fbe393db2dcac6b (diff)
gptman: change the way of how args are passed to subcommands
Diffstat (limited to 'convert/convert.ha')
-rw-r--r--convert/convert.ha9
1 files changed, 6 insertions, 3 deletions
diff --git a/convert/convert.ha b/convert/convert.ha
index 5404bd8..dbf4ef4 100644
--- a/convert/convert.ha
+++ b/convert/convert.ha
@@ -11,10 +11,11 @@ use strings;
use errors;
use rt;
+use volume;
-export fn convert(vol: io::file, args: []str) void = {
+export fn convert(vol: str, args: []str) void = {
if (len(args) < 2) {
- fmt::fatalf("gptman.convert: needs disk");
+ fmt::fatalf("convert: needs disk");
};
let source = os::open(args[1], fs::flags::RDONLY)!;
@@ -22,13 +23,15 @@ export fn convert(vol: io::file, args: []str) void = {
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)