libdragon
|
DragonFS. More...
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <sys/stat.h>
#include "libdragon.h"
#include "system.h"
#include "dfsinternal.h"
Enumerations | |
enum | { WALK_CHDIR, WALK_OPEN } |
Directory walking flags. More... | |
enum | { TYPE_ANY, TYPE_FILE, TYPE_DIR } |
Directory walking return flags. More... | |
Functions | |
static void | grab_sector (void *cart_loc, void *ram_loc) |
Read a sector from cartspace. | |
static open_file_t * | find_free_file () |
Find a free open file structure. | |
static open_file_t * | find_open_file (uint32_t x) |
Find an open file structure based on a handle. | |
static int | sector_from_loc (uint32_t loc) |
Look up a sector number based on offset. | |
static int | offset_into_sector (uint32_t loc) |
Look up a byte offset into a sector. | |
static int | data_left_in_sector (uint32_t loc) |
Look up the remaining data size in a sector. | |
static uint32_t | get_flags (directory_entry_t *dirent) |
Return the file flags given a directory entry. | |
static uint32_t | get_size (directory_entry_t *dirent) |
Return the file size given a directory entry. | |
static directory_entry_t * | get_first_entry (directory_entry_t *dirent) |
Get the directory pointer from a directory entry. | |
static directory_entry_t * | get_next_entry (directory_entry_t *dirent) |
Get the next directory entry. | |
static file_entry_t * | get_first_sector (directory_entry_t *dirent) |
Get the file pointer from a directory entry. | |
static file_entry_t * | get_next_sector (file_entry_t *fileent) |
Get the next file sector given a current file sector. | |
static void | walk_sectors (open_file_t *file, uint32_t num_sectors) |
Walk forward in a file a specified number of sectors. | |
static void | clear_directory () |
Reset the directory stack to the root. | |
static void | push_directory (directory_entry_t *dirent) |
Push a directory onto the stack. | |
static directory_entry_t * | pop_directory () |
Pop a directory from the stack. | |
static directory_entry_t * | peek_directory () |
Peek at the top directory on the stack. | |
static char * | get_next_token (char *path, char *token) |
Parse out the next token in a path delimited by '\'. | |
static directory_entry_t * | find_dirent (char *name, directory_entry_t *cur_node) |
Find a directory node in the current path given a name. | |
static int | recurse_path (const char *const path, int mode, directory_entry_t **dirent, int type) |
Walk a path string, either changing directories or finding the right path. | |
static int | __dfs_init (uint32_t base_fs_loc) |
Helper functioner to initialize the filesystem. | |
int | dfs_chdir (const char *const path) |
Change directories to the specified path. | |
int | dfs_dir_findfirst (const char *const path, char *buf) |
Find the first file or directory in a directory listing. | |
int | dfs_dir_findnext (char *buf) |
Find the next file or directory in a directory listing. | |
int | dfs_open (const char *const path) |
Open a file given a path. | |
int | dfs_close (uint32_t handle) |
Close an already open file handle. | |
int | dfs_seek (uint32_t handle, int offset, int origin) |
Seek to an offset in the file. | |
int | dfs_tell (uint32_t handle) |
Return the current offset into a file. | |
int | dfs_read (void *const buf, int size, int count, uint32_t handle) |
Read data from a file. | |
int | dfs_size (uint32_t handle) |
Return the file size of an open file. | |
int | dfs_eof (uint32_t handle) |
Return whether the end of file has been reached. | |
static void * | __open (char *name, int flags) |
Newlib-compatible open. | |
static int | __fstat (void *file, struct stat *st) |
Newlib-compatible fstat. | |
static int | __lseek (void *file, int ptr, int dir) |
Newlib-compatible lseek. | |
static int | __read (void *file, uint8_t *ptr, int len) |
Newlib-compatible read. | |
static int | __close (void *file) |
Newlib-compatible close. | |
static int | __findfirst (char *path, dir_t *dir) |
Newlib-compatible findfirst. | |
static int | __findnext (dir_t *dir) |
Newlib-compatible findnext. | |
int | dfs_init (uint32_t base_fs_loc) |
Initialize the filesystem. | |
Variables | |
static uint32_t | base_ptr = 0 |
Base filesystem pointer. | |
static open_file_t | open_files [MAX_OPEN_FILES] |
Open file tracking. | |
static uint32_t | directories [MAX_DIRECTORY_DEPTH] |
Directory pointer stack. | |
static uint32_t | directory_top = 0 |
Depth into directory pointer stack. | |
static directory_entry_t * | next_entry = 0 |
Pointer to next directory entry set when doing a directory walk. | |
static filesystem_t | dragon_fs |
Structure used for hooking DragonFS into newlib. |
DragonFS.