From f42a480cbe487fc5fb9b3772990e80926201f6e4 Mon Sep 17 00:00:00 2001 From: Alejandro Sior Date: Tue, 21 Jun 2022 15:38:48 +0200 Subject: gptman: reorganize commands in a cmd module --- create/create.ha | 41 ----------------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 create/create.ha (limited to 'create/create.ha') diff --git a/create/create.ha b/create/create.ha deleted file mode 100644 index b7dc0f7..0000000 --- a/create/create.ha +++ /dev/null @@ -1,41 +0,0 @@ -use fmt; -use fs; -use getopt; -use io; -use os; -use strconv; - -use gpt; -use volume; - -export fn create(vol: str, args: []str) void = { - // XXX this is a stub - - const cmd = getopt::parse(args, - "create a volume", - ('f', "file", "specify another partition file to fit"), - ('l', "length", "specify another length margin") - ); - defer getopt::finish(&cmd); - - let length = 0z; - - for (let i = 0z; i < len(cmd.opts); i += 1) { - const opt = cmd.opts[i]; - switch (opt.0) { - case 'l' => - length += (strconv::stoi(opt.1)! / 512 + 1): size; - case 'f' => - const stat = os::stat(opt.1)!; - length += stat.sz / 512 + 1; - }; - }; - - const vol = volume::mkvol(vol); - const vol = gpt::create(vol, length); - defer { - gpt::chksums(vol); - gpt::commit(vol)!; - gpt::finish(vol); - }; -}; -- cgit v1.2.3