trying something out

This commit is contained in:
notsomeidiot123 2025-09-08 12:03:52 -04:00
parent e744baa5b5
commit 808fa4c13e
6 changed files with 102 additions and 9 deletions

View File

@ -31,6 +31,7 @@ extern void kmain(kernel_info_t *kernel_info){
pic_disable();
pic_setmask(0xfe, PIC1_DATA);
vfs_init();
fcreate("Testing/testing/bleh", 0);
//TODO: Map and load filesystem and disk modules
//TODO: Start Initial Process
mlog("KERNEL", "Initializing Scheduler & starting PID 1\n", MLOG_PRINT);

View File

@ -0,0 +1,32 @@
#include "string.h"
#pragma warning
char res[256];
char* strtok(char* string, char d)
{
static char* input = 0;
if (string){
input = string;
}
if (!input){
return 0;
}
int i = 0;
for (; input[i] != 0; i++) {
if (input[i] != d){
res[i] = input[i];
}
else {
res[i] = '\0';
input = input + i+1;
return res;
}
}
res[i] = '\0';
input = 0;
return res;
}

View File

@ -3,6 +3,7 @@
void itoa(int64_t data, char *res, uint8_t base);
void strpad(char *string, char padding, uint32_t length);
//str cannot be null
inline uint32_t strlen(char *str){
uint32_t c = 0;
while(*str){
@ -11,5 +12,15 @@ inline uint32_t strlen(char *str){
}
return c;
}
//str1 and str2 both cannot be null
inline uint32_t strcmp(char *str1, char *str2){
uint32_t i = 0;
while(str1[i] && str1[i] == str2[i]){
i++;
}
if(str1[i] == str2[i]) return 0;
else return 1;
}
char *strtok(char *str, char delim);
void strcpy(char *src, char *dest);
void memcpy(char *src, char *dest, uint32_t c);

View File

@ -1,16 +1,57 @@
#include "vfs.h"
#include "../shared/kstdlib.h"
vfile_t root_dir = {"/", VFILE_DIRECTORY};
#include "../shared/memory.h"
#include "../shared/string.h"
#define MODULE_NAME "KVFS"
vfile_t root_dir = {"\0", VFILE_DIRECTORY};
void vfs_init(){
// mlog()
mlog(MODULE_NAME, "Initializing VFS\n", MLOG_PRINT);
root_dir.access.data.ptr = kmalloc(1);
root_dir.access.data.size_pgs = 1;
}
void fcreate();
void fcreate(char *name, VFILE_TYPE type, ...){
printf("Sasdafdasdf\n");
char *dir = strtok(name, '/');
char *file = dir;
char *tmp = dir;
while(tmp != 0){
dir = file;
file = tmp;
tmp = strtok(0, '/');
}
}
void fdelete();
uint32_t fwrite();
// navya was here https://github.com/novabansal
uint32_t fwrite(vfile_t *file_entry, void *byte_array, uint32_t offset, uint32_t count){
// a: a way to call RW functions from any given module
// OR
// b: specify a pointer to data that is written to virtual file in memory
// search through root directory
switch(file_entry->type){
case VFILE_DEVICE:
file_entry->access.funcs.write(byte_array, offset, count);
}
}
uint32_t fread();
void fopen();
void fopen(char *name){
char *dir = strtok(name, '/');
char *tmp = dir;
vfile_t *current_dir = &root_dir;
while(tmp != 0){
dir = tmp;
uint32_t i = 0;
vfile_t *dir = ((vfile_t *)(current_dir->access.data.ptr));
while(dir[i].name[0]){
if(!strcmp(dir[i].name, tmp)){
if(dir[i].type == )
}
}
tmp = strtok(0, '/');
}
return;
}

View File

@ -27,8 +27,8 @@ typedef struct virtual_file_t{
}vfile_t;
void vfs_init();
void fcreate();
void fcreate(char *name, VFILE_TYPE type, ...);
void fdelete();
uint32_t fwrite();
uint32_t fread();
void fopen();
void fopen(char *name);

View File

@ -23,4 +23,12 @@ typedef struct module{
uint32_t id;
char name[16];
uint8_t flags;
}module_t;
}module_t;
typedef enum vfile_type{
VFILE_POINTER,
VFILE_DEVICE,
VFILE_MOUNT,
VFILE_DIRECTORY,
VFILE_FILE,
}VFILE_TYPE;