diff options
| author | Alejandro Sior <aho@sior.be> | 2022-06-21 10:38:45 +0200 |
|---|---|---|
| committer | Alejandro Sior <aho@sior.be> | 2022-06-21 10:38:45 +0200 |
| commit | c99646423f311c9238ace86be17caf531fe61c44 (patch) | |
| tree | b17f04f09ce6eb918e71983c8e7b1589eb0ec87f /volume/volume.ha | |
| parent | fd2f5a94d6ad595e8bed354eca168a82b882e8b4 (diff) | |
gptman: partition info
Diffstat (limited to 'volume/volume.ha')
| -rw-r--r-- | volume/volume.ha | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/volume/volume.ha b/volume/volume.ha index d3bae12..832a96f 100644 --- a/volume/volume.ha +++ b/volume/volume.ha @@ -3,24 +3,35 @@ use fs; use io; use os; +use gpt; + export fn mkvol(vol: str) io::file = { - const vol = match (os::create(vol, fs::mode::USER_RWX | fs::mode::GROUP_RX | fs::mode::OTHER_RX, fs::flags::RDWR)) { + 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], os::args[1]); + fmt::fatalf("{}: cannot open file {}", os::args[0], vol); }; - - return vol; }; export fn openvol(vol: str) io::file = { - const vol = match (os::open(vol, fs::flags::RDWR)) { + return match (os::open(vol, fs::flags::RDWR)) { case let v: io::file => yield v; case => - fmt::fatalf("{}: cannot open file {}", os::args[0], os::args[1]); + fmt::fatalf("{}: cannot open file {}", os::args[0], vol); }; +}; - return 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]); + }; }; |
