My Project
Loading...
Searching...
No Matches
vfs.h
Go to the documentation of this file.
1/*
2 * PROJECT: MatanelOS Kernel
3 * LICENSE: GPLv3
4 * PURPOSE: Virtual File System (VFS) Header Functions & Structures.
5 */
6
7#ifndef X86_VFS_H
8#define X86_VFS_H
9
10// Include the FAT32 Header.
11#include "../fat32/fat32.h"
12
17
18typedef struct FS_DRIVER {
19 MTSTATUS(*init)(uint8_t device_id);
20 MTSTATUS(*read)(const char* filename, uint32_t* file_size_out, void** buffer_out);
21 MTSTATUS(*write)(const char* path, const void* data, uint32_t size, uint32_t mode);
22 MTSTATUS(*delete)(const char* path);
23 MTSTATUS(*mkdir)(const char* path);
24 MTSTATUS(*rmdir)(const char* path);
25 bool(*is_dir_empty)(const char* path);
26 MTSTATUS(*listdir)(const char* path, char* listings, size_t max_len);
27 void(*listrootdir)(void);
29
34MTSTATUS vfs_init(void);
35
43MTSTATUS vfs_read(const char* filename, uint32_t* file_size_out, void** buffer_out);
44
53MTSTATUS vfs_write(const char* path, const void* data, uint32_t size, FS_WRITE_MODES write_mode);
54
60MTSTATUS vfs_delete(const char* path);
61
69MTSTATUS vfs_listdir(const char* path, char* listings, size_t max_len);
70
76MTSTATUS vfs_mkdir(const char* path);
77
83MTSTATUS vfs_rmdir(const char* path);
84
90bool vfs_is_dir_empty(const char* path);
91
95void vfs_listrootdir(void);
96
97#endif
#define WRITE_MODE_APPEND_EXISTING
Definition fat32.c:15
#define WRITE_MODE_CREATE_OR_REPLACE
Definition fat32.c:16
int32_t MTSTATUS
Definition mtstatus.h:12
MTSTATUS(* write)(const char *path, const void *data, uint32_t size, uint32_t mode)
Definition vfs.h:21
bool(* is_dir_empty)(const char *path)
Definition vfs.h:25
MTSTATUS(* read)(const char *filename, uint32_t *file_size_out, void **buffer_out)
Definition vfs.h:20
MTSTATUS(* init)(uint8_t device_id)
Definition vfs.h:19
MTSTATUS(* listdir)(const char *path, char *listings, size_t max_len)
Definition vfs.h:26
void(* listrootdir)(void)
Definition vfs.h:27
MTSTATUS(* mkdir)(const char *path)
Definition vfs.h:23
MTSTATUS(* rmdir)(const char *path)
Definition vfs.h:24
MTSTATUS vfs_read(const char *filename, uint32_t *file_size_out, void **buffer_out)
Reads the file into a buffer.
Definition vfs.c:87
MTSTATUS vfs_rmdir(const char *path)
This function deletes the directory given to the function from the system along with its file (marks ...
Definition vfs.c:122
void vfs_listrootdir(void)
This function will list the root directory of the main mount device.
Definition vfs.c:136
MTSTATUS vfs_listdir(const char *path, char *listings, size_t max_len)
Lists the directory given.
Definition vfs.c:108
MTSTATUS vfs_mkdir(const char *path)
Creates a new directory.
Definition vfs.c:115
bool vfs_is_dir_empty(const char *path)
This function returns if the directory given to the function is empty (e.g, has only '....
Definition vfs.c:129
enum _FS_WRITE_MODES FS_WRITE_MODES
MTSTATUS vfs_delete(const char *path)
This function deletes the file given to the function from the system.
Definition vfs.c:101
_FS_WRITE_MODES
Definition vfs.h:13
MTSTATUS vfs_init(void)
Initialize the Virtual File System (initializes other filesystem needed services as well)
Definition vfs.c:42
MTSTATUS vfs_write(const char *path, const void *data, uint32_t size, FS_WRITE_MODES write_mode)
Creates a new file (or opens existing) and writes data to it.
Definition vfs.c:94