|
tape-kernel 1.0
a modular modern independent kernel
|
#include "fs.h"#include "ide.h"#include "../mem/heap.h"#include "../lib/err.h"#include "../lib/utils.h"
Go to the source code of this file.
Classes | |
| struct | fs_entry_t |
| the fs_entry_t type More... | |
Macros | |
| #define | FS_TABLE_LBA 1 |
Functions | |
| void | __fsinit (arena_t *heap) |
| fsinit initializes the filesystem table from disk | |
| void | __fsadd (arena_t *heap, const char *name, uint32_t lba) |
| fsadd adds a new file entry to the filesystem | |
| uint32_t | __fsfind (const char *name) |
| fsfind searches the filesystem for a file by name | |
| char * | __fslist (void) |
| fslist returns a newline-separated listing of all files | |
| uint32_t | __fsnextlba (void) |
| fsnextlba finds the next unused lba for a new file | |
| char * | __fsread (const char *name) |
| fsread reads a files contents from disk into memory | |
| int | __fswrite (arena_t *heap, const char *name, const char *content) |
| fswrite writes text content to a file on disk | |
| void | __fsdelete (const char *name) |
| fsdelete removes a file from the filesystem | |
| int | __fswriteb (arena_t *heap, const char *name, uint8_t *data, uint32_t size) |
| fswriteb writes raw byte data to a file on disk | |
| int | __fsreadb (const char *name, uint8_t *buffer, uint32_t max_size) |
| fsreadb reads raw byte data from a file off disk | |
Variables | |
| static fs_entry_t | files [32] |
| static int | file_count = 0 |
| static arena_t * | fs_heap = ((void*)0) |
| static uint32_t | lba_map [32] |
| #define FS_TABLE_LBA 1 |
Definition at line 8 of file fs.c.
Referenced by __fsadd(), __fsdelete(), and __fsinit().
fsadd adds a new file entry to the filesystem
fsadd is a function that registers a file name and lba into the in-memory file table and persists it to disk
| heap,the | arena to allocate the filename from |
| name,the | name of the file to add |
| lba,the | logical block address where the file lives |
using fsadd is done with
Definition at line 102 of file fs.c.
References alc, assert, file_count, files, FS_TABLE_LBA, iwrt, MAX_FILES, NULL, and strcpy().
| void __fsdelete | ( | const char * | name | ) |
fsdelete removes a file from the filesystem
fsdelete is a function that finds a file by name, zeros out its data sector on disk, marks its lba as free, and removes it from the in-memory file table
| name,the | filename to delete |
using fsdelete is done with
Definition at line 316 of file fs.c.
References assert, file_count, files, FS_TABLE_LBA, iwrt, lba_map, MAX_FILES, and strcmp().
| uint32_t __fsfind | ( | const char * | name | ) |
fsfind searches the filesystem for a file by name
fsfind is a function that looks up a file in the in-memory table and returns its lba if found
| name,the | filename to search for |
using fsfind is done with
Definition at line 150 of file fs.c.
References file_count, files, and strcmp().
| void __fsinit | ( | arena_t * | heap | ) |
fsinit initializes the filesystem table from disk
fsinit is a function that reads the filesystem table from the disk, parses all existing file entries, and rebuilds the lba map
| heap,the | arena to allocate filename strings from |
using fsinit is done with
Definition at line 44 of file fs.c.
References alc, file_count, files, fs_heap, FS_TABLE_LBA, irsec, lba_map, and MAX_FILES.
| char * __fslist | ( | void | ) |
fslist returns a newline-separated listing of all files
fslist is a function that builds a string containing all filenames in the in-memory filesystem table separated by newlines
using fslist is done with
Definition at line 174 of file fs.c.
References file_count, and files.
| uint32_t __fsnextlba | ( | void | ) |
fsnextlba finds the next unused lba for a new file
fsnextlba is a function that scans the lba map for a free slot and returns an unused lba starting from sector 100
using fsnextlba is done with
| char * __fsread | ( | const char * | name | ) |
fsread reads a files contents from disk into memory
fsread is a function that looks up a file by name, reads its sector from disk, and returns the contents as a string
| name,the | filename to read |
using fsread is done with
fsreadb reads raw byte data from a file off disk
fsreadb is a function that reads raw bytes from a file sector into a provided buffer
| name,the | filename to read |
| buffer,the | buffer to store the raw bytes in |
| max_size,the | maximum number of bytes to read |
using fsreadb is done with
| int __fswrite | ( | arena_t * | heap, |
| const char * | name, | ||
| const char * | content ) |
fswrite writes text content to a file on disk
fswrite is a function that writes a text string to a file, creating the file entry if it doesnt exist yet
| heap,the | arena to allocate from if a new file entry is created |
| name,the | filename to write to |
| content,the | text string to write |
using fswrite is done with
fswriteb writes raw byte data to a file on disk
fswriteb is a function that writes raw bytes to a file sector, limited to 511 bytes per sector, creating the file entry if needed
| heap,the | arena to allocate from if a new file entry is created |
| name,the | filename to write to |
| data,the | raw byte buffer to write |
| size,the | number of bytes to write |
using fswriteb is done with
|
static |
Definition at line 25 of file fs.c.
Referenced by __fsadd(), __fsdelete(), __fsfind(), __fsinit(), and __fslist().
|
static |
Definition at line 24 of file fs.c.
Referenced by __fsadd(), __fsdelete(), __fsfind(), __fsinit(), and __fslist().
|
static |
Definition at line 26 of file fs.c.
Referenced by __fsinit().
|
static |
Definition at line 27 of file fs.c.
Referenced by __fsdelete(), __fsinit(), and __fsnextlba().