got some of the pty actually working in userspace

This commit is contained in:
2026-07-12 03:56:25 -05:00
parent 992ffd1f6b
commit 3c6fd8cb65
16 changed files with 140 additions and 147 deletions

View File

@@ -2,6 +2,7 @@
#include <lib/memory.h>
#include <lib/string.h>
#include <lib/print.h>
#define MAX_INITRD_FILES 64
@@ -17,9 +18,16 @@ static uint32_t parse_hex_ascii(const char *str, int len) {
}
static vfs_node_t* cpio_find(vfs_node_t* _dir, const char* name) {
if (strcmp(name, "tvga") == 0) {
kprintf("looking for tvga\n");
}
if (!(_dir->flags & VFS_DIRECTORY)) return NULL;
vfs_node_t* root = _dir;
if (_dir->mnt) {
root = _dir->mnt;
}
vfs_node_t* child = _dir->first_child;
vfs_node_t* child = root->first_child;
while (child != NULL) {
if (strcmp(child->name, name) == 0) {
return child;
@@ -39,7 +47,7 @@ static uint32_t cpio_read(struct vfs_node* node, uint32_t offset, uint32_t size,
return size;
}
static vfs_node_t* cpio_get_or_create(vfs_node_t* root_node, const char* path) {
static vfs_node_t* cpio_find_or_create(vfs_node_t* root_node, const char* path) {
vfs_node_t* current = root_node;
char path_cpy[256];
@@ -49,8 +57,6 @@ static vfs_node_t* cpio_get_or_create(vfs_node_t* root_node, const char* path) {
char* tkn = strtok_r(path_cpy, "/", &sav);
while (tkn != NULL) {
char* next_tkn = strtok_r(NULL, "/", &sav);
vfs_node_t* next_node = cpio_find(current, tkn);
if (!next_node) {
next_node = kalloc(sizeof(vfs_node_t));
@@ -65,7 +71,7 @@ static vfs_node_t* cpio_get_or_create(vfs_node_t* root_node, const char* path) {
}
current = next_node;
tkn = next_tkn;
tkn = strtok_r(NULL, "/", &sav);
}
return current;
@@ -99,26 +105,7 @@ vfs_node_t* cpio_read_fs(uint32_t _vaddr) {
uint8_t* file_data = (uint8_t*)header + file_data_offset;
if (strcmp(".", filename) != 0) {
vfs_node_t* parent = cpio_get_or_create(cpio_root, filename);
char* base_name = filename;
for (int i = strlen(filename) - 1; i >= 0; i--) {
if (filename[i] == '/') {
base_name = &filename[i + 1];
break;
}
}
vfs_node_t* current = cpio_find(parent, base_name);
if (!current) {
current = kalloc(sizeof(vfs_node_t));
memset((void*)current, 0, sizeof(vfs_node_t));
strcpy(current->name, base_name);
current->next_sibling = parent->first_child;
parent->first_child = current;
}
vfs_node_t* current = cpio_find_or_create(cpio_root, filename);
if ((mode & 0xF000) == 0x4000) {
current->flags = VFS_DIRECTORY;
current->find = cpio_find;