function defs for ramfs
This commit is contained in:
parent
e5ce4d42d1
commit
c2f258f1bb
|
|
@ -39,6 +39,8 @@
|
|||
#define KMALLOC_LINK_NEXT 2
|
||||
#define KMALLOC_LINK_LAST 4
|
||||
|
||||
#define PAGE_SIZE_BYTES 4096
|
||||
|
||||
typedef struct BIOS_data{
|
||||
uint16_t com_ports[4];
|
||||
uint16_t lpt_ports[3];
|
||||
|
|
|
|||
|
|
@ -9,6 +9,12 @@
|
|||
fileops_t ramfs_ops =
|
||||
{
|
||||
ramfs_create,
|
||||
ramfs_delete,
|
||||
ramfs_write,
|
||||
ramfs_read,
|
||||
ramfs_open,
|
||||
ramfs_close,
|
||||
ramfs_rfopen,
|
||||
};
|
||||
|
||||
vfile_t root_dir = {"/", FS_FILE_IS_DIR | FS_FILE_SYSTEM, &ramfs_ops};
|
||||
|
|
@ -16,13 +22,39 @@ vfile_t root_dir = {"/", FS_FILE_IS_DIR | FS_FILE_SYSTEM, &ramfs_ops};
|
|||
void ramfs_init(){
|
||||
mlog(MODULE_NAME, "Initializing VFS\n", MLOG_PRINT);
|
||||
root_dir.private = kmalloc(1);
|
||||
root_dir.size = 4096;//one page is 4096 bytes
|
||||
root_dir.size = PAGE_SIZE_BYTES;//one page is 4096 bytes
|
||||
}
|
||||
|
||||
vfile_t *resolve_path(char *pathname){
|
||||
|
||||
}
|
||||
|
||||
vfile_t *ramfs_create(char *path, FS_FILE_FLAGS flags){
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ramfs_delete(vfile_t *file){
|
||||
|
||||
}
|
||||
int ramfs_write(vfile_t *file, char *buffer, uint32_t offset, uint32_t count){
|
||||
|
||||
}
|
||||
int ramfs_read(vfile_t *file, char *buffer, uint32_t offset, uint32_t count){
|
||||
|
||||
}
|
||||
vfile_t *ramfs_open(char *path){
|
||||
|
||||
}
|
||||
void ramfs_close(vfile_t *file){
|
||||
file->refcount--;
|
||||
if(file->refcount < 0) file->refcount = 0;
|
||||
return;
|
||||
}
|
||||
vfile_t *ramfs_rfopen(char *name, vfile_t *parent){
|
||||
|
||||
}
|
||||
|
||||
vfile_t *get_root_dir(){
|
||||
return &root_dir;
|
||||
}
|
||||
|
|
@ -4,4 +4,11 @@
|
|||
void ramfs_init();
|
||||
vfile_t *ramfs_create(char *path, FS_FILE_FLAGS flags);
|
||||
//Will never create a new reference
|
||||
vfile_t *get_root_dir();
|
||||
vfile_t *get_root_dir();
|
||||
|
||||
int ramfs_delete(vfile_t *file);
|
||||
int ramfs_write(vfile_t *file, char *buffer, uint32_t offset, uint32_t count);
|
||||
int ramfs_read(vfile_t *file, char *buffer, uint32_t offset, uint32_t count);
|
||||
vfile_t *ramfs_open(char *path);
|
||||
void ramfs_close(vfile_t *file);
|
||||
vfile_t *ramfs_rfopen(char *name, vfile_t *parent);
|
||||
|
|
@ -6,6 +6,7 @@
|
|||
#define MODULE_NAME "KVFS"
|
||||
|
||||
// !TODO: Modify code to become thread-safe
|
||||
// 3 months later: does this count?
|
||||
|
||||
|
||||
// void add_file(vfile_t *vfile, vfile_t *current_dir){
|
||||
|
|
@ -80,7 +81,7 @@ vfile_t *rfopen(char *name, vfile_t *dir){
|
|||
if(!dir || !name || !dir->fileops || !dir->fileops->rfopen){
|
||||
return 0;
|
||||
}
|
||||
return dir->fileops->rfopen(name);
|
||||
return dir->fileops->rfopen(name, dir);
|
||||
}
|
||||
|
||||
int readdir(vfile_t* file, vfile_t* buffer, uint32_t offset, uint32_t count){
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ typedef struct fileops{
|
|||
struct virtual_file *(*open)(char *path);
|
||||
void (*close)(struct virtual_file *file);
|
||||
// int (*readdir)(struct virtual_file* file, struct virtual_file *buffer, uint32_t count, uint32_t offset);
|
||||
struct virtual_file *(*rfopen)(char *name);
|
||||
struct virtual_file *(*rfopen)(char *name, struct virtual_file *parent);
|
||||
} fileops_t;
|
||||
|
||||
typedef struct virtual_file{
|
||||
|
|
|
|||
Loading…
Reference in New Issue