Retro Rocket Kernel
BASIC-Powered Operating System
filesystem_t Struct Reference

Defines a filesystem driver. More...

#include <filesystem.h>

+ Collaboration diagram for filesystem_t:

Data Fields

char name [32]
 Name of filesystem driver, e.g. 'fat32'. More...
 
mount_volume mount
 Function pointer for mount() Mounts the filesystem to a storage device. More...
 
get_directory getdir
 Function pointer for getdir() Retrieves a list of files in a directory. More...
 
read_file readfile
 Function pointer for readfile() Retrieves file contents from an arbitrary location in a file on the filesystem. Attempts to read any content outside of the files extent should be handled by returning only what is available. More...
 
write_file writefile
 Function pointer for writefile() Writes data to arbitrary location in a file on the filesystem. The file must exist, and writefile() should not create new files, this is the reponsibility of the createfile() endpoint. More...
 
create_file createfile
 Function pointer for createfile() Creates a new file filled with null bytes, of the requested size. The file size on the media may be larger, to account for slack, but the reported size must be that provided. More...
 
truncate_file truncatefile
 Function pointer for truncatefile() Truncates an existing file to a new length, discarding any data past the new size and freeing it for re-use. More...
 
create_dir createdir
 Function pointer for createdir() Create a new empty directory. The directory should not already exist within the given parent directory. More...
 
delete_file rm
 Function pointer for rm() Remove an existing file. The file should already exist in the parent directory, and should not itself be a directory. More...
 
delete_dir rmdir
 Function pointer for rmdir() Remove an existing directory. The directory should already exist in the parent directory, and should be empty of all non-special entries (e.g. '.' and '..' are permitted to still exist) More...
 
struct filesystem_tnext
 Pointer to next filesystem driver or NULL. More...
 

Detailed Description

Defines a filesystem driver.

A driver does not need to implement all functions listed here. An unimplemented function should be NULL.

At a bare minimum a filesystem should support: mount, getdir, readfile

For full read/write support, all endpoints should be defined.

Note
The VFS maintains a separate cache of the directory structure which is adjusted to match any requests made to the underlying filesystem driver. The filesystem driver does not have to concern itself with keeping this cache up to date.

Field Documentation

◆ createdir

create_dir filesystem_t::createdir

Function pointer for createdir() Create a new empty directory. The directory should not already exist within the given parent directory.

◆ createfile

create_file filesystem_t::createfile

Function pointer for createfile() Creates a new file filled with null bytes, of the requested size. The file size on the media may be larger, to account for slack, but the reported size must be that provided.

The file must not already exist, createfile() should not overwrite existing data.

◆ getdir

get_directory filesystem_t::getdir

Function pointer for getdir() Retrieves a list of files in a directory.

◆ mount

mount_volume filesystem_t::mount

Function pointer for mount() Mounts the filesystem to a storage device.

◆ name

char filesystem_t::name[32]

Name of filesystem driver, e.g. 'fat32'.

◆ next

struct filesystem_t* filesystem_t::next

Pointer to next filesystem driver or NULL.

◆ readfile

read_file filesystem_t::readfile

Function pointer for readfile() Retrieves file contents from an arbitrary location in a file on the filesystem. Attempts to read any content outside of the files extent should be handled by returning only what is available.

◆ rm

delete_file filesystem_t::rm

Function pointer for rm() Remove an existing file. The file should already exist in the parent directory, and should not itself be a directory.

◆ rmdir

delete_dir filesystem_t::rmdir

Function pointer for rmdir() Remove an existing directory. The directory should already exist in the parent directory, and should be empty of all non-special entries (e.g. '.' and '..' are permitted to still exist)

◆ truncatefile

truncate_file filesystem_t::truncatefile

Function pointer for truncatefile() Truncates an existing file to a new length, discarding any data past the new size and freeing it for re-use.

The file must exist. To create a new file of a given length, the createfile() endpoint should be used instead.

◆ writefile

write_file filesystem_t::writefile

Function pointer for writefile() Writes data to arbitrary location in a file on the filesystem. The file must exist, and writefile() should not create new files, this is the reponsibility of the createfile() endpoint.

The writefile() endpoint should extend the length of existing files where required however, without error and without any special requirements having to be met, hardware permitting.