feat(kernel): implement Phase 5 - VFS abstraction, in-memory RamFS & interactive airlys-sh shell

This commit is contained in:
Adam Eehan committed 2026-10-23 17:58:20 +05:30
1 parent 6ee659ac6b
commit adfa4dc262
10 files changed
+680 -11

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
#ifndef AIRLYS_RAMFS_H
#define AIRLYS_RAMFS_H
#include <airlys/vfs.h>
/* Initialize in-memory RAM filesystem and standard directories */
vfs_node_t* ramfs_init(void);
/* Create directory under a parent directory */
vfs_node_t* ramfs_create_dir(vfs_node_t* parent, const char* name);
/* Create a file with given text content under a parent directory */
vfs_node_t* ramfs_create_file(vfs_node_t* parent, const char* name, const char* content);
#endif /* AIRLYS_RAMFS_H */
+17
View File
@@ -0,0 +1,17 @@
#ifndef AIRLYS_SHELL_H
#define AIRLYS_SHELL_H
#include <airlys/types.h>
#define SHELL_MAX_INPUT 256
/* Initialize the interactive userland shell */
void shell_init(void);
/* Handle keyboard character input from hardware keyboard driver */
void shell_handle_char(char c);
/* Parse and execute a shell command line */
void shell_execute(const char* cmdline);
#endif /* AIRLYS_SHELL_H */
+54
View File
@@ -0,0 +1,54 @@
#ifndef AIRLYS_VFS_H
#define AIRLYS_VFS_H
#include <airlys/types.h>
#define VFS_FILE 0x01
#define VFS_DIRECTORY 0x02
#define VFS_CHARDEVICE 0x03
#define VFS_BLOCKDEVICE 0x04
#define VFS_MAX_NAME 64
#define VFS_MAX_CHILDREN 32
struct vfs_node;
typedef uint64_t (*vfs_read_fn)(struct vfs_node* node, uint64_t offset, uint64_t size, uint8_t* buffer);
typedef uint64_t (*vfs_write_fn)(struct vfs_node* node, uint64_t offset, uint64_t size, const uint8_t* buffer);
typedef struct vfs_node* (*vfs_finddir_fn)(struct vfs_node* node, const char* name);
typedef struct vfs_node* (*vfs_readdir_fn)(struct vfs_node* node, uint32_t index);
typedef struct vfs_node {
char name[VFS_MAX_NAME];
uint32_t flags;
uint64_t size;
uint32_t inode;
vfs_read_fn read;
vfs_write_fn write;
vfs_finddir_fn finddir;
vfs_readdir_fn readdir;
struct vfs_node* parent;
struct vfs_node* children[VFS_MAX_CHILDREN];
uint32_t num_children;
void* internal_data;
} vfs_node_t;
/* Initialize Virtual File System */
void vfs_init(void);
/* Root VFS node */
vfs_node_t* vfs_get_root(void);
/* Set new root VFS node */
void vfs_set_root(vfs_node_t* root);
/* Path resolution helper (e.g. "/etc/os-release" or "os-release") */
vfs_node_t* vfs_resolve_path(const char* path);
/* Standard VFS operations */
uint64_t vfs_read(vfs_node_t* node, uint64_t offset, uint64_t size, uint8_t* buffer);
uint64_t vfs_write(vfs_node_t* node, uint64_t offset, uint64_t size, const uint8_t* buffer);
vfs_node_t* vfs_finddir(vfs_node_t* node, const char* name);
vfs_node_t* vfs_readdir(vfs_node_t* node, uint32_t index);
#endif /* AIRLYS_VFS_H */