summaryrefslogtreecommitdiff
path: root/volume/volume.ha
diff options
context:
space:
mode:
authorAlejandro Sior <aho@sior.be>2022-06-18 14:43:46 +0200
committerAlejandro Sior <aho@sior.be>2022-06-18 14:43:46 +0200
commitfd2f5a94d6ad595e8bed354eca168a82b882e8b4 (patch)
treef30495b2ca343e1baf189e8a9f20f6234848fdea /volume/volume.ha
parent6117a803ad717fd50003c0bd8fbe393db2dcac6b (diff)
gptman: change the way of how args are passed to subcommands
Diffstat (limited to 'volume/volume.ha')
-rw-r--r--volume/volume.ha26
1 files changed, 26 insertions, 0 deletions
diff --git a/volume/volume.ha b/volume/volume.ha
new file mode 100644
index 0000000..d3bae12
--- /dev/null
+++ b/volume/volume.ha
@@ -0,0 +1,26 @@
+use fmt;
+use fs;
+use io;
+use os;
+
+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)) {
+ case let v: io::file =>
+ yield v;
+ case =>
+ fmt::fatalf("{}: cannot open file {}", os::args[0], os::args[1]);
+ };
+
+ return vol;
+};
+
+export fn openvol(vol: str) io::file = {
+ const vol = 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]);
+ };
+
+ return vol;
+};