aboutsummaryrefslogtreecommitdiff
path: root/mirai.old/fs/afs/types.zig
blob: 77ad08406601f36bbe3cb77c1c4cbc5e88e06092 (plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//! AFS type definitions

const fs = @import("../../common/constants/fs.zig");

pub const BootSector = extern struct {
    signature: [8]u8,
    version: u32,
    bytes_per_sector: u32,
    sectors_per_cluster: u32,
    total_clusters: u32,
    root_cluster: u32,
    alloc_table_sector: u32,
    alloc_table_size: u32,
    data_area_sector: u32,
    used_clusters: u32,
    reserved: [462]u8,
    boot_signature: u16,
};

pub const Entry = extern struct {
    entry_type: u8,
    name_len: u8,
    name: [fs.MAX_IDENTITY_LEN]u8,
    owner_name_len: u8,
    owner_name: [fs.MAX_OWNER_NAME_LEN]u8,
    permission_type: u8,
    reserved: u8,
    first_cluster: u32,
    size: u64,
    created_time: u64,
    modified_time: u64,

    pub fn get_identity(self: *const Entry) []const u8 {
        return self.name[0..self.name_len];
    }

    pub fn get_owner(self: *const Entry) []const u8 {
        return self.owner_name[0..self.owner_name_len];
    }

    pub fn is_unit(self: *const Entry) bool {
        return self.entry_type == fs.ENTRY_TYPE_UNIT;
    }

    pub fn is_stack(self: *const Entry) bool {
        return self.entry_type == fs.ENTRY_TYPE_STACK;
    }

    pub fn is_end(self: *const Entry) bool {
        return self.entry_type == fs.ENTRY_TYPE_END;
    }
};

pub const StackItem = struct {
    identity: [fs.MAX_LOCATION_LENGTH]u8,
    identity_len: usize,
    is_stack: bool,
    size: u32,
    modified_time: u64,
    owner_name: [fs.MAX_OWNER_NAME_LEN]u8,
    owner_name_len: usize,
    permission_type: u8,

    pub fn get_identity(self: *const StackItem) []const u8 {
        return self.identity[0..self.identity_len];
    }

    pub fn get_owner(self: *const StackItem) []const u8 {
        return self.owner_name[0..self.owner_name_len];
    }
};

pub const ParentCacheEntry = struct {
    cluster: u32,
    parent: u32,
};

pub const DiskInfo = struct {
    total_bytes: u64,
    used_bytes: u64,
};