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 io;
use os;
use gpt;
use cmd;
fn booltonum(a: bool) str = if (a) { return "1"; } else { return "0"; };
export fn info(args: []str) void = {
const fd = cmd::openfile();
const vol = cmd::opengpt(fd);
defer gpt::finish(vol);
const header = vol.primary.header;
fmt::printfln("# GPT header info {}", os::args[1])!;
fmt::printfln("revision({})", header.revision)!;
fmt::printfln("header_size({})", header.header_size)!;
fmt::printfln("header_crc32({})", header.header_crc32)!;
fmt::printfln("header_lba({})", header.header_lba)!;
fmt::printfln("backup_header_lba({})", header.backup_header_lba)!;
fmt::printfln("first_lba({})", header.first_lba)!;
fmt::printfln("last_lba({})", header.last_lba)!;
// XXX Add a comment output for the GUID written in normal form
fmt::printfln("disk_guid([{},{}])", header.disk_guid[0], header.disk_guid[1])!;
fmt::printfln("entries_lba({})", header.entries_lba)!;
fmt::printfln("entries_len({})", header.entries_len)!;
fmt::printfln("entry_size({})", header.entry_size)!;
fmt::printfln("entries_crc32({})", header.entries_crc32)!;
const primary_sane = gpt::header_crc32(header) == header.header_crc32 && gpt::entries_crc32(vol.primary.entries) == header.entries_crc32;
const backup_sane = gpt::header_crc32(vol.backup.header) == vol.backup.header.header_crc32 && gpt::entries_crc32(vol.backup.entries) == vol.backup.header.entries_crc32;
fmt::printfln("primary_sane({})", booltonum(primary_sane))!;
fmt::printfln("backup_sane({})", booltonum(backup_sane))!;
};
|