summaryrefslogtreecommitdiff
path: root/cmd/create/create.ha
diff options
context:
space:
mode:
authorAlejandro Sior <aho@sior.be>2022-06-21 17:31:07 +0200
committerAlejandro Sior <aho@sior.be>2022-06-21 17:31:07 +0200
commit68b9c04241ef433f346279fbc153928bcbd360e9 (patch)
tree7235a65503151837906962cdc8f46ab241b432c2 /cmd/create/create.ha
parentf42a480cbe487fc5fb9b3772990e80926201f6e4 (diff)
gptman: polish create and convert
Diffstat (limited to 'cmd/create/create.ha')
-rw-r--r--cmd/create/create.ha22
1 files changed, 17 insertions, 5 deletions
diff --git a/cmd/create/create.ha b/cmd/create/create.ha
index 124d86e..7733928 100644
--- a/cmd/create/create.ha
+++ b/cmd/create/create.ha
@@ -6,15 +6,16 @@ use os;
use strconv;
use gpt;
+use mbr;
use cmd;
-export fn create(vol: str, args: []str) void = {
+export fn create(args: []str) void = {
// XXX this is a stub
const c = getopt::parse(args,
- "create a volume",
('f', "file", "specify another partition file to fit"),
- ('l', "length", "specify another length margin")
+ ('b', "bytes", "specify another length margin (bytes)"),
+ ('s', "sectors", "specify another length margin (sectors, 512 bytes)")
);
defer getopt::finish(&c);
@@ -25,17 +26,28 @@ export fn create(vol: str, args: []str) void = {
switch (opt.0) {
case 'l' =>
length += (strconv::stoi(opt.1)! / 512 + 1): size;
+ case 's' =>
+ length += strconv::stoi(opt.1)!: size;
case 'f' =>
const stat = os::stat(opt.1)!;
length += stat.sz / 512 + 1;
};
};
- const vol = cmd::mkvol(vol);
- const vol = gpt::create(vol, length);
+ const fd = cmd::mkfile();
+ defer io::close(fd)!;
+
+ const vol = gpt::create(fd, length);
defer {
gpt::chksums(vol);
gpt::commit(vol)!;
gpt::finish(vol);
};
+
+ vol.mbr.entries[3] = mbr::entry {
+ part_type = 0xEE,
+ lba_begin = 0,
+ length = -1: u32,
+ ...
+ };
};