From 3c8602ee9f04991e1d60b8d6504e12296ca671d9 Mon Sep 17 00:00:00 2001 From: Alejandro Sior Date: Wed, 15 Jun 2022 17:42:40 +0200 Subject: gptman: add files --- convert/convert.ha | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 convert/convert.ha (limited to 'convert/convert.ha') 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; +}; -- cgit v1.2.3