From 4ad1519e06504303dcebe9239850f3c93d87c0bd Mon Sep 17 00:00:00 2001 From: kamkow1 Date: Wed, 11 Feb 2026 21:36:50 +0100 Subject: [PATCH] Virtual filesystem and ramdiskfs --- include/m/fs_desc_buffer.h | 12 +++ kernel/amd64/bootmain.c | 8 +- kernel/amd64/smp.c | 2 +- kernel/{rd => fs}/.gitignore | 0 kernel/fs/path.c | 96 ++++++++++++++++++++++++ kernel/fs/path.h | 13 ++++ kernel/fs/ramdiskfs.c | 138 +++++++++++++++++++++++++++++++++++ kernel/fs/ramdiskfs.h | 15 ++++ kernel/fs/src.mk | 7 ++ kernel/fs/vfs.c | 99 +++++++++++++++++++++++++ kernel/fs/vfs.h | 42 +++++++++++ kernel/libk/fieldsizeof.h | 6 ++ kernel/libk/hash.h | 51 +++++++++++++ kernel/libk/lengthof.h | 6 ++ kernel/libk/string.h | 2 + kernel/proc/proc.c | 44 ++++++++--- kernel/proc/proc.h | 2 +- kernel/rd/rd.c | 81 -------------------- kernel/rd/rd.h | 27 ------- kernel/rd/src.mk | 3 - kernel/src.mk | 2 +- 21 files changed, 528 insertions(+), 128 deletions(-) create mode 100644 include/m/fs_desc_buffer.h rename kernel/{rd => fs}/.gitignore (100%) create mode 100644 kernel/fs/path.c create mode 100644 kernel/fs/path.h create mode 100644 kernel/fs/ramdiskfs.c create mode 100644 kernel/fs/ramdiskfs.h create mode 100644 kernel/fs/src.mk create mode 100644 kernel/fs/vfs.c create mode 100644 kernel/fs/vfs.h create mode 100644 kernel/libk/fieldsizeof.h create mode 100644 kernel/libk/hash.h create mode 100644 kernel/libk/lengthof.h delete mode 100644 kernel/rd/rd.c delete mode 100644 kernel/rd/rd.h delete mode 100644 kernel/rd/src.mk diff --git a/include/m/fs_desc_buffer.h b/include/m/fs_desc_buffer.h new file mode 100644 index 0000000..ac67406 --- /dev/null +++ b/include/m/fs_desc_buffer.h @@ -0,0 +1,12 @@ +#ifndef _M_FS_DESC_BUFFER_H +#define _M_FS_DESC_BUFFER_H + +#define FS_FILE 0 +#define FS_DIR 1 + +struct fs_desc_buffer { + int type; + size_t size; +}; + +#endif // _M_FS_DESC_BUFFER_H diff --git a/kernel/amd64/bootmain.c b/kernel/amd64/bootmain.c index 30321eb..00906e9 100644 --- a/kernel/amd64/bootmain.c +++ b/kernel/amd64/bootmain.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -13,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -40,13 +40,15 @@ void bootmain (void) { pmm_init (); mm_init (); - rd_init (); - uacpi_setup_early_table_access ((void*)uacpi_memory_buffer, sizeof (uacpi_memory_buffer)); amd64_ioapic_init (); amd64_hpet_init (); + vfs_init (); + + vfs_create_mountpoint ("ramdisk", VFS_RAMDISKFS); + smp_init (); proc_init (); diff --git a/kernel/amd64/smp.c b/kernel/amd64/smp.c index 73bc217..fd63323 100644 --- a/kernel/amd64/smp.c +++ b/kernel/amd64/smp.c @@ -87,7 +87,7 @@ static void amd64_smp_bootstrap (struct limine_mp_info* mp_info) { atomic_fetch_sub (&cpu_counter, 1); - struct proc* spin_proc = proc_spawn_rd ("spin.exe"); + struct proc* spin_proc = proc_from_file ("ramdisk", "/spin.exe"); struct cpu* spin_cpu = thiscpu; proc_register (spin_proc, &spin_cpu); diff --git a/kernel/rd/.gitignore b/kernel/fs/.gitignore similarity index 100% rename from kernel/rd/.gitignore rename to kernel/fs/.gitignore diff --git a/kernel/fs/path.c b/kernel/fs/path.c new file mode 100644 index 0000000..0109745 --- /dev/null +++ b/kernel/fs/path.c @@ -0,0 +1,96 @@ +#include +#include +#include + +bool path_validate_char (char ch) { + return ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || + (ch == '_') || (ch == '_')); +} + +bool path_validate (const char* path) { + if (path == NULL || *path == '\0') + return false; + + const char* ptr = path; + + if (*ptr == ':') + return false; + + while (*ptr != ':' && *ptr != '\0') { + if (!path_validate_char (*ptr)) + return false; + + ptr++; + } + + if (*ptr != ':') + return false; + + ptr++; + + if (*ptr != '/') + return false; + + while (*ptr != '\0') { + if (*ptr == '/' && *(ptr + 1) == '/') + return false; + + if (!path_validate_char (*ptr)) + return false; + + ptr++; + } + + if (ptr > path && *(ptr - 1) == '/' && *(ptr - 2) != ':') + return false; + + return true; +} + +bool path_parse (const char* source, char* mountpoint, const char** path) { + if (source == NULL || mountpoint == NULL || path == NULL) + return false; + + size_t i = 0; + + while (source[i] != ':' && source[i] != '\0') { + if (i >= (fieldsizeof (struct vfs_mountpoint, key) - 1)) + return false; + + mountpoint[i] = source[i]; + i++; + } + + if (source[i] != ':' || i == 0) + return false; + + mountpoint[i] = '\0'; + + const char* internal_path = &source[i + 1]; + + if (!path_validate (internal_path)) + return false; + + *path = internal_path; + return true; +} + +const char* path_basename (const char* path) { + if (path == NULL) + return NULL; + + const char* last_slash = NULL; + const char* ptr = path; + + while (*ptr != '\0') { + if (*ptr == '/') + last_slash = ptr; + + ptr++; + } + + if (last_slash == NULL) + return path; + + return last_slash + 1; +} diff --git a/kernel/fs/path.h b/kernel/fs/path.h new file mode 100644 index 0000000..c7dfe8a --- /dev/null +++ b/kernel/fs/path.h @@ -0,0 +1,13 @@ +#ifndef _KERNEL_FS_PATH_H +#define _KERNEL_FS_PATH_H + +#include + +/* Path scheme: MOUNTPOINT:/path/to/file.txt */ + +bool path_validate_char (char ch); +bool path_validate (const char* path); +bool path_parse (const char* source, char* mountpoint, const char** path); +const char* path_basename (const char* path); + +#endif // _KERNEL_FS_PATH_H diff --git a/kernel/fs/ramdiskfs.c b/kernel/fs/ramdiskfs.c new file mode 100644 index 0000000..5a5ab2b --- /dev/null +++ b/kernel/fs/ramdiskfs.c @@ -0,0 +1,138 @@ +#include +#include +#include +#include +#include +#include +#include + +struct ramdisk_tar_header { + char filename[100]; + uint8_t mode[8]; + uint8_t uid[8]; + uint8_t gid[8]; + uint8_t size[12]; + uint8_t mtime[12]; + uint8_t checksum[8]; + uint8_t type_flag; +} PACKED; + +struct ramdisk_tar_file { + struct ramdisk_tar_header* header; + uint8_t* content; + size_t size; +}; + +#define RAMDISK_FILES_MAX 128 +#define RAMDISK_PATH "/boot/mop3dist.tar" + +static struct ramdisk_tar_file ramdisk_files[RAMDISK_FILES_MAX]; + +static struct ramdisk_tar_file* ramdisk_get_file (const char* filename) { + for (size_t i = 0; i < RAMDISK_FILES_MAX; i++) { + if ((ramdisk_files[i].header != NULL) && + (memcmp (ramdisk_files[i].header->filename, filename, strlen (filename)) == 0)) + return &ramdisk_files[i]; + } + return NULL; +} + +static size_t ramdisk_tar_get_size (uint8_t* in) { + size_t size = 0; + size_t j; + size_t count = 1; + + for (j = 11; j > 0; j--, count *= 8) + size += ((in[j - 1] - '0') * count); + + return size; +} + +static size_t ramdisk_tar_parse (uint8_t* addr) { + size_t i; + + for (i = 0;; i++) { + struct ramdisk_tar_header* hdr = (struct ramdisk_tar_header*)addr; + + if (hdr->filename[i] == '\0') + break; + + size_t size = ramdisk_tar_get_size (hdr->size); + + ramdisk_files[i].header = hdr; + ramdisk_files[i].content = (uint8_t*)((uintptr_t)hdr + 512); + ramdisk_files[i].size = ramdisk_tar_get_size ((uint8_t*)hdr->size); + + addr += ((size / 512) + 1) * 512; + + if (size % 512) + addr += 512; + } + + return i; +} + +bool ramdiskfs_mount (struct vfs_mountpoint* mountpoint) { + (void)mountpoint; + + struct limine_module_response* module = limine_module_request.response; + + uint8_t* rd_addr = NULL; + + for (size_t i = 0; i < module->module_count; i++) { + struct limine_file* file = module->modules[i]; + + if (memcmp (file->path, RAMDISK_PATH, strlen (RAMDISK_PATH)) == 0) { + rd_addr = file->address; + } + } + + if (rd_addr == NULL) + return false; + + ramdisk_tar_parse (rd_addr); + + return true; +} + +int ramdiskfs_describe (struct vfs_mountpoint* mountpoint, const char* path, + struct fs_desc_buffer* desc) { + (void)mountpoint; + + const char* filename = path_basename (path); + + if (filename == NULL) + return -VFS_BAD_PATH; + + struct ramdisk_tar_file* file = ramdisk_get_file (filename); + + if (file == NULL) + return -VFS_NOT_FOUND; + + desc->size = file->size; + desc->type = FS_FILE; + + return VFS_OK; +} + +int ramdiskfs_read (struct vfs_mountpoint* mountpoint, const char* path, uint8_t* buffer, + size_t off, size_t size) { + (void)mountpoint; + + const char* filename = path_basename (path); + + if (filename == NULL) + return -VFS_BAD_PATH; + + struct ramdisk_tar_file* file = ramdisk_get_file (filename); + + if (file == NULL) + return -VFS_NOT_FOUND; + + if (off + size > file->size) + return -VFS_OOB_ERROR; + + memcpy (buffer, (void*)((uintptr_t)file->content + off), size); + + return VFS_OK; +} diff --git a/kernel/fs/ramdiskfs.h b/kernel/fs/ramdiskfs.h new file mode 100644 index 0000000..cfeeccb --- /dev/null +++ b/kernel/fs/ramdiskfs.h @@ -0,0 +1,15 @@ +#ifndef _KERNEL_FS_RAMDISKFS_H +#define _KERNEL_FS_RAMDISKFS_H + +#include +#include + +struct vfs_mountpoint; + +bool ramdiskfs_mount (struct vfs_mountpoint* mountpoint); +int ramdiskfs_describe (struct vfs_mountpoint* mountpoint, const char* path, + struct fs_desc_buffer* desc); +int ramdiskfs_read (struct vfs_mountpoint* mountpoint, const char* path, uint8_t* buffer, + size_t off, size_t size); + +#endif // _KERNEL_FS_RAMDISKFS_H diff --git a/kernel/fs/src.mk b/kernel/fs/src.mk new file mode 100644 index 0000000..8a9933a --- /dev/null +++ b/kernel/fs/src.mk @@ -0,0 +1,7 @@ +c += fs/vfs.c \ + fs/ramdiskfs.c \ + fs/path.c + +o += fs/vfs.o \ + fs/ramdiskfs.o \ + fs/path.o diff --git a/kernel/fs/vfs.c b/kernel/fs/vfs.c new file mode 100644 index 0000000..09b52f2 --- /dev/null +++ b/kernel/fs/vfs.c @@ -0,0 +1,99 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static struct vfs_mount_table mount_table; + +static struct vfs_mountpoint* vfs_find_mountpoint (const char* mountpoint) { + struct hash_node_link* found_link = NULL; + size_t mountpoint_len = strlen (mountpoint); + uint32_t hash = hash_fnv32 (mountpoint, strlen (mountpoint)); + + spin_lock (&mount_table.lock); + hash_find (&mount_table, mountpoint, mountpoint_len, hash, + lengthof (mount_table.mountpoint_buckets), mountpoint_buckets, struct vfs_mountpoint, + mount_table_link, key, found_link); + spin_unlock (&mount_table.lock); + + if (found_link == NULL) + return NULL; + + return hash_entry (found_link, struct vfs_mountpoint, mount_table_link); +} + +struct vfs_mountpoint* vfs_create_mountpoint (const char* key, int fs_type) { + if (strlen_null (key) > fieldsizeof (struct vfs_mountpoint, key)) + return NULL; + + struct vfs_mountpoint* mountpoint = malloc (sizeof (*mountpoint)); + + if (mountpoint == NULL) + return NULL; + + memset (mountpoint, 0, sizeof (*mountpoint)); + + memcpy (mountpoint->key, key, strlen_null (key)); + mountpoint->fs_type = fs_type; + mountpoint->lock = SPIN_LOCK_INIT; + + switch (mountpoint->fs_type) { + case VFS_RAMDISKFS: { + mountpoint->driver_ops.mount = &ramdiskfs_mount; + mountpoint->driver_ops.describe = &ramdiskfs_describe; + mountpoint->driver_ops.read = &ramdiskfs_read; + } break; + default: { + free (mountpoint); + return NULL; + } break; + } + + bool ok = mountpoint->driver_ops.mount (mountpoint); + + if (!ok) { + free (mountpoint); + return NULL; + } + + uint32_t mp_hash = hash_fnv32 (mountpoint->key, strlen (mountpoint->key)); + + spin_lock (&mount_table.lock); + + hash_insert (&mount_table, &mountpoint->mount_table_link, mp_hash, + lengthof (mount_table.mountpoint_buckets), mountpoint_buckets); + + spin_unlock (&mount_table.lock); + + return mountpoint; +} + +int vfs_describe (const char* mountpoint, const char* path, struct fs_desc_buffer* desc) { + struct vfs_mountpoint* vmp = vfs_find_mountpoint (mountpoint); + + if (vmp == NULL) + return -VFS_NOT_FOUND; + + return vmp->driver_ops.describe (vmp, path, desc); +} + +int vfs_read (const char* mountpoint, const char* path, uint8_t* buffer, size_t off, size_t size) { + struct vfs_mountpoint* vmp = vfs_find_mountpoint (mountpoint); + + if (vmp == NULL) + return -VFS_NOT_FOUND; + + return vmp->driver_ops.read (vmp, path, buffer, off, size); +} + +void vfs_init (void) { + memset (&mount_table, 0, sizeof (mount_table)); + + mount_table.lock = SPIN_LOCK_INIT; +} diff --git a/kernel/fs/vfs.h b/kernel/fs/vfs.h new file mode 100644 index 0000000..960fc60 --- /dev/null +++ b/kernel/fs/vfs.h @@ -0,0 +1,42 @@ +#ifndef _KERNEL_FS_VFS_H +#define _KERNEL_FS_VFS_H + +#include +#include +#include +#include +#include + +#define VFS_OK 0 +#define VFS_EXISTS 1 +#define VFS_NOT_FOUND 2 +#define VFS_BAD_PATH 3 +#define VFS_OOB_ERROR 4 + +#define VFS_RAMDISKFS 0 + +struct vfs_mountpoint { + char key[0x100]; + struct hash_node_link mount_table_link; + int fs_type; + spin_lock_t lock; + struct { + bool (*mount) (struct vfs_mountpoint* mountpoint); + int (*describe) (struct vfs_mountpoint* mountpoint, const char* path, + struct fs_desc_buffer* desc); + int (*read) (struct vfs_mountpoint* mountpoint, const char* path, uint8_t* buffer, size_t off, + size_t size); + } driver_ops; +}; + +struct vfs_mount_table { + struct hash_node_link* mountpoint_buckets[1024]; + spin_lock_t lock; +}; + +struct vfs_mountpoint* vfs_create_mountpoint (const char* key, int fs_type); +int vfs_describe (const char* mountpoint, const char* path, struct fs_desc_buffer* desc); +int vfs_read (const char* mountpoint, const char* path, uint8_t* buffer, size_t off, size_t size); +void vfs_init (void); + +#endif // _KERNEL_FS_VFS_H diff --git a/kernel/libk/fieldsizeof.h b/kernel/libk/fieldsizeof.h new file mode 100644 index 0000000..61fd902 --- /dev/null +++ b/kernel/libk/fieldsizeof.h @@ -0,0 +1,6 @@ +#ifndef _KERNEL_LIBK_FIELDSIZEOF_H +#define _KERNEL_LIBK_FIELDSIZEOF_H + +#define fieldsizeof(type, field) (sizeof (((type*)0)->field)) + +#endif // _KERNEL_LIBK_FIELDSIZEOF_H diff --git a/kernel/libk/hash.h b/kernel/libk/hash.h new file mode 100644 index 0000000..264748a --- /dev/null +++ b/kernel/libk/hash.h @@ -0,0 +1,51 @@ +#ifndef _KERNEL_LIBK_HASH_H +#define _KERNEL_LIBK_HASH_H + +#include + +struct hash_node_link { + struct hash_node_link* next; + uint32_t hash; +}; + +#define hash_entry(ptr, type, member) ((type*)((char*)(ptr) - offsetof (type, member))) + +static inline uint32_t hash_fnv32 (const void* data, size_t len) { + uint32_t hash = 2166136261U; + const uint8_t* bp = (const uint8_t*)data; + const uint8_t* be = bp + len; + + while (bp < be) { + hash ^= (uint32_t)*bp++; + hash *= 16777619U; + } + return hash; +} + +#define hash_insert(table, new_link, hash_val, table_size, buckets_name) \ + do { \ + uint32_t __idx = (hash_val) % (table_size); \ + (new_link)->hash = (hash_val); \ + (new_link)->next = (table)->buckets_name[__idx]; \ + (table)->buckets_name[__idx] = (new_link); \ + } while (0) + +#define hash_find(table, key_ptr, key_size, hash_val, table_size, buckets_name, type, member, \ + key_field, out_link) \ + do { \ + uint32_t __idx = (hash_val) % (table_size); \ + struct hash_node_link* __curr = (table)->buckets_name[__idx]; \ + (out_link) = NULL; \ + while (__curr) { \ + if (__curr->hash == (hash_val)) { \ + type* __entry = hash_entry (__curr, type, member); \ + if (memcmp (__entry->key_field, (key_ptr), (key_size)) == 0) { \ + (out_link) = __curr; \ + break; \ + } \ + } \ + __curr = __curr->next; \ + } \ + } while (0) + +#endif // _KERNEL_LIBK_HASH_H diff --git a/kernel/libk/lengthof.h b/kernel/libk/lengthof.h new file mode 100644 index 0000000..731aa8f --- /dev/null +++ b/kernel/libk/lengthof.h @@ -0,0 +1,6 @@ +#ifndef _KERNEL_LIBK_LENGTHOF_H +#define _KERNEL_LIBK_LENGTHOF_H + +#define lengthof(x) (sizeof ((x)) / sizeof ((x)[0])) + +#endif // _KERNEL_LIBK_LENGTHOF_H diff --git a/kernel/libk/string.h b/kernel/libk/string.h index 01c073f..7bb5d16 100644 --- a/kernel/libk/string.h +++ b/kernel/libk/string.h @@ -9,4 +9,6 @@ void strncpy (char* dst, const char* src, size_t n); size_t strlen (const char* str); int memcmp (const void* s1, const void* s2, size_t n); +#define strlen_null(x) (strlen ((x)) + 1) + #endif // _KERNEL_LIBK_STRING_H diff --git a/kernel/proc/proc.c b/kernel/proc/proc.c index ff09e45..dfa6c81 100644 --- a/kernel/proc/proc.c +++ b/kernel/proc/proc.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -7,12 +8,12 @@ #include #include #include +#include #include #include #include #include #include -#include #include #include #include @@ -100,17 +101,38 @@ struct elf_aux proc_load_segments (struct proc* proc, uint8_t* elf) { return aux; } -struct proc* proc_spawn_rd (char* name) { - struct rd_file* rd_file = rd_get_file (name); +struct proc* proc_from_file (const char* mountpoint, const char* path) { + struct fs_desc_buffer desc; - bool ok = proc_check_elf (rd_file->content); - - DEBUG ("Spawning %s, elf header %s\n", name, ok ? "ok" : "bad"); - - if (!ok) + if (vfs_describe (mountpoint, path, &desc) != VFS_OK) return NULL; - return proc_from_elf (rd_file->content); + if (desc.type != FS_FILE) + return NULL; + + uint8_t* temp_buffer = malloc (desc.size); + + if (temp_buffer == NULL) + return NULL; + + if (vfs_read (mountpoint, path, temp_buffer, 0, desc.size) != VFS_OK) { + free (temp_buffer); + return NULL; + } + + bool ok = proc_check_elf (temp_buffer); + + DEBUG ("Spawning %s:%s, elf header %s\n", mountpoint, path, ok ? "ok" : "bad"); + + if (!ok) { + free (temp_buffer); + return NULL; + } + + struct proc* proc = proc_from_elf (temp_buffer); + + free (temp_buffer); + return proc; } struct proc* proc_find_pid (int pid) { @@ -275,11 +297,11 @@ void proc_init (void) { irq_attach (&proc_irq_sched, NULL, CPU_REQUEST_SCHED); #endif - struct proc* spin_proc = proc_spawn_rd ("spin.exe"); + struct proc* spin_proc = proc_from_file ("ramdisk", "/spin.exe"); struct cpu* spin_cpu = thiscpu; proc_register (spin_proc, &spin_cpu); - struct proc* init = proc_spawn_rd ("init.exe"); + struct proc* init = proc_from_file ("ramdisk", "/init.exe"); struct cpu* init_cpu = thiscpu; proc_register (init, &init_cpu); diff --git a/kernel/proc/proc.h b/kernel/proc/proc.h index 652a714..525f655 100644 --- a/kernel/proc/proc.h +++ b/kernel/proc/proc.h @@ -51,7 +51,7 @@ bool proc_kill (struct proc* proc, struct cpu** reschedule_cpu); struct elf_aux proc_load_segments (struct proc* proc, uint8_t* elf); bool proc_register (struct proc* proc, struct cpu** reschedule_cpu); struct proc* proc_find_pid (int pid); -struct proc* proc_spawn_rd (char* name); +struct proc* proc_from_file (const char* mountpoint, const char* path); void proc_init (void); #endif // _KERNEL_PROC_PROC_H diff --git a/kernel/rd/rd.c b/kernel/rd/rd.c deleted file mode 100644 index 59446f4..0000000 --- a/kernel/rd/rd.c +++ /dev/null @@ -1,81 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#define RD_FILES_MAX 64 -#define RD_PATH "/boot/mop3dist.tar" - -static struct rd_file rd_files[RD_FILES_MAX]; - -struct rd_file* rd_get_file (char* filename) { - for (size_t i = 0; i < RD_FILES_MAX; i++) { - if ((rd_files[i].hdr != NULL) && - (memcmp (rd_files[i].hdr->filename, filename, strlen (filename)) == 0)) - return &rd_files[i]; - } - return NULL; -} - -static size_t rd_tar_get_size (uint8_t* in) { - size_t size = 0; - size_t j; - size_t count = 1; - - for (j = 11; j > 0; j--, count *= 8) - size += ((in[j - 1] - '0') * count); - - return size; -} - -static size_t rd_tar_parse (uint8_t* addr) { - size_t i; - - for (i = 0;; i++) { - struct tar_hdr* hdr = (struct tar_hdr*)addr; - - if (hdr->filename[i] == '\0') - break; - - size_t size = rd_tar_get_size (hdr->size); - - rd_files[i].hdr = hdr; - rd_files[i].content = (uint8_t*)((uintptr_t)hdr + 512); - rd_files[i].size = rd_tar_get_size ((uint8_t*)hdr->size); - - DEBUG ("filename=%s\n", hdr->filename); - - addr += ((size / 512) + 1) * 512; - - if (size % 512) - addr += 512; - } - - return i; -} - -void rd_init (void) { - struct limine_module_response* module = limine_module_request.response; - - uint8_t* rd_addr = NULL; - - for (size_t i = 0; i < module->module_count; i++) { - struct limine_file* file = module->modules[i]; - DEBUG ("%s\n", file->path); - - if (memcmp (file->path, RD_PATH, strlen (RD_PATH)) == 0) { - rd_addr = file->address; - } - } - - if (rd_addr == NULL) { - DEBUG ("mop3dist.tar NOT FOUND!\n"); - - for (;;) - ; - } - - rd_tar_parse (rd_addr); -} diff --git a/kernel/rd/rd.h b/kernel/rd/rd.h deleted file mode 100644 index f63236c..0000000 --- a/kernel/rd/rd.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef _KERNEL_RD_RD_H -#define _KERNEL_RD_RD_H - -#include -#include - -struct tar_hdr { - char filename[100]; - uint8_t mode[8]; - uint8_t uid[8]; - uint8_t gid[8]; - uint8_t size[12]; - uint8_t mtime[12]; - uint8_t checksum[8]; - uint8_t type_flag; -} PACKED; - -struct rd_file { - struct tar_hdr* hdr; - uint8_t* content; - size_t size; -}; - -struct rd_file* rd_get_file (char* filename); -void rd_init (void); - -#endif // _KERNEL_RD_RD_H diff --git a/kernel/rd/src.mk b/kernel/rd/src.mk deleted file mode 100644 index 10af544..0000000 --- a/kernel/rd/src.mk +++ /dev/null @@ -1,3 +0,0 @@ -c += rd/rd.c - -o += rd/rd.o diff --git a/kernel/src.mk b/kernel/src.mk index 49aad03..8e4ad09 100644 --- a/kernel/src.mk +++ b/kernel/src.mk @@ -5,6 +5,6 @@ include mm/src.mk include limine/src.mk include uACPI/src.mk include irq/src.mk -include rd/src.mk include proc/src.mk include syscall/src.mk +include fs/src.mk