BattFS: a filesystem for embedded platforms (implementation).
|
Functions |
| void | battfs_to_disk (struct BattFsPageHeader *hdr, uint8_t *buf) |
| | Convert from memory representation to disk structure.
|
| void | disk_to_battfs (uint8_t *buf, struct BattFsPageHeader *hdr) |
| | Convert from disk structure to memory representation.
|
|
static fcs_t | computeFcs (struct BattFsPageHeader *hdr) |
| | Compute the fcs of the header.
|
|
static fcs_t | computeFcsFree (struct BattFsPageHeader *hdr) |
| | Compute the fcs of the header marked as free.
|
| static bool | battfs_readHeader (struct BattFsSuper *disk, pgcnt_t page, struct BattFsPageHeader *hdr) |
| | Read header of page page.
|
| static bool | battfs_writeHeader (struct BattFsSuper *disk, pgcnt_t page, struct BattFsPageHeader *hdr) |
| | Write header of page page.
|
|
static pgcnt_t | countPages (pgoff_t *filelen_table, inode_t inode) |
| | Count the number of pages from inode 0 to inode in filelen_table.
|
| static void | movePages (struct BattFsSuper *disk, pgcnt_t src, int offset) |
| | Move all pages in page allocation array from src to src + offset.
|
|
static void | insertFreePage (struct BattFsSuper *disk, mark_t mark, pgcnt_t page) |
| | Insert page into page allocation array of disk, using mark to compute position.
|
| static bool | battfs_markFree (struct BattFsSuper *disk, struct BattFsPageHeader *hdr, pgcnt_t page) |
| | Mark page of disk as free.
|
| static void | findFreeStartNext (struct BattFsSuper *disk, mark_t minl, mark_t maxl, mark_t minh, mark_t maxh) |
| | Determine free_start and free_next blocks for disk using minl, maxl, minh, maxh.
|
| static bool | countDiskFilePages (struct BattFsSuper *disk, pgoff_t *filelen_table) |
| | Count number of pages per file on disk.
|
| static bool | fillPageArray (struct BattFsSuper *disk, pgoff_t *filelen_table) |
| | Fill page allocation array of disk using file lenghts in filelen_table.
|
| bool | battfs_init (struct BattFsSuper *disk) |
| | Initialize and mount disk described by disk.
|
| static int | battfs_flush (struct KFile *fd) |
| | Flush file fd.
|
| static int | battfs_fileclose (struct KFile *fd) |
| | Close file fd.
|
| static size_t | battfs_read (struct KFile *fd, void *_buf, size_t size) |
| | Read from file fd size bytes in buf.
|
| static pgcnt_t * | findFile (BattFsSuper *disk, inode_t inode) |
| | Search file inode in disk using a binary search.
|
| bool | battfs_fileExists (BattFsSuper *disk, inode_t inode) |
| static bool | countFileSize (BattFsSuper *disk, pgcnt_t *start, inode_t inode, file_size_t *size) |
| | Count size of file inode on disk, starting at pointer start in disk->page_array.
|
| bool | battfs_fileopen (BattFsSuper *disk, KFileBattFs *fd, inode_t inode, filemode_t mode) |
| | Open file inode from disk in mode.
|
|
bool | battfs_close (struct BattFsSuper *disk) |
| | Close disk.
|
BattFS: a filesystem for embedded platforms (implementation).
Fill page allocation array of disk using file lenghts in filelen_table.
The page allocation array is an array containings all file infos. Is ordered by file, and within each file is ordered by page offset inside file. e.g. : at page array[0] you will find page address of the first page of the first file (if present). Free blocks are allocated after the last file, starting from invalid ones and continuing with the marked free ones.
- Returns:
- true if ok, false on disk read errors.
- Note:
- The whole disk is scanned once.
Definition at line 441 of file battfs.c.
Determine free_start and free_next blocks for disk using minl, maxl, minh, maxh.
Mark_t is a type that has at least 1 bit more than pgaddr_t. So all free blocks can be numbered using at most half numbers of a mark_t type. The free blocks algorithm increments by 1 the disk->free_next every time a page becomes free. So the free block sequence is guaranteed to be countiguous. Only wrap arounds may happen, but due to half size sequence limitation, there are only 4 possible situations:
* |------lower half------|-------upper half-------|
*
* 1) |------minl*****maxl---|------------------------|
* 2) |------minl********maxl|minh******maxh----------|
* 3) |----------------------|----minh*******maxh-----|
* 4) |minl******maxl--------|------------minh****maxh|
*
Situations 1 and 3 are easy to detect, while 2 and 4 require more care.
Definition at line 292 of file battfs.c.