blob: b7dc0f7c6aeea8c7ae3f2f0cc74a32c08fa82701 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
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);
};
};
|