Files
Espresso/drivers/fs/vfs.c
2026-03-20 16:57:08 -05:00

87 lines
1.6 KiB
C

#include <stdlib.h>
#include <string.h>
#include <tty.h>
#include <fs/vfs.h>
/* we use something similar to the Linux kernel in terms of a VFS system */
#define MAX_FDS 64
struct inode {
size_t size;
int permissions;
void *fs_data; /* FS-specific */
};
struct file_ops {
int (*read)(struct file*, char*, size_t);
int (*write)(struct file*, const char*, size_t);
};
struct file {
struct inode* f_inode;
size_t f_offset;
size_t f_refcount;
const struct file_ops f_ops;
};
struct fdtable {
struct file* fds[MAX_FDS];
};
int vfs_handle_stdout(struct file* __f, const char* __s, size_t __l)
{
(void) __f;
terminal_write(__s, __l);
return 0;
}
struct fdtable* vfs_init_kernel_fdtable(void)
{
#if 0
struct fdtable* ft = malloc(sizeof(struct fdtable));
struct file* _stdout = malloc(sizeof(struct file));
struct file* _stdin = malloc(sizeof(struct file));
if (!ft || !_stdin || !_stdout)
{
return NULL;
}
_stdout->f_inode = NULL;
_stdout->f_offset = 0;
_stdout->f_refcount = 1;
_stdout->f_ops = { .read = NULL, .write = vfs_handle_stdout };
#endif
return NULL;
}
int init_vfs(int argc, char** argv)
{
(void) argc;
(void) argv;
return 0;
}
/*
This is being written as a test.
This has no affect on aaand my CPU is at 87 degrees Celsius and /usr/bin/gnome-shell is at 115% CPU utilization.
Just by writing that.
wow.
and now my CPU fan is going nuts.
--update: now it works. I had to go back to nouveau instead of the proprietary nVidia®©™ drivers..
--update: I wrote what months ago. now is 3/12/2026, I don't even remember what was going on well. wow.
*/