This commit is contained in:
Caleb Gardner
2025-05-16 06:59:21 -05:00
parent 986f308c60
commit ff2ef6feaa
5 changed files with 62 additions and 1 deletions
+34
View File
@@ -0,0 +1,34 @@
const io = @import("std").io;
pub const DirInode = packed struct {
block_start: u32,
hard_links: u32,
/// Note: size is 3 larger then the actual size, due to "." and ".."
size: u16,
offset: u16,
parent_num: u32,
pub fn init(rdr: io.AnyReader) !DirInode {
return rdr.readStruct(DirInode);
}
};
const DirIndex = struct {
}
pub const ExtDirInode = packed struct {
hard_links: u32,
/// Note: size is 3 larger then the actual size, due to "." and ".."
size: u32,
block_start: u32,
parent_num: u32,
index_count: u16,
offset: u16,
xattr_inx: u32,
// TODO: possibly also read dir indexes. Maybe relagate to function...
pub fn init(rdr: io.AnyReader) !ExtDirInode {
return rdr.readStruct(ExtDirInode);
}
};
View File
+28 -1
View File
@@ -1,3 +1,6 @@
const std = @import("std");
const io = std.io;
pub const InodeRef = packed struct {
offset: u16,
block_start: u32,
@@ -21,6 +24,28 @@ pub const InodeType = enum(u16) {
ext_sock,
};
const dir = @import("dir.zig");
const file = @import("file.zig");
const sym = @import("sym.zig");
const misc = @import("misc.zig");
pub const InodeData = union(enum) {
dir: dir.DirInode,
file: file.FileInode,
sym: sym.SymInode,
block: misc.DeviceInode,
char: misc.DeviceInode,
fifo: misc.IPCInode,
sock: misc.IPCInode,
ext_dir: dir.ExtDirInode,
ext_file: file.ExtFileInode,
ext_sym: sym.ExtSymInode,
ext_block: misc.ExtDeviceInode,
ext_char: misc.ExtDeviceInode,
ext_fifo: misc.ExtIPCInode,
ext_sock: misc.ExtIPCInode,
};
pub const InodeHeader = packed struct {
inode_type: InodeType,
perm: u16,
@@ -32,5 +57,7 @@ pub const InodeHeader = packed struct {
pub const Inode = struct {
header: InodeHeader,
data: void, //TODO
data: InodeData, //TODO
pub fn init(rdr: io.AnyReader) !Inode {}
};
View File
View File