modified some syscall code in rlibc, fs stuff

This commit is contained in:
2026-06-29 17:00:07 -05:00
parent 97357f3170
commit 432d160b7a
285 changed files with 4223 additions and 3957 deletions

34
kernel/initrd.c Normal file
View File

@@ -0,0 +1,34 @@
#include "initrd.h"
#include <stdint.h>
#include <lib/print.h>
#include <lib/memory.h>
void parse_cpio(void *initrd_start) {
cpio_header_t *head = (cpio_header_t *)initrd_start;
while (strncmp(head->c_magic, "070701", 6) == 0) {
// If we hit the trailer, we are done
char *filename = (char *)(head + 1);
if (strncmp(filename, "TRAILER!!!", 10) == 0) {
break;
}
uint32_t filesize = parse_hex(head->c_filesize);
uint32_t namesize = parse_hex(head->c_namesize);
kprintf("found file of size %d\n", filesize);
// Calculate where the data begins (accounting for 4-byte padding)
uint32_t header_plus_name = 110 + namesize;
header_plus_name = (header_plus_name + 3) & ~3; // Align to 4 bytes
char *file_data = (char *)head + header_plus_name;
uint32_t total_record_size = header_plus_name + filesize;
total_record_size = (total_record_size + 3) & ~3; // Align to 4 bytes
head = (cpio_header_t *)((char *)head + total_record_size);
}
}