blob: 832a96f6c18a060b0e3b7298c1929cbf9470b98c (
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
|
use fmt;
use fs;
use io;
use os;
use gpt;
export fn mkvol(vol: str) io::file = {
return match (os::create(vol, fs::mode::USER_RWX | fs::mode::GROUP_RX | fs::mode::OTHER_RX, fs::flags::RDWR)) {
case let v: io::file =>
yield v;
case =>
fmt::fatalf("{}: cannot open file {}", os::args[0], vol);
};
};
export fn openvol(vol: str) io::file = {
return match (os::open(vol, fs::flags::RDWR)) {
case let v: io::file =>
yield v;
case =>
fmt::fatalf("{}: cannot open file {}", os::args[0], vol);
};
};
export fn opengpt(vol: str) *gpt::gpt = {
const vol = openvol(vol);
return match (gpt::from(vol)) {
case let g: *gpt::gpt =>
yield g;
case io::error =>
fmt::fatalf("{}: could not properly read disk {}", os::args[0], os::args[1]);
case =>
fmt::fatalf("{}: no valid gpt in disk", os::args[0]);
};
};
|