No clue what i'm doing

This commit is contained in:
notsomeidiot123 2026-06-25 20:46:29 -04:00
parent 335b386463
commit c79aeedae2
3 changed files with 47 additions and 10 deletions

View File

@ -46,15 +46,14 @@ void pci_write_file(vfile_t *file, uint32_t *buffer, uint32_t offset, uint32_t c
return;
}
void pci_make_file(uint32_t class, uint8_t bus, uint8_t slot, uint8_t func){
char *str = kmalloc(1);
memcpy("/dev/pci/", str, 9);
char str[256] = "/dev/pci/\0";
char *dev = classes[class >> 8][class & 0xf];
switch(class >> 8){
case 0x1://PCI class 0x1 is disks
// printf("!!STR: %s, LEN: %d!!", str, strlen(str));
strcpy("disk/", str + strlen(str));
uint32_t l = (uint32_t)pci_read_config(bus, slot, func, 0x4) | (uint32_t)pci_read_config(bus, slot, func, 0x6) << 16;
pci_write_config(bus, slot, func, 0x4, l | 4);
break;
case 0x2://PCI class 0x2 is network controllers
strcpy("net/", str + strlen(str));

View File

@ -17,8 +17,40 @@ void add_file(vfile_t *vfile, vfile_t *current_dir){
return;
}
vfile_t *fcreate(char *name, FS_FILE_FLAGS flags){
return 0;
vfile_t *fcreate(char *path, FS_FILE_FLAGS flags){
if(!path){
return;
}
char *name = kmalloc((strlen(path) + 4095)/4096);//don't make modifications to the original string
strcpy(path, name);
// printf("Sizeof: %d\n", sizeof(vfile_t));
if(name[0] == '/') name++;//first slash just indicates that it's an absolute path, we don't want to include that into the filename.
uint32_t name_length = strlen(name);
// printf("%s, %d: ", name, strlen(name));
uint32_t name_index = 0;
uint32_t subpath_start = 0;
vfile_t *new_file = 0;
while(name[name_index]){//this condition shouldn't ever be triggered, but it's here to stop us if we're at the end.
subpath_start = name_index;
while(name[name_index] && name[name_index] != '/'){//split the string at directories
name_index++;
}
name[name_index] = 0;
// printf("%d, %s,", subpath_start, name + subpath_start);
if(name_index >= name_length){//this should be the only exit condition
printf("Creating file in dir; name: %s", name + subpath_start);
break;
}
name_index++;
}
printf("\n");
kfree(name);
return new_file;
}
int fdelete(vfile_t *file_entry){
@ -37,7 +69,7 @@ int fread(vfile_t *file_entry, void *byte_array, uint32_t offset, uint32_t count
// return 0;
// }
int readdir(vfile_t* file, vfile_t *buffer, uint32_t offset, uint32_t count){
int readdir(vfile_t* file, vfile_t* buffer, uint32_t offset, uint32_t count){
return 0;
}
@ -45,3 +77,8 @@ vfile_t *fopen(char *name){
return 0;
}
//create file in vfs
vfile_t *vfs_create(char *path, FS_FILE_FLAGS flags){
}

View File

@ -8,12 +8,13 @@ typedef enum fs_flags{
FS_FILE_IS_DIR = 0x10,
FS_FILE_ARCHIVE = 0x20,
FS_FILE_PIPE = 0x40,
FS_FILE_LINK = 0x80
FS_FILE_LINK = 0x80,
FS_FILE_MOUNT = 0x100,
}FS_FILE_FLAGS;
typedef struct virtual_file{
char name[256];
FS_FILE_FLAGS flags;
char name[212];
uint16_t flags;
int (*delete)(struct virtual_file *file_entry);
struct virtual_file *(*create)(char *path, FS_FILE_FLAGS flags);
int (*write)(struct virtual_file *file_entry, void *data, uint32_t offset, uint32_t count);
@ -35,6 +36,6 @@ vfile_t *fcreate(char *name, FS_FILE_FLAGS flags);
int fdelete(vfile_t* file_entry);
int fwrite(vfile_t *file_entry, void *byte_array, uint32_t offset, uint32_t count);
int fread(vfile_t *file_entry, void *byte_array, uint32_t offset, uint32_t count);
int readdir(vfile_t* file, struct virtual_file *buffer, uint32_t offset, uint32_t count);
int readdir(vfile_t* file, vfile_t *buffer, uint32_t offset, uint32_t count);
vfile_t *fopen(char *path);