A VFS driver for Able OS :D
Go to file
2023-07-12 15:48:49 -04:00
holey-bytes@7599542226 Updataa 2023-07-12 15:48:49 -04:00
src gaming 2023-07-12 06:47:49 -04:00
.gitignore Get started 2023-07-12 02:17:00 -04:00
.gitmodules Get started 2023-07-12 02:17:00 -04:00
LICENSE Initial commit 2023-07-12 05:35:06 +00:00
README.md Updataa 2023-07-12 15:48:49 -04:00
run.sh gaming 2023-07-12 06:47:49 -04:00

AbleOS VFS

Public API

// reads the whole file
pub fn read(file: FileHandle) -> Vec<u8>

// overwrites the contents of the file
pub fn write(file: FileHandle, data: Vec<u8>)

// opens a file for reading and writing
pub fn open(path: Path)

// closes the file
pub fn close(file: FileHandle)

// deletes a file
pub fn delete(path: Path)

Opening a file opens it using the corresponding filesystem. Multiple processes can open the same file in any mode, and the file only leaves the FS cache when no process has it open anymore.

Minimal FS API

trait FileIO {
    // reads the whole file
    pub fn read(path: Path) -> Vec<u8>

    // overwrites the file contents
    pub fn write(path: Path, data: Vec<u8>)

    // opens a file for reading and writing
    pub fn open(path: Path)

    // closes a file, removing it from the cache
    pub fn close(path: Path)

    // deletes a file
    pub fn delete(path: Path)
}

All filesystems must expose at least these functions in order to work with the VFS.

Structure

Mount Point Lookup Entry

path_len: u64
path: [u8; <path_len>]
entries: u64
addr: u64

There is one of these for each mount point, stored sequentially. The list ends when it finds a path_len of 0

Sub Part

name_len: u64
name: [u8; <name_len>]
dir: u8
size: u64
addr: u64

There can be many of these in a mount point, and they can be nested within eachother. dir is 1 if the part is a directory, or 0 if it's a file. size specifies the number of sub parts within a directory, or the number of bytes within a file