Messing around with thing.
Things not working.
This commit is contained in:
+10
-6
@@ -1,7 +1,11 @@
|
||||
const std = @import("std");
|
||||
const io = std.io;
|
||||
|
||||
pub const BlockSize = packed struct { size: u23, not_compressed: bool, _: u8 };
|
||||
pub const BlockSize = packed struct {
|
||||
size: u23,
|
||||
not_compressed: bool,
|
||||
_: u8,
|
||||
};
|
||||
|
||||
pub const FileInode = struct {
|
||||
data_start: u32,
|
||||
@@ -11,8 +15,8 @@ pub const FileInode = struct {
|
||||
blocks: []const BlockSize,
|
||||
|
||||
pub fn init(alloc: std.mem.Allocator, rdr: io.AnyReader, block_size: u32) !FileInode {
|
||||
const fixed_buf = [_]u8{0} ** 16;
|
||||
_ = try rdr.readAll(&fixed_buf);
|
||||
var fixed_buf = [_]u8{0} ** 16;
|
||||
_ = try rdr.readAll(@ptrCast(&fixed_buf));
|
||||
const frag_idx = std.mem.bytesToValue(u32, fixed_buf[4..8]);
|
||||
const size = std.mem.bytesToValue(u32, fixed_buf[12..16]);
|
||||
var block_num = size / block_size;
|
||||
@@ -20,7 +24,7 @@ pub const FileInode = struct {
|
||||
block_num += 1;
|
||||
}
|
||||
const blocks = try alloc.alloc(BlockSize, block_num);
|
||||
_ = try rdr.readAll(std.mem.asBytes(blocks));
|
||||
_ = try rdr.readAll(@ptrCast(blocks));
|
||||
return .{
|
||||
.data_start = std.mem.bytesToValue(u32, fixed_buf[0..4]),
|
||||
.frag_idx = frag_idx,
|
||||
@@ -45,7 +49,7 @@ pub const ExtFileInode = struct {
|
||||
blocks: []const BlockSize,
|
||||
|
||||
pub fn init(alloc: std.mem.Allocator, rdr: io.AnyReader, block_size: u32) !ExtFileInode {
|
||||
const fixed_buf = [_]u8{0} ** 40;
|
||||
var fixed_buf = [_]u8{0} ** 40;
|
||||
_ = try rdr.readAll(&fixed_buf);
|
||||
const size = std.mem.bytesToValue(u64, fixed_buf[8..16]);
|
||||
const frag_idx = std.mem.bytesToValue(u32, fixed_buf[28..32]);
|
||||
@@ -54,7 +58,7 @@ pub const ExtFileInode = struct {
|
||||
block_num += 1;
|
||||
}
|
||||
const blocks = try alloc.alloc(BlockSize, block_num);
|
||||
_ = try rdr.readAll(std.mem.asBytes(blocks));
|
||||
_ = try rdr.readAll(@ptrCast(blocks));
|
||||
return .{
|
||||
.data_start = std.mem.bytesToValue(u64, fixed_buf[0..8]),
|
||||
.size = size,
|
||||
|
||||
+8
-1
@@ -4,7 +4,14 @@ const io = std.io;
|
||||
pub const InodeRef = packed struct {
|
||||
offset: u16,
|
||||
block_start: u32,
|
||||
_: u16,
|
||||
_: u16 = 0,
|
||||
|
||||
pub fn init(block_start: u32, offset: u16) InodeRef {
|
||||
return .{
|
||||
.offset = offset,
|
||||
.block_start = block_start,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
pub const InodeType = enum(u16) {
|
||||
|
||||
+4
-4
@@ -7,8 +7,8 @@ pub const SymInode = struct {
|
||||
target: []const u8,
|
||||
|
||||
pub fn init(alloc: std.mem.Allocator, rdr: io.AnyReader) !SymInode {
|
||||
const fixed_buf = [_]u8{0} ** 8;
|
||||
_ = try rdr.readAll(&fixed_buf);
|
||||
var fixed_buf = [_]u8{0} ** 8;
|
||||
_ = try rdr.readAll(@ptrCast(&fixed_buf));
|
||||
const size = std.mem.bytesToValue(u32, fixed_buf[4..]);
|
||||
const target = try alloc.alloc(u8, size);
|
||||
_ = try rdr.readAll(target);
|
||||
@@ -30,7 +30,7 @@ pub const ExtSymInode = struct {
|
||||
xattr_idx: u32,
|
||||
|
||||
pub fn init(alloc: std.mem.Allocator, rdr: io.AnyReader) !ExtSymInode {
|
||||
const fixed_buf = [_]u8{0} ** 8;
|
||||
var fixed_buf = [_]u8{0} ** 8;
|
||||
_ = try rdr.readAll(&fixed_buf);
|
||||
const size = std.mem.bytesToValue(u32, fixed_buf[4..]);
|
||||
const target = try alloc.alloc(u8, size);
|
||||
@@ -39,7 +39,7 @@ pub const ExtSymInode = struct {
|
||||
.hard_links = std.mem.bytesToValue(u32, fixed_buf[0..4]),
|
||||
.size = size,
|
||||
.target = target,
|
||||
.xattr_idx = rdr.readInt(u32, std.builtin.Endian.little),
|
||||
.xattr_idx = try rdr.readInt(u32, std.builtin.Endian.little),
|
||||
};
|
||||
}
|
||||
pub fn deinit(self: ExtSymInode, alloc: std.mem.Allocator) void {
|
||||
|
||||
Reference in New Issue
Block a user