Modified files to fit new VFS
This commit is contained in:
parent
cc61eec0cf
commit
e366dc75d8
|
|
@ -76,7 +76,9 @@ void pci_make_file(uint32_t class, uint8_t bus, uint8_t slot, uint8_t func){
|
||||||
itoa(tries++, num, 10);
|
itoa(tries++, num, 10);
|
||||||
strcpy(str, cpy);
|
strcpy(str, cpy);
|
||||||
strcpy(num, cpy + strlen(cpy));
|
strcpy(num, cpy + strlen(cpy));
|
||||||
file = fcreate(cpy, VFILE_DEVICE, pci_write_file, pci_read_file);
|
file = fcreate(cpy, 0);
|
||||||
|
file->read = pci_read_file;
|
||||||
|
file->write = pci_write_file;
|
||||||
if(tries >= 254){
|
if(tries >= 254){
|
||||||
mlog(MODULE_NAME, "Failed to make PCI file for device!\n", MLOG_PRINT);
|
mlog(MODULE_NAME, "Failed to make PCI file for device!\n", MLOG_PRINT);
|
||||||
return;
|
return;
|
||||||
|
|
@ -124,11 +126,11 @@ void pci_enumerate_bus(uint8_t bus){
|
||||||
|
|
||||||
void pci_init(){
|
void pci_init(){
|
||||||
mlog(MODULE_NAME, "Enumerating PCI Buses\n", MLOG_PRINT);
|
mlog(MODULE_NAME, "Enumerating PCI Buses\n", MLOG_PRINT);
|
||||||
vfile_t *file = fcreate("dev/pci/", VFILE_DIRECTORY, kmalloc(1), 1);
|
vfile_t *file = fcreate("dev/pci/", FS_FILE_IS_DIR);
|
||||||
fcreate("dev/pci/disk", VFILE_DIRECTORY, kmalloc(1), 1);
|
fcreate("dev/pci/disk", FS_FILE_IS_DIR);
|
||||||
fcreate("dev/pci/net", VFILE_DIRECTORY, kmalloc(1), 1);
|
fcreate("dev/pci/net", FS_FILE_IS_DIR);
|
||||||
fcreate("dev/pci/video", VFILE_DIRECTORY, kmalloc(1), 1);
|
fcreate("dev/pci/video", FS_FILE_IS_DIR);
|
||||||
fcreate("dev/pci/bridge", VFILE_DIRECTORY, kmalloc(1), 1);
|
fcreate("dev/pci/bridge", FS_FILE_IS_DIR);
|
||||||
for(uint32_t i = 0 ; i < 256; i++){
|
for(uint32_t i = 0 ; i < 256; i++){
|
||||||
pci_enumerate_bus(i);
|
pci_enumerate_bus(i);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,15 @@ int read_initrd(initrd_t *initrd){
|
||||||
// }
|
// }
|
||||||
char final_fname[80] = "/boot/";
|
char final_fname[80] = "/boot/";
|
||||||
strcat(file->filename, final_fname);
|
strcat(file->filename, final_fname);
|
||||||
fcreate(final_fname, VFILE_POINTER, (archive + offset + sizeof(USTAR_file_t)), fsize_pgs);
|
vfile_t *tmp = fcreate(final_fname, 0);
|
||||||
|
if(!tmp){
|
||||||
|
mlog("INITRD", "Failed to read critical boot file: %s\n", MLOG_PRINT, file->filename);
|
||||||
|
}
|
||||||
|
if(tmp->ptr){
|
||||||
|
kfree(tmp->ptr);
|
||||||
|
}
|
||||||
|
tmp->ptr = (archive + offset + sizeof(USTAR_file_t));
|
||||||
|
tmp->size = fsize_pgs * 4096;
|
||||||
// printf("%s, %d, %d\n", final_fname, filesize, fsize_pgs);
|
// printf("%s, %d, %d\n", final_fname, filesize, fsize_pgs);
|
||||||
offset += (((filesize + 511) / 512) + 1) * 512;
|
offset += (((filesize + 511) / 512) + 1) * 512;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ void sysinit(){
|
||||||
modules_init();
|
modules_init();
|
||||||
vfile_t *initrc = fopen("/boot/initrc.conf");
|
vfile_t *initrc = fopen("/boot/initrc.conf");
|
||||||
if(initrc){
|
if(initrc){
|
||||||
mlog("KERNEL", "Found initrc at: %x\n", MLOG_PRINT, initrc->access.data.ptr);
|
mlog("KERNEL", "Found initrc", MLOG_PRINT);
|
||||||
initrc_read(initrc);
|
initrc_read(initrc);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
@ -56,10 +56,10 @@ extern void kmain(kernel_info_t *kernel_info){
|
||||||
pic_setmask(0x0, PIC1_DATA);
|
pic_setmask(0x0, PIC1_DATA);
|
||||||
pic_setmask(0x0, PIC2_DATA);
|
pic_setmask(0x0, PIC2_DATA);
|
||||||
|
|
||||||
fcreate("/dev", VFILE_DIRECTORY, kmalloc(1), 1);
|
fcreate("/dev", FS_FILE_IS_DIR);
|
||||||
fcreate("/dev/disk", VFILE_DIRECTORY, kmalloc(1), 1);
|
fcreate("/dev/disk", FS_FILE_IS_DIR);
|
||||||
fcreate("/tmp", VFILE_DIRECTORY, kmalloc(1), 1);
|
fcreate("/tmp", FS_FILE_IS_DIR);
|
||||||
fcreate("/boot", VFILE_DIRECTORY, kmalloc(1), 1);
|
fcreate("/boot", FS_FILE_IS_DIR);
|
||||||
mlog("KERNEL", "Initializing Scheduler & starting PID 1\n", MLOG_PRINT);
|
mlog("KERNEL", "Initializing Scheduler & starting PID 1\n", MLOG_PRINT);
|
||||||
boot_info = kernel_info;
|
boot_info = kernel_info;
|
||||||
scheduler_init();
|
scheduler_init();
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,12 @@ int is_num(char c){
|
||||||
|
|
||||||
void initrc_read(vfile_t *file){
|
void initrc_read(vfile_t *file){
|
||||||
mlog("KERNEL", "Reading initrc:\n", MLOG_PRINT);
|
mlog("KERNEL", "Reading initrc:\n", MLOG_PRINT);
|
||||||
char *ptr = file->access.data.ptr;
|
char *ptr = file->ptr;
|
||||||
if(!file || !ptr){
|
if(!file || !ptr){
|
||||||
mlog("KERNEL", "Failed to read initrc!\n", MLOG_PRINT);
|
mlog("KERNEL", "Failed to read initrc!\n", MLOG_PRINT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint32_t size = file->access.data.size_pgs * 4096;
|
uint32_t size = file->size;
|
||||||
char statement[512];
|
char statement[512];
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
while(strcmp(statement, "END")){
|
while(strcmp(statement, "END")){
|
||||||
|
|
@ -67,7 +67,7 @@ void initrc_read(vfile_t *file){
|
||||||
printf("Error: Could not find module in Initrc.conf: %s\n", module_name);
|
printf("Error: Could not find module in Initrc.conf: %s\n", module_name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
module_start(module->access.data.ptr);
|
module_start(module->ptr);
|
||||||
}
|
}
|
||||||
else if(!strcmp(statement, "MOUNT")){
|
else if(!strcmp(statement, "MOUNT")){
|
||||||
char mount_src_name[512] = {0};
|
char mount_src_name[512] = {0};
|
||||||
|
|
|
||||||
|
|
@ -77,14 +77,15 @@ uint32_t module_api(uint32_t func, ...){
|
||||||
break;
|
break;
|
||||||
case MODULE_API_CREAT:
|
case MODULE_API_CREAT:
|
||||||
name = va_arg(vars, char *);
|
name = va_arg(vars, char *);
|
||||||
VFILE_TYPE ftype = va_arg(vars, VFILE_TYPE);
|
FS_FILE_FLAGS ftype = va_arg(vars, FS_FILE_FLAGS);
|
||||||
void *arg1, *arg2;
|
void *arg1, *arg2;
|
||||||
arg1 = va_arg(vars, void *);
|
arg1 = va_arg(vars, void *);
|
||||||
arg2 = va_arg(vars, void *);
|
arg2 = va_arg(vars, void *);
|
||||||
return_value = (uint32_t)fcreate(name, ftype, arg1, arg2);
|
return_value = (uint32_t)fcreate(name, ftype);
|
||||||
break;
|
break;
|
||||||
case MODULE_API_DELET:
|
case MODULE_API_DELET:
|
||||||
return_value = -1;
|
file = va_arg(vars, vfile_t *);
|
||||||
|
return_value = fdelete(file);
|
||||||
break;
|
break;
|
||||||
case MODULE_API_OPEN:
|
case MODULE_API_OPEN:
|
||||||
name = va_arg(vars, char *);
|
name = va_arg(vars, char *);
|
||||||
|
|
|
||||||
|
|
@ -3,21 +3,21 @@
|
||||||
#include "../shared/memory.h"
|
#include "../shared/memory.h"
|
||||||
#include "../shared/string.h"
|
#include "../shared/string.h"
|
||||||
#define MODULE_NAME "KVFS"
|
#define MODULE_NAME "KVFS"
|
||||||
vfile_t root_dir = {"/", VFILE_DIRECTORY};
|
vfile_t root_dir = {"/", FS_FILE_IS_DIR | FS_FILE_SYSTEM};
|
||||||
|
|
||||||
// !TODO: Modify code to become thread-safe
|
// !TODO: Modify code to become thread-safe
|
||||||
|
|
||||||
void vfs_init(){
|
void vfs_init(){
|
||||||
mlog(MODULE_NAME, "Initializing VFS\n", MLOG_PRINT);
|
mlog(MODULE_NAME, "Initializing VFS\n", MLOG_PRINT);
|
||||||
root_dir.access.data.ptr = kmalloc(1);
|
// root_dir.access.data.ptr = kmalloc(1);
|
||||||
root_dir.access.data.size_pgs = 1;
|
// root_dir.access.data.size_pgs = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_file(vfile_t *vfile, vfile_t *current_dir){
|
void add_file(vfile_t *vfile, vfile_t *current_dir){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
vfile_t *fcreate(char *name, VFILE_TYPE type, ...){
|
vfile_t *fcreate(char *name, FS_FILE_FLAGS flags){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,87 +1,37 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
typedef enum vfile_type{
|
|
||||||
VFILE_NULL,
|
|
||||||
VFILE_POINTER,//virtual files
|
|
||||||
VFILE_DEVICE,
|
|
||||||
VFILE_MOUNT,//in the pointer passed to the function, must specify a read, write, open, create, and delete function.
|
|
||||||
VFILE_DIRECTORY,
|
|
||||||
VFILE_PDIR,//used for directories in physical filesystems.
|
|
||||||
VFILE_FILE,//physical files
|
|
||||||
VFILE_SYMLINK,
|
|
||||||
VFILE_PIPE //yay we have pipes
|
|
||||||
}VFILE_TYPE;
|
|
||||||
|
|
||||||
typedef enum mount_ops{
|
|
||||||
MOUNT_NEW,
|
|
||||||
MOUNT_UNMOUNT,
|
|
||||||
}MOUNT_OPERATION;
|
|
||||||
|
|
||||||
|
|
||||||
//this code is gonna be ***really*** unsafe
|
|
||||||
typedef struct virtual_file{
|
|
||||||
char name[20];
|
|
||||||
VFILE_TYPE type;
|
|
||||||
uint32_t id;//to be assigned by driver;
|
|
||||||
uint32_t mount_id;
|
|
||||||
uint8_t lock;
|
|
||||||
uint32_t size;
|
|
||||||
struct virtual_file *parent;//should point to A: a virtual directory, or B: a mounted filesystem
|
|
||||||
union{
|
|
||||||
struct{
|
|
||||||
int (*read)(struct virtual_file *file, void *data, uint32_t offset, uint32_t count);
|
|
||||||
int (*write)(struct virtual_file *file, void *data, uint32_t offset, uint32_t count);
|
|
||||||
}funcs;
|
|
||||||
struct{
|
|
||||||
void *ptr;
|
|
||||||
uint32_t size_pgs;
|
|
||||||
}__attribute__((packed))data;
|
|
||||||
}access;
|
|
||||||
}vfile_t;
|
|
||||||
|
|
||||||
typedef enum fs_flags{
|
typedef enum fs_flags{
|
||||||
FS_FILE_READ_ONLY = 1,
|
FS_FILE_READ_ONLY = 1,
|
||||||
FS_FILE_HIDDEN = 2,
|
FS_FILE_HIDDEN = 2,
|
||||||
FS_FILE_SYSTEM = 4,
|
FS_FILE_SYSTEM = 4,
|
||||||
FS_FILE_IS_DIR = 0x10,
|
FS_FILE_IS_DIR = 0x10,
|
||||||
FS_FILE_ARCHIVE = 0x20
|
FS_FILE_ARCHIVE = 0x20,
|
||||||
|
FS_FILE_PIPE = 0x40,
|
||||||
|
FS_FILE_LINK = 0x80
|
||||||
}FS_FILE_FLAGS;
|
}FS_FILE_FLAGS;
|
||||||
|
|
||||||
typedef struct mount_funcs{
|
typedef struct virtual_file{
|
||||||
int (*write)(vfile_t *file, void *data, uint32_t offset, uint32_t count);
|
char name[256];
|
||||||
int (*read)(vfile_t *file, void *data, uint32_t offset, uint32_t count);
|
FS_FILE_FLAGS flags;
|
||||||
int (*open)(char *filename, vfile_t *file);
|
int (*delete)(struct virtual_file *file_entry);
|
||||||
void (*delete)(vfile_t *file);
|
struct virtual_file *(*create)(char *name, FS_FILE_FLAGS flags);
|
||||||
void (*create)(char *filename, FS_FILE_FLAGS flags);
|
int (*write)(struct virtual_file *file_entry, void *data, uint32_t offset, uint32_t count);
|
||||||
}mount_t;
|
int (*read)(struct virtual_file *file_entry, void *data, uint32_t offset, uint32_t count);
|
||||||
|
struct virtual_file *(*open)(char *name);
|
||||||
typedef struct partition{
|
struct virtual_file **(*lookup)(char *name);
|
||||||
uint8_t attributes;
|
|
||||||
uint8_t chs_start[3];
|
uint32_t id;//for use in drivers
|
||||||
uint8_t type;
|
void * ptr; //also for use in drivers
|
||||||
uint8_t chs_end[3];
|
uint32_t size;
|
||||||
uint32_t lba_start;
|
uint32_t offset; //for use in drivers
|
||||||
uint32_t lba_size;
|
|
||||||
}__attribute__((packed))partition_t;
|
}vfile_t;
|
||||||
|
|
||||||
#define MBR_MAGIC 0xaa55
|
|
||||||
|
|
||||||
typedef struct mbr{
|
|
||||||
char code[440];
|
|
||||||
char id[4];
|
|
||||||
char res[2];
|
|
||||||
partition_t partitions[4];
|
|
||||||
uint16_t magic;
|
|
||||||
}__attribute__((packed)) mbr_t;
|
|
||||||
|
|
||||||
void vfs_init();
|
void vfs_init();
|
||||||
vfile_t *fcreate(char *name, VFILE_TYPE type, ...);
|
vfile_t *fcreate(char *name, FS_FILE_FLAGS flags);
|
||||||
int fdelete(vfile_t* file_entry);
|
int fdelete(vfile_t* file_entry);
|
||||||
int fwrite(vfile_t *file_entry, void *byte_array, uint32_t offset, uint32_t count);
|
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 fread(vfile_t *file_entry, void *byte_array, uint32_t offset, uint32_t count);
|
||||||
vfile_t *lookup(char *name, vfile_t dir);
|
vfile_t *lookup(char *name, vfile_t dir);
|
||||||
vfile_t *fopen(char *name);
|
vfile_t *fopen(char *name);
|
||||||
// void vfs_del_mount_handler(uint32_t key);
|
|
||||||
// void vfs_add_mount_handler(int (*mount_handler)(vfile_t *device, MOUNT_OPERATION op, ...), uint32_t key);
|
|
||||||
void vfs_detect_partitions(vfile_t *file);
|
|
||||||
|
|
@ -208,7 +208,7 @@ int ata_write(vfile_t *file, void *ptr, uint32_t offset, uint32_t count){
|
||||||
if (count == 0) return -1;
|
if (count == 0) return -1;
|
||||||
ata_acquire_primary_lock();
|
ata_acquire_primary_lock();
|
||||||
// }
|
// }
|
||||||
drive_t drive = drives[file->mount_id];
|
drive_t drive = drives[file->id];
|
||||||
uint16_t io_base = drive.BARs[0] &0xfffe;
|
uint16_t io_base = drive.BARs[0] &0xfffe;
|
||||||
uint16_t ctrl_base = drive.BARs[1] &0xfffe;
|
uint16_t ctrl_base = drive.BARs[1] &0xfffe;
|
||||||
uint16_t bm_base = drive.BARs[4] & ~3;
|
uint16_t bm_base = drive.BARs[4] & ~3;
|
||||||
|
|
@ -283,7 +283,7 @@ int ata_write(vfile_t *file, void *ptr, uint32_t offset, uint32_t count){
|
||||||
|
|
||||||
asm("sti");
|
asm("sti");
|
||||||
|
|
||||||
transferring_disk_index = file->mount_id;
|
transferring_disk_index = file->id;
|
||||||
|
|
||||||
uint8_t status = inb(ctrl_base);
|
uint8_t status = inb(ctrl_base);
|
||||||
uint8_t bm_status = inb(bm_base + 2);
|
uint8_t bm_status = inb(bm_base + 2);
|
||||||
|
|
@ -303,7 +303,7 @@ int ata_write(vfile_t *file, void *ptr, uint32_t offset, uint32_t count){
|
||||||
|
|
||||||
int ata_read(vfile_t *file, uint8_t *ptr, uint32_t offset, uint32_t count) {
|
int ata_read(vfile_t *file, uint8_t *ptr, uint32_t offset, uint32_t count) {
|
||||||
if (count == 0) return -1;
|
if (count == 0) return -1;
|
||||||
drive_t drive = drives[file->mount_id];
|
drive_t drive = drives[file->id];
|
||||||
uint16_t io_base = drive.BARs[0] &0xfffe;
|
uint16_t io_base = drive.BARs[0] &0xfffe;
|
||||||
uint16_t ctrl_base = drive.BARs[1] &0xfffe;
|
uint16_t ctrl_base = drive.BARs[1] &0xfffe;
|
||||||
uint16_t bm_base = drive.BARs[4] & ~3;
|
uint16_t bm_base = drive.BARs[4] & ~3;
|
||||||
|
|
@ -372,7 +372,7 @@ int ata_read(vfile_t *file, uint8_t *ptr, uint32_t offset, uint32_t count) {
|
||||||
recieved_ints = 0;
|
recieved_ints = 0;
|
||||||
|
|
||||||
asm("cli");
|
asm("cli");
|
||||||
transferring_disk_index = file->mount_id;
|
transferring_disk_index = file->id;
|
||||||
uint32_t cpid = api(MODULE_API_GET_CPID);
|
uint32_t cpid = api(MODULE_API_GET_CPID);
|
||||||
// api(MODULE_API_PRINT, MODULE_NAME, "Cpid: %x", cpid);
|
// api(MODULE_API_PRINT, MODULE_NAME, "Cpid: %x", cpid);
|
||||||
api(MODULE_API_BLOCK_PID, cpid);
|
api(MODULE_API_BLOCK_PID, cpid);
|
||||||
|
|
@ -522,8 +522,10 @@ uint8_t ata_identify(uint32_t index, uint16_t disk){
|
||||||
uint32_t prdt_phys = api(MODULE_API_PMALLOC64K);
|
uint32_t prdt_phys = api(MODULE_API_PMALLOC64K);
|
||||||
drives[index].PRDT = (void *)api(MODULE_API_KMALLOC_PADDR, prdt_phys, 16);
|
drives[index].PRDT = (void *)api(MODULE_API_KMALLOC_PADDR, prdt_phys, 16);
|
||||||
itoa(ata_drives, fname + strlen(fname), 10);
|
itoa(ata_drives, fname + strlen(fname), 10);
|
||||||
vfile_t *new_file = fcreate(api, fname, VFILE_DEVICE, ata_write, ata_read);
|
vfile_t *new_file = fcreate(api, fname, FS_FILE_SYSTEM);
|
||||||
new_file->mount_id = index;
|
new_file->read = ata_read;
|
||||||
|
new_file->write = ata_write;
|
||||||
|
new_file->id = index;
|
||||||
puts(api, "KIDM", "Valid Drive!\n");
|
puts(api, "KIDM", "Valid Drive!\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -596,8 +598,11 @@ void init(KOS_MAPI_FP module_api, uint32_t api_version){
|
||||||
api(MODULE_API_ADDINT, 15, module_data.key, int_handler);
|
api(MODULE_API_ADDINT, 15, module_data.key, int_handler);
|
||||||
api(MODULE_API_ADDINT, 14, module_data.key, int_handler);
|
api(MODULE_API_ADDINT, 14, module_data.key, int_handler);
|
||||||
// api(MODULE_API_ADDINT, 0, module_data.key, int_handler);
|
// api(MODULE_API_ADDINT, 0, module_data.key, int_handler);
|
||||||
vfile_t *pci_drive_dir = fget_file(api, "/dev/pci/disk/");
|
vfile_t *pci_drive_dir = fopen(api, "/dev/pci/disk/");
|
||||||
vfile_t **dir_data = (pci_drive_dir->access.data.ptr);
|
if(!pci_drive_dir){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
vfile_t **dir_data = (pci_drive_dir->ptr);
|
||||||
for(uint32_t i = 0; dir_data[i]; i++){
|
for(uint32_t i = 0; dir_data[i]; i++){
|
||||||
vfile_t *current_file = dir_data[i];
|
vfile_t *current_file = dir_data[i];
|
||||||
uint32_t class = 0;
|
uint32_t class = 0;
|
||||||
|
|
|
||||||
|
|
@ -53,34 +53,31 @@ enum MESSAGES{
|
||||||
MESSAGE_BROADCAST = 0x80000000, //placeholder
|
MESSAGE_BROADCAST = 0x80000000, //placeholder
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum vfile_type{
|
typedef enum fs_flags{
|
||||||
VFILE_NULL,
|
FS_FILE_READ_ONLY = 1,
|
||||||
VFILE_POINTER,
|
FS_FILE_HIDDEN = 2,
|
||||||
VFILE_DEVICE,
|
FS_FILE_SYSTEM = 4,
|
||||||
VFILE_MOUNT,
|
FS_FILE_IS_DIR = 0x10,
|
||||||
VFILE_DIRECTORY,
|
FS_FILE_ARCHIVE = 0x20,
|
||||||
VFILE_PDIR,//used for directories in physical filesystems.
|
FS_FILE_PIPE = 0x40,
|
||||||
VFILE_FILE,
|
FS_FILE_LINK = 0x80
|
||||||
}VFILE_TYPE;
|
}FS_FILE_FLAGS;
|
||||||
|
|
||||||
typedef struct virtual_file{
|
typedef struct virtual_file{
|
||||||
char name[20];
|
char name[256];
|
||||||
VFILE_TYPE type;
|
FS_FILE_FLAGS flags;
|
||||||
uint32_t id;//to be assigned by driver;
|
int (*delete)(struct virtual_file *file_entry);
|
||||||
uint32_t mount_id;
|
struct virtual_file *(*create)(char *name, FS_FILE_FLAGS flags);
|
||||||
uint8_t lock;
|
int (*write)(struct virtual_file *file_entry, void *data, uint32_t offset, uint32_t count);
|
||||||
|
int (*read)(struct virtual_file *file_entry, void *data, uint32_t offset, uint32_t count);
|
||||||
|
struct virtual_file *(*open)(char *name);
|
||||||
|
struct virtual_file **(*lookup)(char *name);
|
||||||
|
|
||||||
|
uint32_t id;//for use in drivers
|
||||||
|
void * ptr; //also for use in drivers
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
struct virtual_file *parent;//should point to A: a virtual directory, or B: a mounted filesystem
|
uint32_t offset; //for use in drivers
|
||||||
union{
|
|
||||||
struct{
|
|
||||||
int (*read)(struct virtual_file *file, void *data, uint32_t offset, uint32_t count);
|
|
||||||
int (*write)(struct virtual_file *file, void *data, uint32_t offset, uint32_t count);
|
|
||||||
}funcs;
|
|
||||||
struct{
|
|
||||||
void *ptr;
|
|
||||||
uint32_t size_pgs;
|
|
||||||
}__attribute__((packed))data;
|
|
||||||
}access;
|
|
||||||
}vfile_t;
|
}vfile_t;
|
||||||
|
|
||||||
inline void *malloc(KOS_MAPI_FP api, uint32_t size_pages){
|
inline void *malloc(KOS_MAPI_FP api, uint32_t size_pages){
|
||||||
|
|
@ -90,7 +87,7 @@ inline void *free(KOS_MAPI_FP api, void *ptr){
|
||||||
api(MODULE_API_FREE, ptr);
|
api(MODULE_API_FREE, ptr);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
inline vfile_t *fget_file(KOS_MAPI_FP api, char *filename){
|
inline vfile_t *fopen(KOS_MAPI_FP api, char *filename){
|
||||||
// vfile_t *file = malloc(api, 1);
|
// vfile_t *file = malloc(api, 1);
|
||||||
return (void *)api(MODULE_API_OPEN, filename);
|
return (void *)api(MODULE_API_OPEN, filename);
|
||||||
}
|
}
|
||||||
|
|
@ -101,8 +98,8 @@ inline int fwrite(KOS_MAPI_FP api, vfile_t *file, char *buffer, uint32_t offset,
|
||||||
return api(MODULE_API_WRITE, file, buffer, offset, count);
|
return api(MODULE_API_WRITE, file, buffer, offset, count);
|
||||||
}
|
}
|
||||||
//read documenation for this one
|
//read documenation for this one
|
||||||
inline vfile_t *fcreate(KOS_MAPI_FP api, char *filename, VFILE_TYPE type, char *pointer_write, char *size_read){
|
inline vfile_t *fcreate(KOS_MAPI_FP api, char *filename, FS_FILE_FLAGS type){
|
||||||
return (void *)api(MODULE_API_CREAT, filename, type, pointer_write, size_read);
|
return (void *)api(MODULE_API_CREAT, filename, type);
|
||||||
}
|
}
|
||||||
inline void puts(KOS_MAPI_FP api, char *mname, char *str){
|
inline void puts(KOS_MAPI_FP api, char *mname, char *str){
|
||||||
api(MODULE_API_PRINT, mname, str);
|
api(MODULE_API_PRINT, mname, str);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue