aboutsummaryrefslogtreecommitdiff
path: root/toolchain
diff options
context:
space:
mode:
authorBobby <[email protected]>2026-01-27 17:32:49 +0530
committerBobby <[email protected]>2026-01-27 17:32:49 +0530
commit2d96b6d09e8ea04b1cf3b421c22a6bf1cfd11c04 (patch)
tree8096a8140eb5a10c9e09a91f1c763fa5da88842d /toolchain
parent2b2854aa80e61f4e68f2284bd307696b97339e69 (diff)
downloadakiba-2d96b6d09e8ea04b1cf3b421c22a6bf1cfd11c04.tar.xz
akiba-2d96b6d09e8ea04b1cf3b421c22a6bf1cfd11c04.zip
feat: Add owner and permission fields to AFS directory entry structure
Diffstat (limited to 'toolchain')
-rw-r--r--toolchain/grub-afs/afs.c6
-rw-r--r--toolchain/mkafsdisk/main.zig35
2 files changed, 37 insertions, 4 deletions
diff --git a/toolchain/grub-afs/afs.c b/toolchain/grub-afs/afs.c
index b412be5..536c189 100644
--- a/toolchain/grub-afs/afs.c
+++ b/toolchain/grub-afs/afs.c
@@ -31,8 +31,10 @@ struct afs_dir_entry
grub_uint8_t entry_type;
grub_uint8_t name_len;
grub_uint8_t name[255];
- grub_uint8_t attributes;
- grub_uint16_t reserved;
+ grub_uint8_t owner_name_len;
+ grub_uint8_t owner_name[64];
+ grub_uint8_t permission_type;
+ grub_uint8_t reserved;
grub_uint32_t first_cluster;
grub_uint64_t file_size;
grub_uint64_t created_time;
diff --git a/toolchain/mkafsdisk/main.zig b/toolchain/mkafsdisk/main.zig
index ae970fa..ab932f0 100644
--- a/toolchain/mkafsdisk/main.zig
+++ b/toolchain/mkafsdisk/main.zig
@@ -22,8 +22,10 @@ const AFSDirEntry = extern struct {
entry_type: u8,
name_len: u8,
name: [255]u8,
- attributes: u8,
- reserved: u16,
+ owner_name_len: u8,
+ owner_name: [64]u8,
+ permission_type: u8, // 1=OA, 2=WA, 3=WR
+ reserved: u8,
first_cluster: u32,
file_size: u64,
created_time: u64,
@@ -34,6 +36,10 @@ const ENTRY_TYPE_END: u8 = 0x00;
const ENTRY_TYPE_FILE: u8 = 0x01;
const ENTRY_TYPE_DIR: u8 = 0x02;
+const PERM_OWNER: u8 = 1; // OA - Owner All
+const PERM_WORLD: u8 = 2; // WA - World All
+const PERM_READ_ONLY: u8 = 3; // WR - World Read
+
const FATDateTime = struct {
date: u16,
time: u16,
@@ -703,6 +709,31 @@ fn copyDirectoryAFS(allocator: mem.Allocator, file: fs.File, dir_path: []const u
afs_entry.name_len = @intCast(name.len);
@memcpy(afs_entry.name[0..name.len], name);
+ // Set owner to "akiba"
+ const owner = "akiba";
+ afs_entry.owner_name_len = @intCast(owner.len);
+ @memcpy(afs_entry.owner_name[0..owner.len], owner);
+
+ // Set permissions based on directory
+ // system/ - WR, EFI/ - WR, boot/ - WR, binaries/ - WA
+ const is_system = std.mem.indexOf(u8, dir_path, "/system") != null or std.mem.eql(u8, name, "system");
+ const is_efi = std.mem.indexOf(u8, dir_path, "/EFI") != null or std.mem.eql(u8, name, "EFI");
+ const is_boot = std.mem.indexOf(u8, dir_path, "/boot") != null or std.mem.eql(u8, name, "boot");
+ const is_binaries = std.mem.indexOf(u8, dir_path, "/binaries") != null or std.mem.eql(u8, name, "binaries");
+
+ if (is_binaries) {
+ afs_entry.permission_type = PERM_WORLD;
+ } else if (is_system or is_efi or is_boot) {
+ afs_entry.permission_type = PERM_READ_ONLY;
+ } else {
+ afs_entry.permission_type = PERM_OWNER;
+ }
+ afs_entry.reserved = 0;
+
+ const current_time = std.time.timestamp();
+ afs_entry.created_time = @intCast(current_time);
+ afs_entry.modified_time = @intCast(current_time);
+
if (entry.kind == .directory) {
const new_cluster = try cluster_alloc.allocate(10);
afs_entry.first_cluster = new_cluster;