summaryrefslogtreecommitdiff
path: root/convert/convert.ha
diff options
context:
space:
mode:
authorAlejandro Sior <aho@sior.be>2022-06-15 17:42:40 +0200
committerAlejandro Sior <aho@sior.be>2022-06-15 17:42:40 +0200
commit3c8602ee9f04991e1d60b8d6504e12296ca671d9 (patch)
tree1be941405e224be61ce1f2c9116cc5f05bc13e01 /convert/convert.ha
gptman: add files
Diffstat (limited to 'convert/convert.ha')
-rw-r--r--convert/convert.ha33
1 files changed, 33 insertions, 0 deletions
diff --git a/convert/convert.ha b/convert/convert.ha
new file mode 100644
index 0000000..10f73c7
--- /dev/null
+++ b/convert/convert.ha
@@ -0,0 +1,33 @@
+use fmt;
+
+use mbr;
+use gpt;
+use sector;
+
+use os;
+use io;
+use fs;
+use strings;
+use errors;
+
+
+export fn convert(args: []str) void = {
+ if (len(args) < 2) {
+ fmt::fatalf("gptman.convert: needs disk");
+ };
+
+ fmt::println(args[1])!;
+ let file = os::open(args[1], fs::flags::RDWR)!;
+ defer io::close(file)!;
+
+ let vol = gpt::from(file)!;
+ gpt::mkbackup(vol);
+ defer {
+ gpt::chksums(vol);
+ gpt::commit(vol);
+ gpt::finish(vol);
+ };
+
+ vol.primary.header.disk_guid[0] = 0xcafebabe;
+ vol.primary.header.disk_guid[1] = 0xabababababababab;
+};