|
ICARUS OS (Intelligent Cooperative Architecture for Real-time Unified Systems) 0.1.0
Preemptive Real-Time Operating System for ARM Cortex-M7
|
ICARUS OS — Internal RAM-backed flat-file filesystem. More...
#include <stdint.h>#include <stdbool.h>Go to the source code of this file.
Data Structures | |
| struct | fs_file_t |
| Opaque file handle — callers hold one of these per open file. More... | |
| struct | fs_file_info_t |
| Per-file metadata returned by fs_list(). More... | |
| struct | fs_stats_t |
| Aggregate filesystem statistics. More... | |
Macros | |
| #define | FS_MAX_FILES 16 |
| #define | FS_MAX_NAME_LEN 12 /* null-terminated, so 11 usable chars */ |
| #define | FS_MAX_FILE_SIZE 2048 /* bytes per file */ |
| #define | FS_TOTAL_BYTES (FS_MAX_FILES * FS_MAX_FILE_SIZE) /* 32 KB */ |
Functions | |
| void | fs_init (void) |
| Clear all file table entries and zero the data store. | |
| bool | fs_create (const char *name, fs_file_t *out) |
| Create a new file with the given name. | |
| bool | fs_open (const char *name, fs_file_t *out) |
| Open an existing file by name. | |
| bool | fs_write (fs_file_t *f, const uint8_t *data, uint16_t len) |
| Append data to an open file. | |
| uint16_t | fs_read (fs_file_t *f, uint8_t *buf, uint16_t len, uint16_t offset) |
| Read bytes from an open file at a given offset. | |
| bool | fs_delete (const char *name) |
| Delete a file by name. | |
| uint8_t | fs_list (fs_file_info_t *out, uint8_t max) |
| Enumerate all files currently in the filesystem. | |
| void | fs_stats (fs_stats_t *out) |
| Return aggregate filesystem statistics. | |
| void | __fs_init (void) |
| Privileged implementation of fs_init(). | |
| bool | __fs_create (const char *name, fs_file_t *out) |
| Privileged implementation of fs_create(). | |
| bool | __fs_open (const char *name, fs_file_t *out) |
| Privileged implementation of fs_open(). | |
| bool | __fs_write (fs_file_t *f, const uint8_t *data, uint16_t len) |
| Privileged implementation of fs_write(). | |
| uint16_t | __fs_read (fs_file_t *f, uint8_t *buf, uint16_t len, uint16_t offset) |
| Privileged implementation of fs_read(). | |
| bool | __fs_delete (const char *name) |
| Privileged implementation of fs_delete(). | |
| uint8_t | __fs_list (fs_file_info_t *out, uint8_t max) |
| Privileged implementation of fs_list(). | |
| void | __fs_stats (fs_stats_t *out) |
| Privileged implementation of fs_stats(). | |
ICARUS OS — Internal RAM-backed flat-file filesystem.
A minimal flat-file storage layer backed by a static RAM array divided into FS_MAX_FILES fixed-size blocks. Suitable as a drop-in target for code that wants a tiny POSIX-ish file API before a real flash filesystem is wired up. The on-disk format is opaque; a real flash backend can be substituted later without changing the public API.
Definition in file fs.h.
| #define FS_MAX_NAME_LEN 12 /* null-terminated, so 11 usable chars */ |
| #define FS_TOTAL_BYTES (FS_MAX_FILES * FS_MAX_FILE_SIZE) /* 32 KB */ |
| bool __fs_create | ( | const char * | name, |
| fs_file_t * | out | ||
| ) |
Privileged implementation of fs_create().
| [in] | name | Null-terminated file name. |
| [out] | out | File handle written on success. |
| true | File created. |
| false | Full, duplicate, or invalid name. |
Definition at line 88 of file fs.c.
References fs_data, fs_find(), fs_free_slot(), FS_MAX_FILE_SIZE, FS_MAX_NAME_LEN, fs_table, fs_entry_t::name, fs_entry_t::size, fs_file_t::slot, fs_entry_t::used, and fs_file_t::valid.
Referenced by fs_create(), and SVC_Handler_C().
| bool __fs_delete | ( | const char * | name | ) |
Privileged implementation of fs_delete().
| [in] | name | File name to remove. |
| true | File found and deleted. |
| false | File does not exist. |
Definition at line 205 of file fs.c.
References fs_data, fs_find(), FS_MAX_FILE_SIZE, and fs_table.
Referenced by fs_delete(), and SVC_Handler_C().
| void __fs_init | ( | void | ) |
| uint8_t __fs_list | ( | fs_file_info_t * | out, |
| uint8_t | max | ||
| ) |
Privileged implementation of fs_list().
| [out] | out | Array of file info entries. |
| [in] | max | Maximum entries to write. |
Definition at line 227 of file fs.c.
References FS_MAX_FILES, FS_MAX_NAME_LEN, fs_table, fs_file_info_t::name, fs_file_info_t::size, and fs_entry_t::size.
Referenced by fs_list(), and SVC_Handler_C().
| bool __fs_open | ( | const char * | name, |
| fs_file_t * | out | ||
| ) |
Privileged implementation of fs_open().
| [in] | name | File name to look up. |
| [out] | out | File handle written on success. |
| true | File found and handle populated. |
| false | File does not exist. |
Definition at line 124 of file fs.c.
References fs_find(), fs_file_t::slot, and fs_file_t::valid.
Referenced by fs_open(), and SVC_Handler_C().
| uint16_t __fs_read | ( | fs_file_t * | f, |
| uint8_t * | buf, | ||
| uint16_t | len, | ||
| uint16_t | offset | ||
| ) |
Privileged implementation of fs_read().
| [in] | f | File handle. |
| [out] | buf | Destination buffer. |
| [in] | len | Maximum bytes to read. |
| [in] | offset | Byte offset into the file. |
len near EOF), or 0 on error. Definition at line 175 of file fs.c.
References fs_data, FS_MAX_FILES, fs_table, fs_entry_t::size, fs_file_t::slot, and fs_file_t::valid.
Referenced by fs_read(), and SVC_Handler_C().
| void __fs_stats | ( | fs_stats_t * | out | ) |
Privileged implementation of fs_stats().
| [out] | out | Aggregate filesystem statistics. |
Definition at line 249 of file fs.c.
References fs_stats_t::file_count, fs_stats_t::free_bytes, FS_MAX_FILE_SIZE, FS_MAX_FILES, fs_table, fs_entry_t::size, fs_stats_t::total_bytes, and fs_stats_t::used_bytes.
Referenced by fs_stats(), and SVC_Handler_C().
| bool __fs_write | ( | fs_file_t * | f, |
| const uint8_t * | data, | ||
| uint16_t | len | ||
| ) |
Privileged implementation of fs_write().
| [in] | f | File handle. |
| [in] | data | Bytes to append. |
| [in] | len | Number of bytes. |
| true | Data appended. |
| false | Invalid handle, null data, or would exceed max size. |
Definition at line 146 of file fs.c.
References fs_data, FS_MAX_FILE_SIZE, FS_MAX_FILES, fs_table, fs_entry_t::size, fs_file_t::slot, and fs_file_t::valid.
Referenced by fs_write(), and SVC_Handler_C().
| bool fs_create | ( | const char * | name, |
| fs_file_t * | out | ||
| ) |
Create a new file with the given name.
Create a new file with the given name.
| [in] | name | Null-terminated file name. |
| [out] | out | File handle written on success. |
| true | File created. |
| false | Full, duplicate, or invalid name. |
Definition at line 292 of file fs.c.
References __fs_create(), and SVC_FS_CREATE.
| bool fs_delete | ( | const char * | name | ) |
Delete a file by name.
Delete a file by name.
| [in] | name | File name to remove. |
| true | File deleted. |
| false | File does not exist. |
Definition at line 401 of file fs.c.
References __fs_delete(), and SVC_FS_DELETE.
| void fs_init | ( | void | ) |
Clear all file table entries and zero the data store.
Clear all file table entries and zero the data store.
Definition at line 277 of file fs.c.
References __fs_init(), and SVC_FS_INIT.
| uint8_t fs_list | ( | fs_file_info_t * | out, |
| uint8_t | max | ||
| ) |
Enumerate all files currently in the filesystem.
out.Enumerate all files currently in the filesystem.
| [out] | out | Array of file info entries. |
| [in] | max | Maximum entries to write. |
Definition at line 424 of file fs.c.
References __fs_list(), and SVC_FS_LIST.
| bool fs_open | ( | const char * | name, |
| fs_file_t * | out | ||
| ) |
Open an existing file by name.
Open an existing file by name.
| [in] | name | File name to look up. |
| [out] | out | File handle written on success. |
| true | File found. |
| false | File does not exist. |
Definition at line 318 of file fs.c.
References __fs_open(), and SVC_FS_OPEN.
| uint16_t fs_read | ( | fs_file_t * | f, |
| uint8_t * | buf, | ||
| uint16_t | len, | ||
| uint16_t | offset | ||
| ) |
Read bytes from an open file at a given offset.
Read bytes from an open file at a given offset.
| [in] | f | File handle. |
| [out] | buf | Destination buffer. |
| [in] | len | Maximum bytes to read. |
| [in] | offset | Byte offset into the file. |
Definition at line 373 of file fs.c.
References __fs_read(), and SVC_FS_READ.
| void fs_stats | ( | fs_stats_t * | out | ) |
Return aggregate filesystem statistics.
Return aggregate filesystem statistics.
| [out] | out | Statistics structure to fill. |
Definition at line 447 of file fs.c.
References __fs_stats(), and SVC_FS_STATS.
| bool fs_write | ( | fs_file_t * | f, |
| const uint8_t * | data, | ||
| uint16_t | len | ||
| ) |
Append data to an open file.
Append data to an open file.
| [in] | f | File handle. |
| [in] | data | Bytes to append. |
| [in] | len | Number of bytes. |
| true | Data appended. |
| false | Invalid handle, null data, or would exceed max size. |
Definition at line 345 of file fs.c.
References __fs_write(), and SVC_FS_WRITE.