working on reading elf from initrd, and getting it launched with the new scheduler
This commit is contained in:
34
kernel/vfs.c
34
kernel/vfs.c
@@ -22,22 +22,22 @@ vfs_node_t* vfs_create_root() {
|
||||
|
||||
void mount(vfs_node_t* _mnt, vfs_node_t* _fs) {
|
||||
if (!_fs || !_mnt || !(_mnt->flags & VFS_DIRECTORY)) return;
|
||||
_mnt->ptr = _fs;
|
||||
_mnt->mnt = _fs;
|
||||
}
|
||||
|
||||
static vfs_node_t* lookup(const char* path) {
|
||||
if (path[0] != '/') return NULL;
|
||||
vfs_node_t* current = root;
|
||||
|
||||
if (current->ptr) {
|
||||
current = current->ptr;
|
||||
if (current->mnt) {
|
||||
current = current->mnt;
|
||||
}
|
||||
|
||||
const char* component = path + 1;
|
||||
if (*component == '\0') return current;
|
||||
const char* cmp = path + 1;
|
||||
if (*cmp == '\0') return current;
|
||||
|
||||
if (current->finddir) {
|
||||
return current->finddir(current, component);
|
||||
return current->finddir(current, cmp);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -72,6 +72,22 @@ int read(int fd, void* buf, size_t sz) {
|
||||
return bytes_read;
|
||||
}
|
||||
|
||||
int fseek(int fd) {
|
||||
|
||||
}
|
||||
int fstat(int fd, file_t* dst) {
|
||||
if (fd < 0 || fd >= MAX_PROCESS_FDS || !fd_table[fd].node) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
file_t* src = &fd_table[fd];
|
||||
memcpy(src, dst, sizeof(file_t));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int fseek(int fd, size_t offset) {
|
||||
if (fd < 0 || fd >= MAX_PROCESS_FDS || !fd_table[fd].node) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
file_t* file = &fd_table[fd];
|
||||
file->offset = offset;
|
||||
return 1;
|
||||
}
|
||||
Reference in New Issue
Block a user