libdragon
Data Fields
filesystem_t Struct Reference

Filesystem hook structure. More...

#include <system.h>

Data Fields

void *(* open )(char *name, int flags)
 Function to call when performing an open command. More...
 
int(* fstat )(void *file, struct stat *st)
 Function to call when performing a fstat command. More...
 
int(* lseek )(void *file, int ptr, int dir)
 Function to call when performing an lseek command. More...
 
int(* read )(void *file, uint8_t *ptr, int len)
 Function to call when performing a read operation. More...
 
int(* write )(void *file, uint8_t *ptr, int len)
 Function to call when performing a write operation. More...
 
int(* close )(void *file)
 Function to call when performing a close operation. More...
 
int(* unlink )(char *name)
 Function to call when performing an unlink operation. More...
 
int(* findfirst )(char *path, dir_t *dir)
 Function to call when performing a findfirst operation. More...
 
int(* findnext )(dir_t *dir)
 Function to call when performing a findnext operation. More...
 

Detailed Description

Filesystem hook structure.

Filesystems that do not support one of more of the following methods should provide null pointers instead of empty functions. The newlib hooks will set errno to ENOSYS and return a proper error to userspace.

Field Documentation

◆ open

void *(* filesystem_t::open) (char *name, int flags)

Function to call when performing an open command.

Parameters
[in]nameFull path of the file to be opened, relative to the root of the filesystem.
[in]flagsOpen flags, such as binary, append, etc. Follows POSIX flags.
Returns
A pointer to an arbitrary file handle assigned by the filesystem code or NULL on error.

◆ fstat

int(* filesystem_t::fstat) (void *file, struct stat *st)

Function to call when performing a fstat command.

Parameters
[in]fileArbitrary file handle returned by filesystem_t::open
[out]stStat structure to populate with file statistics
Returns
0 on success or a negative value on error.

◆ lseek

int(* filesystem_t::lseek) (void *file, int ptr, int dir)

Function to call when performing an lseek command.

Parameters
[in]fileArbitrary file handle returned by filesystem_t::open
[in]ptrAn offset from dir to seek.
[in]dirA direction to see, either SEEK_SET, SEEK_CUR or SEEK_END
Returns
The absolute offset in bytes after the seek.

◆ read

int(* filesystem_t::read) (void *file, uint8_t *ptr, int len)

Function to call when performing a read operation.

Parameters
[in]fileArbitrary file handle returned by filesystem_t::open
[out]ptrBuffer to place data read into
[in]lenLength of data that should be read into ptr
Returns
The actual number of bytes read into ptr or a negative value on failure.

◆ write

int(* filesystem_t::write) (void *file, uint8_t *ptr, int len)

Function to call when performing a write operation.

Parameters
[in]fileArbitrary file handle returned by filesystem_t::open
[out]ptrBuffer to grab the data to be written
[in]lenLength of data that should be written out of ptr
Returns
The actual number of bytes written or a negative value on failure.

◆ close

int(* filesystem_t::close) (void *file)

Function to call when performing a close operation.

Parameters
[in]fileArbitrary file handle returned by filesystem_t::open
Returns
0 on success or a negative value on failure.

◆ unlink

int(* filesystem_t::unlink) (char *name)

Function to call when performing an unlink operation.

Parameters
[in]nameFull path of the file to be opened, relative to the root of the filesystem.
Returns
0 on success or a negative value on failure.

◆ findfirst

int(* filesystem_t::findfirst) (char *path, dir_t *dir)

Function to call when performing a findfirst operation.

Parameters
[in]pathFull path of the directory to list files from, relative to the root of the filesystem.
[out]dirDirectory structure to place information on the first file in the directory.
Returns
0 on successful lookup or a negative value on failure or empty directory.

◆ findnext

int(* filesystem_t::findnext) (dir_t *dir)

Function to call when performing a findnext operation.

Parameters
[out]dirDirectory structure to place information on the next file in the directory.
Returns
0 on successful lookup or a negative value on failure or empty directory.

The documentation for this struct was generated from the following file: