libdragon
Loading...
Searching...
No Matches
system.h
Go to the documentation of this file.
1
8#ifndef __LIBDRAGON_SYSTEM_H
9#define __LIBDRAGON_SYSTEM_H
10
44#define MAX_FILESYSTEMS 10
46#define MAX_OPEN_HANDLES 4096
47
48#ifdef __cplusplus
49extern "C" {
50#endif
51
52#include <dir.h>
53#include <sys/stat.h>
54
65typedef struct
66{
79 void *(*open)( char *name, int flags );
90 int (*fstat)( void *file, struct stat *st );
102 int (*stat)( char *name, struct stat *st );
116 int (*lseek)( void *file, int ptr, int dir );
130 int (*read)( void *file, uint8_t *ptr, int len );
143 int (*write)( void *file, uint8_t *ptr, int len );
152 int (*close)( void *file );
162 int (*unlink)( char *name );
176 int (*findfirst)( char *path, dir_t *dir );
177
179 #ifndef SYSTEM_NO_DEPRECATED
180 __attribute__((deprecated("Use findnext2 instead")))
181 #endif
182 int (*findnext)( dir_t *dir );
184
198 int (*findnext2)( const char *path, dir_t *dir );
207 int (*ftruncate)( void *file, int length );
218 int (*mkdir)( char *path, mode_t mode );
231 int (*ioctl)(void *file, unsigned long cmd, void *argp);
233
241typedef struct
242{
253 int (*stdin_read)( char *data, unsigned int len );
264 int (*stdout_write)( char *data, unsigned int len );
275 int (*stderr_write)( char *data, unsigned int len );
276} stdio_t;
277
302int attach_filesystem( const char * const prefix, filesystem_t *filesystem );
303
317int detach_filesystem( const char * const prefix );
318
319
328int hook_stdio_calls( stdio_t *stdio_calls );
329
338int unhook_stdio_calls( stdio_t *stdio_calls );
339
340
349int hook_time_call( time_t (*time_fn)( void ) );
350
359int unhook_time_call( time_t (*time_fn)( void ) );
360
361#ifdef __cplusplus
362}
363#endif
364
367#endif
Directory handling.
int hook_time_call(time_t(*time_fn)(void))
Hook into gettimeofday with a current time callback.
Definition system.c:1428
int hook_stdio_calls(stdio_t *stdio_calls)
Hook into stdio for STDIN, STDOUT and STDERR callbacks.
Definition system.c:1394
int unhook_stdio_calls(stdio_t *stdio_calls)
Unhook from stdio.
Definition system.c:1414
int unhook_time_call(time_t(*time_fn)(void))
Unhook from gettimeofday current time callback.
Definition system.c:1440
int detach_filesystem(const char *const prefix)
Unregister a filesystem from newlib.
Definition system.c:366
int attach_filesystem(const char *const prefix, filesystem_t *filesystem)
Register a filesystem with newlib.
Definition system.c:305
Directory entry structure.
Definition dir.h:37
Filesystem hook structure.
Definition system.h:66
Standard I/O hook structure.
Definition system.h:242
int read(int fileno, char *ptr, int len)
Read data from a file.
Definition system.c:943
int lseek(int file, int ptr, int dir)
Seek to a location in a file.
Definition system.c:841
int ioctl(int fd, unsigned long cmd, void *argp)
Perform IO Control Request.
Definition system.c:1174
int mkdir(const char *path, mode_t mode)
Create a directory.
Definition system.c:1373
int fstat(int fileno, struct stat *st)
Return stats on an open file handle.
Definition system.c:689
int stat(const char *file, struct stat *st)
Return file stats based on a file name.
Definition system.c:1063
int close(int fildes)
Close a file.
Definition system.c:593
int ftruncate(int file, off_t length)
Truncate a file to the specified length.
Definition system.c:1271
int unlink(char *name)
Remove a file based on filename.
Definition system.c:1135
int write(int file, char *ptr, int len)
Write data to a file.
Definition system.c:1204