|
Retro Rocket Kernel
BASIC-Powered Operating System
|
Data Structures | |
| struct | fs_directory_entry_t |
| A VFS directory entry. Files AND directories have these, but internally there is also a tree of fs_tree_t* which is used for faster access and caching the structure to RAM. More... | |
| struct | filesystem_t |
| Defines a filesystem driver. More... | |
| struct | storage_device_t |
| Represents a block storage device e.g. a hard disk, DVD-ROM drive, etc. More... | |
| struct | fs_tree_t |
| Used internally by filesystem.c to cache directories to RAM. More... | |
| struct | fs_handle_t |
| The data for an open file descriptor. More... | |
Macros | |
| #define | FD_MAX 1024 |
| Maximum number of file descriptors which can be open at the same time. More... | |
| #define | IOBUFSZ 8192 |
| Default size of IO buffer in open file. More... | |
| #define | _O_APPEND 0x00000001 |
| #define | _O_CREAT 0x00000002 |
| #define | _O_RDONLY 0x00000004 |
| #define | _O_WRONLY 0x00000008 |
| #define | _O_RDWR (_O_WRONLY|_O_RDONLY) |
| #define | FS_DIRECTORY 0x00000001 /* Entry is a directory */ |
| #define | FS_MOUNTPOINT 0x00000002 /* Entry is a mountpoint */ |
Typedefs | |
| typedef uint16_t | mode_t |
| typedef void *(* | get_directory) (void *) |
| typedef int(* | mount_volume) (const char *, const char *) |
| typedef bool(* | read_file) (void *, uint64_t, uint32_t, unsigned char *) |
| typedef bool(* | write_file) (void *, uint64_t, uint32_t, unsigned char *) |
| typedef uint64_t(* | create_file) (void *, const char *, size_t) |
| typedef bool(* | truncate_file) (void *, size_t) |
| typedef uint64_t(* | create_dir) (void *, const char *) |
| typedef bool(* | delete_file) (void *, const char *) |
| typedef bool(* | delete_dir) (void *, const char *) |
| typedef int(* | block_read) (void *, uint64_t, uint32_t, unsigned char *) |
| typedef int(* | block_write) (void *, uint64_t, uint32_t, const unsigned char *) |
Enumerations | |
| enum | fs_handle_type_t { file_input , file_output , file_random } |
| File handle access type. More... | |
Functions | |
| int | register_filesystem (filesystem_t *newfs) |
| Register a new filesystem. More... | |
| filesystem_t * | find_filesystem (const char *name) |
| Find a filesystem by name. More... | |
| int | register_storage_device (storage_device_t *newdev) |
| Register a new storage device. More... | |
| storage_device_t * | find_storage_device (const char *name) |
| Find a storage device by name. More... | |
| int | read_storage_device (const char *name, uint64_t start_block, uint32_t bytes, unsigned char *data) |
| Read blocks from storage device by name. More... | |
| int | write_storage_device (const char *name, uint64_t start_block, uint32_t bytes, const unsigned char *data) |
| Write blocks to storage device by name. More... | |
| int | attach_filesystem (const char *virtual_path, filesystem_t *fs, void *opaque) |
| Attach a filesystem to a VFS directory. Do not use this function for end user features, use filesystem_mount() instead. More... | |
| int | filesystem_mount (const char *pathname, const char *device, const char *filesystem_driver) |
| High level mount function. More... | |
| void | init_filesystem () |
| Initialise the filesystem This loads the DummyFS filesystem which manages the root directory until any other driver is loaded. DummyFS is a dummy and does nothing. More... | |
| fs_directory_entry_t * | fs_get_items (const char *pathname) |
| Get a list of files in a directory. The directory path must be fully qualified from the root directory and must contain no trailing slash. More... | |
| bool | fs_is_directory (const char *pathname) |
| Returns true if the given path is a directory, false if it is a file. More... | |
| fs_directory_entry_t * | fs_get_file_info (const char *pathandfile) |
| Retrieve file information on any arbitrary filename. The item requested can be a file, or a directory. More... | |
| fs_directory_entry_t * | fs_create_file (const char *pathandfile, size_t bytes) |
| Create a new empty file. More... | |
| fs_directory_entry_t * | fs_create_directory (const char *pathandfile) |
| Create a new empty directory. More... | |
| int | fs_truncate_file (fs_directory_entry_t *file, uint32_t length) |
| Truncate an existing file to new length. More... | |
| int | fs_read_file (fs_directory_entry_t *file, uint32_t start, uint32_t length, unsigned char *buffer) |
| Read raw bytes from any arbitrary file. More... | |
| int | _open (const char *filename, int oflag) |
| POSIX style _open function. More... | |
| int | _read (int fd, void *buffer, unsigned int count) |
| POSIX _read function, reads bytes from an open file. More... | |
| int | _write (int fd, void *buffer, unsigned int count) |
| POSIX _write function, writes bytes to an open file. More... | |
| int | _close (uint32_t fd) |
| POSIX _close function, closes an open file. More... | |
| int | _eof (int fd) |
| POSIX _eof function. More... | |
| int64_t | _lseek (int fd, uint64_t offset, uint64_t origin) |
| Seek to given position in a file. More... | |
| int64_t | _tell (int fd) |
| Obtain current file position. More... | |
| int | unlink (const char *pathname) |
| Delete a file (not a directory) More... | |
| int | mkdir (const char *pathname, mode_t mode) |
| Make a directory. More... | |
| int | rmdir (const char *pathname) |
| Remove a directory. More... | |
| int | ftruncate (int fd, uint32_t length) |
| Truncate a file to the new length. More... | |
| bool | fs_delete_file (const char *pathandfile) |
| Low level delete file. More... | |
| bool | fs_delete_directory (const char *pathandfile) |
| Delete a directory. More... | |
| #define _O_APPEND 0x00000001 |
| #define _O_CREAT 0x00000002 |
| #define _O_RDONLY 0x00000004 |
| #define _O_WRONLY 0x00000008 |
| #define FD_MAX 1024 |
Maximum number of file descriptors which can be open at the same time.
| #define IOBUFSZ 8192 |
Default size of IO buffer in open file.
| typedef int(* block_read) (void *, uint64_t, uint32_t, unsigned char *) |
| typedef int(* block_write) (void *, uint64_t, uint32_t, const unsigned char *) |
| typedef uint64_t(* create_dir) (void *, const char *) |
| typedef uint64_t(* create_file) (void *, const char *, size_t) |
| typedef bool(* delete_dir) (void *, const char *) |
| typedef bool(* delete_file) (void *, const char *) |
| typedef void*(* get_directory) (void *) |
| typedef uint16_t mode_t |
| typedef int(* mount_volume) (const char *, const char *) |
| typedef bool(* read_file) (void *, uint64_t, uint32_t, unsigned char *) |
| typedef bool(* truncate_file) (void *, size_t) |
| typedef bool(* write_file) (void *, uint64_t, uint32_t, unsigned char *) |
| enum fs_handle_type_t |
| int _close | ( | uint32_t | fd | ) |
POSIX _close function, closes an open file.
| fd | file descriptor |
| int _eof | ( | int | fd | ) |
POSIX _eof function.
reports if we have reached the end of file marker on any open file.
| fd | file descriptor |
| int64_t _lseek | ( | int | fd, |
| uint64_t | offset, | ||
| uint64_t | origin | ||
| ) |
Seek to given position in a file.
| fd | file descriptor |
| offset | offset from origin point |
| origin | origin point in file |
| int _open | ( | const char * | filename, |
| int | oflag | ||
| ) |
POSIX style _open function.
opens a file for read or write access, or creates a new file.
| filename | Filename to create (fully qualified name) |
| oflag | open state for the file |
| int _read | ( | int | fd, |
| void * | buffer, | ||
| unsigned int | count | ||
| ) |
POSIX _read function, reads bytes from an open file.
| fd | file descriptor |
| buffer | buffer to receive data |
| count | count of bytes to read |
| int64_t _tell | ( | int | fd | ) |
Obtain current file position.
| fd | file descriptor |
| int _write | ( | int | fd, |
| void * | buffer, | ||
| unsigned int | count | ||
| ) |
POSIX _write function, writes bytes to an open file.
| fd | file descriptor |
| buffer | buffer containing data to write |
| count | count of bytes to write |
| int attach_filesystem | ( | const char * | virtual_path, |
| filesystem_t * | fs, | ||
| void * | opaque | ||
| ) |
Attach a filesystem to a VFS directory. Do not use this function for end user features, use filesystem_mount() instead.
| virtual_path | virtual pathname in the VFS |
| fs | Filesystem driver name |
| opaque | Opaque data used by the filesystem driver |
| int filesystem_mount | ( | const char * | pathname, |
| const char * | device, | ||
| const char * | filesystem_driver | ||
| ) |
High level mount function.
| pathname | VFS path to mount device/driver to |
| device | block device name |
| filesystem_driver | filesystem driver name |
| filesystem_t* find_filesystem | ( | const char * | name | ) |
Find a filesystem by name.
| name | Name of filesystem to find |
| storage_device_t* find_storage_device | ( | const char * | name | ) |
Find a storage device by name.
| name | Name of storage device to find |
| fs_directory_entry_t* fs_create_directory | ( | const char * | pathandfile | ) |
Create a new empty directory.
| pathandfile | fully qualified path to new directory to create |
| bytes | size in bytes of directory to create |
| fs_directory_entry_t* fs_create_file | ( | const char * | pathandfile, |
| size_t | bytes | ||
| ) |
Create a new empty file.
| pathandfile | fully qualified path to new file to create |
| bytes | size in bytes of file to create |
| bool fs_delete_directory | ( | const char * | pathandfile | ) |
Delete a directory.
| pathandfile | fully qualified path to file |
| bool fs_delete_file | ( | const char * | pathandfile | ) |
Low level delete file.
| pathandfile | path and filename |
| fs_directory_entry_t* fs_get_file_info | ( | const char * | pathandfile | ) |
Retrieve file information on any arbitrary filename. The item requested can be a file, or a directory.
| pathandfile | Path to file or directory |
| fs_directory_entry_t* fs_get_items | ( | const char * | pathname | ) |
Get a list of files in a directory. The directory path must be fully qualified from the root directory and must contain no trailing slash.
| pathname | fully qualified directory name |
| bool fs_is_directory | ( | const char * | pathname | ) |
Returns true if the given path is a directory, false if it is a file.
| pathname | full qualified vfs path |
| int fs_read_file | ( | fs_directory_entry_t * | file, |
| uint32_t | start, | ||
| uint32_t | length, | ||
| unsigned char * | buffer | ||
| ) |
Read raw bytes from any arbitrary file.
| file | File to read from |
| start | starting byte position |
| length | length of data to read, starting at the starting position |
| buffer | Buffer to receive read data |
| int fs_truncate_file | ( | fs_directory_entry_t * | file, |
| uint32_t | length | ||
| ) |
Truncate an existing file to new length.
| file | File to truncate |
| length | New length, should be <= current file size |
| int ftruncate | ( | int | fd, |
| uint32_t | length | ||
| ) |
Truncate a file to the new length.
| fd | file descriptor of an open file |
| length | New file length |
| void init_filesystem | ( | ) |
Initialise the filesystem This loads the DummyFS filesystem which manages the root directory until any other driver is loaded. DummyFS is a dummy and does nothing.
| int mkdir | ( | const char * | pathname, |
| mode_t | mode | ||
| ) |
Make a directory.
| pathname | Fully qualified pathname |
| mode | UNIX permission mode, ignored |
| int read_storage_device | ( | const char * | name, |
| uint64_t | start_block, | ||
| uint32_t | bytes, | ||
| unsigned char * | data | ||
| ) |
Read blocks from storage device by name.
| name | Name of storage device registered by register_storage_device() |
| start_block | Starting block number |
| bytes | Number of bytes to read (should be modulus of block size) |
| data | Buffer to receive read data |
| int register_filesystem | ( | filesystem_t * | newfs | ) |
Register a new filesystem.
| newfs | Pointer to new filesystem information to register |
| int register_storage_device | ( | storage_device_t * | newdev | ) |
Register a new storage device.
| newdev | New storage device information to register |
| int rmdir | ( | const char * | pathname | ) |
Remove a directory.
| pathname | Fully qualified pathname |
| int unlink | ( | const char * | pathname | ) |
Delete a file (not a directory)
| pathname | Fully qualified pathname |
| int write_storage_device | ( | const char * | name, |
| uint64_t | start_block, | ||
| uint32_t | bytes, | ||
| const unsigned char * | data | ||
| ) |
Write blocks to storage device by name.
| name | Name of storage device registered by register_storage_device() |
| start_block | Starting block number |
| bytes | Number of bytes to write (should be modulus of block size) |
| data | Data to write |