diff options
| author | Bobby <[email protected]> | 2026-07-12 05:17:19 +0530 |
|---|---|---|
| committer | Bobby <[email protected]> | 2026-07-12 05:17:19 +0530 |
| commit | cfcee2cbb3f6daeb20ee62fcc411c99ca02f7dec (patch) | |
| tree | bb4580d0c719ed6e3659f38e552c23cd9ac692cb /shared/fs/afs | |
| parent | 174951500db9ee02ad537cf163d83f9b8dcd9b82 (diff) | |
| download | akiba-cfcee2cbb3f6daeb20ee62fcc411c99ca02f7dec.tar.xz akiba-cfcee2cbb3f6daeb20ee62fcc411c99ca02f7dec.zip | |
Sweep: extract crimson/render strings, move pure-constant files into constants/ subfolders, strip explanatory comments and multi-line headers tree-wide, zig fmt
Diffstat (limited to 'shared/fs/afs')
| -rw-r--r-- | shared/fs/afs/afs.zig | 3 | ||||
| -rw-r--r-- | shared/fs/afs/btree/btree.zig | 2 | ||||
| -rw-r--r-- | shared/fs/afs/btree/node.zig | 5 | ||||
| -rw-r--r-- | shared/fs/afs/btree/search.zig | 7 | ||||
| -rw-r--r-- | shared/fs/afs/constants/constants.zig | 1 | ||||
| -rw-r--r-- | shared/fs/afs/constants/flags.zig | 5 | ||||
| -rw-r--r-- | shared/fs/afs/constants/magic.zig | 4 | ||||
| -rw-r--r-- | shared/fs/afs/io/block.zig | 3 | ||||
| -rw-r--r-- | shared/fs/afs/read/location.zig | 5 | ||||
| -rw-r--r-- | shared/fs/afs/read/read.zig | 2 | ||||
| -rw-r--r-- | shared/fs/afs/read/unit.zig | 3 | ||||
| -rw-r--r-- | shared/fs/afs/types/types.zig | 7 | ||||
| -rw-r--r-- | shared/fs/afs/write/allocate.zig | 8 | ||||
| -rw-r--r-- | shared/fs/afs/write/stack.zig | 4 | ||||
| -rw-r--r-- | shared/fs/afs/write/unit.zig | 5 | ||||
| -rw-r--r-- | shared/fs/afs/write/write.zig | 3 |
16 files changed, 0 insertions, 67 deletions
diff --git a/shared/fs/afs/afs.zig b/shared/fs/afs/afs.zig index 42990ee..9c494af 100644 --- a/shared/fs/afs/afs.zig +++ b/shared/fs/afs/afs.zig @@ -7,7 +7,6 @@ pub const btree = @import("btree/btree.zig"); pub const read = @import("read/read.zig"); pub const write = @import("write/write.zig"); -// Re-export commonly used types pub const VolumeHeader = types.VolumeHeader; pub const SpanDescriptor = types.SpanDescriptor; pub const ChannelInfo = types.ChannelInfo; @@ -19,13 +18,11 @@ pub const BTreeHeaderRecord = types.BTreeHeaderRecord; pub const IndexKey = types.IndexKey; pub const Permissions = types.Permissions; -// Re-export I/O interfaces pub const BlockReader = io.BlockReader; pub const BlockWriter = io.BlockWriter; pub const BlockDevice = io.BlockDevice; pub const BlockError = io.BlockError; -// Re-export errors pub const BTreeError = btree.BTreeError; pub const ReadError = read.ReadError; pub const WriteError = write.WriteError; diff --git a/shared/fs/afs/btree/btree.zig b/shared/fs/afs/btree/btree.zig index ba72f99..cac9e36 100644 --- a/shared/fs/afs/btree/btree.zig +++ b/shared/fs/afs/btree/btree.zig @@ -3,7 +3,6 @@ pub const node = @import("node.zig"); pub const search = @import("search.zig"); -// Node operations pub const get_node_cell = node.get_node_cell; pub const get_node_offset_in_cell = node.get_node_offset_in_cell; pub const get_record_offset = node.get_record_offset; @@ -11,7 +10,6 @@ pub const get_record_ptr = node.get_record_ptr; pub const get_record_ptr_const = node.get_record_ptr_const; pub const NodeError = node.NodeError; -// Search operations pub const compare_keys = search.compare_keys; pub const search_index_node = search.search_index_node; pub const search_leaf_for_unit = search.search_leaf_for_unit; diff --git a/shared/fs/afs/btree/node.zig b/shared/fs/afs/btree/node.zig index d2ccc73..5fe161f 100644 --- a/shared/fs/afs/btree/node.zig +++ b/shared/fs/afs/btree/node.zig @@ -13,32 +13,27 @@ pub const NodeError = error{ OutOfBounds, }; -/// Calculate the cell containing a node pub fn get_node_cell(node_number: u32, cell_size: u32, node_size: u32) u64 { const nodes_per_cell = cell_size / node_size; return node_number / nodes_per_cell; } -/// Calculate offset of a node within a cell pub fn get_node_offset_in_cell(node_number: u32, cell_size: u32, node_size: u32) u32 { const nodes_per_cell = cell_size / node_size; return (node_number % nodes_per_cell) * node_size; } -/// Get record offset from the offset table at the end of the node pub fn get_record_offset(node_buffer: [*]const u8, node_size: u32, record_index: u16) u16 { const offset_table_start = node_size - (@as(u32, record_index) + 1) * 2; const offset_ptr: *align(1) const u16 = @ptrCast(node_buffer + offset_table_start); return offset_ptr.*; } -/// Get pointer to a record in the node buffer pub fn get_record_ptr(node_buffer: [*]u8, node_size: u32, record_index: u16) [*]u8 { const offset = get_record_offset(node_buffer, node_size, record_index); return node_buffer + offset; } -/// Get const pointer to a record in the node buffer pub fn get_record_ptr_const(node_buffer: [*]const u8, node_size: u32, record_index: u16) [*]const u8 { const offset = get_record_offset(node_buffer, node_size, record_index); return node_buffer + offset; diff --git a/shared/fs/afs/btree/search.zig b/shared/fs/afs/btree/search.zig index 85f7c4b..93614d1 100644 --- a/shared/fs/afs/btree/search.zig +++ b/shared/fs/afs/btree/search.zig @@ -10,8 +10,6 @@ const StackRecord = types.StackRecord; const UnitRecord = types.UnitRecord; const ThreadRecord = types.ThreadRecord; -/// Compare search key against a B-tree key -/// Returns: -1 if search < key, 0 if equal, 1 if search > key pub fn compare_keys(parent_node_id: u32, identity: []const u16, key: *align(1) const IndexKey) i32 { if (parent_node_id < key.parent_node_id) { return -1; @@ -45,7 +43,6 @@ pub fn compare_keys(parent_node_id: u32, identity: []const u16, key: *align(1) c return 0; } -/// Search an index node for the child pointer to follow pub fn search_index_node( node_buffer: [*]const u8, node_size: u32, @@ -65,7 +62,6 @@ pub fn search_index_node( } } - // Return last child pointer if search key is greater than all keys if (record_count > 0) { const last_record = node_ops.get_record_ptr_const(node_buffer, node_size, record_count - 1); const last_key: *align(1) const IndexKey = @ptrCast(last_record); @@ -76,7 +72,6 @@ pub fn search_index_node( return null; } -/// Search a leaf node for a unit record pub fn search_leaf_for_unit( node_buffer: [*]const u8, node_size: u32, @@ -104,7 +99,6 @@ pub fn search_leaf_for_unit( return null; } -/// Search a leaf node for a stack record pub fn search_leaf_for_stack( node_buffer: [*]const u8, node_size: u32, @@ -132,7 +126,6 @@ pub fn search_leaf_for_stack( return null; } -/// Search a leaf node for a thread record pub fn search_leaf_for_thread( node_buffer: [*]const u8, node_size: u32, diff --git a/shared/fs/afs/constants/constants.zig b/shared/fs/afs/constants/constants.zig index 2478a86..6be89a4 100644 --- a/shared/fs/afs/constants/constants.zig +++ b/shared/fs/afs/constants/constants.zig @@ -7,7 +7,6 @@ pub const records = @import("records.zig"); pub const btree = @import("btree.zig"); pub const flags = @import("flags.zig"); -// Re-export commonly used constants pub const signature = magic.signature; pub const version = magic.version; pub const journal_signature = magic.journal_signature; diff --git a/shared/fs/afs/constants/flags.zig b/shared/fs/afs/constants/flags.zig index 3ac1143..32daaa9 100644 --- a/shared/fs/afs/constants/flags.zig +++ b/shared/fs/afs/constants/flags.zig @@ -1,6 +1,5 @@ //! AFS Flags -// Unit flags pub const unit_locked: u16 = 0x0001; pub const unit_has_thread: u16 = 0x0002; pub const unit_has_alias: u16 = 0x0004; @@ -8,21 +7,17 @@ pub const unit_has_security: u16 = 0x0008; pub const unit_has_twins: u16 = 0x0010; pub const unit_has_resource_channel: u16 = 0x0020; -// Channel types pub const channel_data: u8 = 0x00; pub const channel_resource: u8 = 0xFF; -// Compression types pub const compression_none: u32 = 0; pub const compression_zlib: u32 = 1; pub const compression_lz4: u32 = 2; pub const compression_zstd: u32 = 3; -// Encryption types pub const encryption_none: u32 = 0; pub const encryption_aes_128_xts: u32 = 1; pub const encryption_aes_256_xts: u32 = 2; -// Journal flags pub const journal_on_other_device: u32 = 0x00000001; pub const journal_needs_init: u32 = 0x00000002; diff --git a/shared/fs/afs/constants/magic.zig b/shared/fs/afs/constants/magic.zig index 84f46db..f268615 100644 --- a/shared/fs/afs/constants/magic.zig +++ b/shared/fs/afs/constants/magic.zig @@ -1,15 +1,11 @@ //! AFS Magic Numbers and Signatures -/// "AKIBAFS!" signature pub const signature: u64 = 0x2153464142494B41; -/// AFS version pub const version: u16 = 0x0001; -/// "JNRL" journal signature pub const journal_signature: u32 = 0x4A4E524C; -/// AFS partition type GUID: 414B4942-4146-5300-0000-000000000001 pub const partition_type_guid = [16]u8{ 0x42, 0x49, 0x4B, 0x41, 0x46, 0x41, 0x00, 0x53, diff --git a/shared/fs/afs/io/block.zig b/shared/fs/afs/io/block.zig index 8abd71c..8475562 100644 --- a/shared/fs/afs/io/block.zig +++ b/shared/fs/afs/io/block.zig @@ -9,7 +9,6 @@ pub const BlockError = error{ NotSupported, }; -/// Block reader interface - implemented by each consumer pub const BlockReader = struct { context: *anyopaque, read_fn: *const fn (context: *anyopaque, cell: u64, buffer: []u8) BlockError!void, @@ -40,7 +39,6 @@ pub const BlockReader = struct { } }; -/// Block writer interface - implemented by each consumer pub const BlockWriter = struct { context: *anyopaque, write_fn: *const fn (context: *anyopaque, cell: u64, data: []const u8) BlockError!void, @@ -71,7 +69,6 @@ pub const BlockWriter = struct { } }; -/// Combined reader/writer for read-write operations pub const BlockDevice = struct { reader: BlockReader, writer: BlockWriter, diff --git a/shared/fs/afs/read/location.zig b/shared/fs/afs/read/location.zig index ef145fc..f76b9d4 100644 --- a/shared/fs/afs/read/location.zig +++ b/shared/fs/afs/read/location.zig @@ -13,14 +13,12 @@ pub const LocationError = error{ BTreeError, }; -/// Result of looking up a location pub const LookupResult = union(enum) { unit: UnitRecord, stack: StackRecord, not_found: void, }; -/// Convert ASCII location component to UTF-16 identity pub fn component_to_identity(component: []const u8, identity_buffer: []u16) usize { var len: usize = 0; for (component) |byte| { @@ -31,14 +29,12 @@ pub fn component_to_identity(component: []const u8, identity_buffer: []u16) usiz return len; } -/// Iterator for location components pub const LocationIterator = struct { location: []const u8, position: usize, pub fn init(location: []const u8) LocationIterator { var start: usize = 0; - // Skip leading separator if (location.len > 0 and (location[0] == '/' or location[0] == '\\')) { start = 1; } @@ -49,7 +45,6 @@ pub const LocationIterator = struct { } pub fn next(self: *LocationIterator) ?[]const u8 { - // Skip empty components while (self.position < self.location.len and (self.location[self.position] == '/' or self.location[self.position] == '\\')) { diff --git a/shared/fs/afs/read/read.zig b/shared/fs/afs/read/read.zig index 7b232db..6adb4be 100644 --- a/shared/fs/afs/read/read.zig +++ b/shared/fs/afs/read/read.zig @@ -3,13 +3,11 @@ pub const unit = @import("unit.zig"); pub const location = @import("location.zig"); -// Unit operations pub const read_span = unit.read_span; pub const read_unit_inline_spans = unit.read_unit_inline_spans; pub const read_unit = unit.read_unit; pub const ReadError = unit.ReadError; -// Location operations pub const component_to_identity = location.component_to_identity; pub const LocationIterator = location.LocationIterator; pub const LocationError = location.LocationError; diff --git a/shared/fs/afs/read/unit.zig b/shared/fs/afs/read/unit.zig index cecd5f7..46a7b82 100644 --- a/shared/fs/afs/read/unit.zig +++ b/shared/fs/afs/read/unit.zig @@ -17,7 +17,6 @@ pub const ReadError = error{ BufferTooSmall, }; -/// Read data from a span into a buffer pub fn read_span( reader: *const BlockReader, span: *const SpanDescriptor, @@ -50,7 +49,6 @@ pub fn read_span( return bytes_read; } -/// Read unit data using inline spans pub fn read_unit_inline_spans( reader: *const BlockReader, channel: *const ChannelInfo, @@ -86,7 +84,6 @@ pub fn read_unit_inline_spans( return bytes_read; } -/// Read entire unit data (inline spans only, no overflow support yet) pub fn read_unit( reader: *const BlockReader, unit: *const UnitRecord, diff --git a/shared/fs/afs/types/types.zig b/shared/fs/afs/types/types.zig index 151435e..21d5ad6 100644 --- a/shared/fs/afs/types/types.zig +++ b/shared/fs/afs/types/types.zig @@ -8,17 +8,14 @@ pub const attributes = @import("attributes.zig"); pub const journal = @import("journal.zig"); pub const timestamp = @import("timestamp.zig"); -// Volume types pub const VolumeHeader = volume.VolumeHeader; pub const SpanDescriptor = volume.SpanDescriptor; pub const ChannelInfo = volume.ChannelInfo; -// B-tree types pub const BTreeNodeDescriptor = btree.NodeDescriptor; pub const BTreeHeaderRecord = btree.HeaderRecord; pub const IndexKey = btree.IndexKey; -// Catalog types pub const StackRecord = catalog.StackRecord; pub const UnitRecord = catalog.UnitRecord; pub const ThreadRecord = catalog.ThreadRecord; @@ -28,20 +25,16 @@ pub const SpecialInfo = catalog.SpecialInfo; pub const AliasInfo = catalog.AliasInfo; pub const TwinInfo = catalog.TwinInfo; -// Extent types pub const SpanKey = extents.SpanKey; pub const SpanRecord = extents.SpanRecord; -// Attribute types pub const AttributeKey = attributes.AttributeKey; pub const AttributeInlineRecord = attributes.AttributeInlineRecord; pub const AttributeChannelRecord = attributes.AttributeChannelRecord; -// Journal types pub const JournalInfoCell = journal.JournalInfoCell; pub const JournalHeader = journal.JournalHeader; pub const JournalCellList = journal.JournalCellList; pub const JournalCellInfo = journal.JournalCellInfo; -// Timestamp pub const Timestamp = timestamp.Timestamp; diff --git a/shared/fs/afs/write/allocate.zig b/shared/fs/afs/write/allocate.zig index 2377f4f..9573a88 100644 --- a/shared/fs/afs/write/allocate.zig +++ b/shared/fs/afs/write/allocate.zig @@ -5,7 +5,6 @@ pub const AllocationError = error{ InvalidCell, }; -/// Allocation bitmap operations pub const AllocationMap = struct { bitmap: []u8, total_cells: u32, @@ -19,7 +18,6 @@ pub const AllocationMap = struct { }; } - /// Mark a cell as allocated pub fn mark_allocated(self: *AllocationMap, cell: u32) void { if (cell >= self.total_cells) return; const byte_index = cell / 8; @@ -27,7 +25,6 @@ pub const AllocationMap = struct { self.bitmap[byte_index] |= @as(u8, 1) << bit_index; } - /// Mark a cell as free pub fn mark_free(self: *AllocationMap, cell: u32) void { if (cell >= self.total_cells) return; const byte_index = cell / 8; @@ -35,7 +32,6 @@ pub const AllocationMap = struct { self.bitmap[byte_index] &= ~(@as(u8, 1) << bit_index); } - /// Check if a cell is allocated pub fn is_allocated(self: *const AllocationMap, cell: u32) bool { if (cell >= self.total_cells) return true; const byte_index = cell / 8; @@ -43,7 +39,6 @@ pub const AllocationMap = struct { return (self.bitmap[byte_index] & (@as(u8, 1) << bit_index)) != 0; } - /// Allocate a contiguous range of cells pub fn allocate_cells(self: *AllocationMap, count: u32) AllocationError!u32 { if (count == 0) return self.next_free; @@ -61,7 +56,6 @@ pub const AllocationMap = struct { return start; } - /// Mark a range of cells as allocated (for reserved areas) pub fn reserve_range(self: *AllocationMap, start: u32, count: u32) void { var i: u32 = 0; while (i < count) : (i += 1) { @@ -69,7 +63,6 @@ pub const AllocationMap = struct { } } - /// Get count of free cells pub fn free_count(self: *const AllocationMap) u32 { var count: u32 = 0; var i: u32 = 0; @@ -82,7 +75,6 @@ pub const AllocationMap = struct { } }; -/// Calculate bitmap size needed for a given number of cells pub fn bitmap_size(total_cells: u32) u32 { return (total_cells + 7) / 8; } diff --git a/shared/fs/afs/write/stack.zig b/shared/fs/afs/write/stack.zig index 69afd53..0507bae 100644 --- a/shared/fs/afs/write/stack.zig +++ b/shared/fs/afs/write/stack.zig @@ -10,7 +10,6 @@ const IndexKey = types.IndexKey; const Permissions = types.Permissions; const ChannelInfo = types.ChannelInfo; -/// Create a stack record pub fn create_stack_record( node_id: u32, timestamp: u64, @@ -40,7 +39,6 @@ pub fn create_stack_record( }; } -/// Create a unit record pub fn create_unit_record( node_id: u32, timestamp: u64, @@ -73,7 +71,6 @@ pub fn create_unit_record( }; } -/// Create an index key for a catalog entry pub fn create_index_key( parent_node_id: u32, identity: []const u8, @@ -91,7 +88,6 @@ pub fn create_index_key( return key; } -/// Get the size of an index key in bytes pub fn index_key_size(identity_len: usize) usize { return 8 + identity_len * 2; } diff --git a/shared/fs/afs/write/unit.zig b/shared/fs/afs/write/unit.zig index a20da4e..0162219 100644 --- a/shared/fs/afs/write/unit.zig +++ b/shared/fs/afs/write/unit.zig @@ -15,7 +15,6 @@ pub const WriteError = error{ InvalidCell, }; -/// Write data to a span pub fn write_span( writer: *const BlockWriter, span: *const SpanDescriptor, @@ -29,7 +28,6 @@ pub fn write_span( var current_cell = span.start_cell; while (bytes_written < bytes_to_write) { - // Clear cell buffer for (cell_buffer) |*b| { b.* = 0; } @@ -37,7 +35,6 @@ pub fn write_span( const bytes_remaining = bytes_to_write - bytes_written; const bytes_to_copy = if (bytes_remaining < writer.cell_size) bytes_remaining else writer.cell_size; - // Copy data to cell buffer var i: u64 = 0; while (i < bytes_to_copy) : (i += 1) { cell_buffer[@intCast(i)] = data[@intCast(bytes_written + i)]; @@ -54,13 +51,11 @@ pub fn write_span( return bytes_written; } -/// Calculate number of cells needed for a given size pub fn cells_needed(size: u64, cell_size: u32) u32 { if (size == 0) return 0; return @intCast((size + cell_size - 1) / cell_size); } -/// Create a channel info for inline data pub fn create_channel_info( logical_size: u64, start_cell: u64, diff --git a/shared/fs/afs/write/write.zig b/shared/fs/afs/write/write.zig index b33ed3b..c4c1727 100644 --- a/shared/fs/afs/write/write.zig +++ b/shared/fs/afs/write/write.zig @@ -4,18 +4,15 @@ pub const unit = @import("unit.zig"); pub const allocate = @import("allocate.zig"); pub const stack = @import("stack.zig"); -// Unit operations pub const write_span = unit.write_span; pub const cells_needed = unit.cells_needed; pub const create_channel_info = unit.create_channel_info; pub const WriteError = unit.WriteError; -// Allocation operations pub const AllocationMap = allocate.AllocationMap; pub const AllocationError = allocate.AllocationError; pub const bitmap_size = allocate.bitmap_size; -// Stack operations pub const create_stack_record = stack.create_stack_record; pub const create_unit_record = stack.create_unit_record; pub const create_index_key = stack.create_index_key; |
