master
 1const std = @import("std");
 2const uefi = std.os.uefi;
 3const Guid = uefi.Guid;
 4const File = uefi.protocol.File;
 5const Status = uefi.Status;
 6const cc = uefi.cc;
 7const Error = Status.Error;
 8
 9pub const SimpleFileSystem = extern struct {
10    revision: u64,
11    _open_volume: *const fn (*const SimpleFileSystem, **File) callconv(cc) Status,
12
13    pub const OpenVolumeError = uefi.UnexpectedError || error{
14        Unsupported,
15        NoMedia,
16        DeviceError,
17        VolumeCorrupted,
18        AccessDenied,
19        OutOfResources,
20        MediaChanged,
21    };
22
23    pub fn openVolume(self: *const SimpleFileSystem) OpenVolumeError!*File {
24        var root: *File = undefined;
25        switch (self._open_volume(self, &root)) {
26            .success => return root,
27            .unsupported => return Error.Unsupported,
28            .no_media => return Error.NoMedia,
29            .device_error => return Error.DeviceError,
30            .volume_corrupted => return Error.VolumeCorrupted,
31            .access_denied => return Error.AccessDenied,
32            .out_of_resources => return Error.OutOfResources,
33            .media_changed => return Error.MediaChanged,
34            else => |status| return uefi.unexpectedStatus(status),
35        }
36    }
37
38    pub const guid align(8) = Guid{
39        .time_low = 0x0964e5b22,
40        .time_mid = 0x6459,
41        .time_high_and_version = 0x11d2,
42        .clock_seq_high_and_reserved = 0x8e,
43        .clock_seq_low = 0x39,
44        .node = [_]u8{ 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b },
45    };
46};