Restructured the major interfaces of the filesystem
This commit is contained in:
+14
-13
@@ -8,14 +8,15 @@
|
||||
#define LFS_EMUBD_H
|
||||
|
||||
#include "lfs_config.h"
|
||||
#include "lfs_util.h"
|
||||
#include "lfs_bd.h"
|
||||
|
||||
|
||||
// Stats for debugging and optimization
|
||||
struct lfs_bd_stats {
|
||||
lfs_lword_t read_count;
|
||||
lfs_lword_t write_count;
|
||||
lfs_lword_t erase_count;
|
||||
uint64_t read_count;
|
||||
uint64_t prog_count;
|
||||
uint64_t erase_count;
|
||||
};
|
||||
|
||||
// The emu bd state
|
||||
@@ -28,40 +29,40 @@ typedef struct lfs_emubd {
|
||||
|
||||
|
||||
// Create a block device using path for the directory to store blocks
|
||||
lfs_error_t lfs_emubd_create(lfs_emubd_t *emu, const char *path);
|
||||
int lfs_emubd_create(lfs_emubd_t *emu, const char *path);
|
||||
|
||||
// Clean up memory associated with emu block device
|
||||
void lfs_emubd_destroy(lfs_emubd_t *emu);
|
||||
|
||||
// Read a block
|
||||
lfs_error_t lfs_emubd_read(lfs_emubd_t *bd, uint8_t *buffer,
|
||||
lfs_ino_t ino, lfs_off_t off, lfs_size_t size);
|
||||
int lfs_emubd_read(lfs_emubd_t *bd, lfs_block_t block,
|
||||
lfs_off_t off, lfs_size_t size, void *buffer);
|
||||
|
||||
// Program a block
|
||||
//
|
||||
// The block must have previously been erased.
|
||||
lfs_error_t lfs_emubd_write(lfs_emubd_t *bd, const uint8_t *buffer,
|
||||
lfs_ino_t ino, lfs_off_t off, lfs_size_t size);
|
||||
int lfs_emubd_prog(lfs_emubd_t *bd, lfs_block_t block,
|
||||
lfs_off_t off, lfs_size_t size, const void *buffer);
|
||||
|
||||
// Erase a block
|
||||
//
|
||||
// A block must be erased before being programmed. The
|
||||
// state of an erased block is undefined.
|
||||
lfs_error_t lfs_emubd_erase(lfs_emubd_t *bd,
|
||||
lfs_ino_t ino, lfs_off_t off, lfs_size_t size);
|
||||
int lfs_emubd_erase(lfs_emubd_t *bd, lfs_block_t block,
|
||||
lfs_off_t off, lfs_size_t size);
|
||||
|
||||
// Sync the block device
|
||||
lfs_error_t lfs_emubd_sync(lfs_emubd_t *bd);
|
||||
int lfs_emubd_sync(lfs_emubd_t *bd);
|
||||
|
||||
// Get a description of the block device
|
||||
//
|
||||
// Any unknown information may be left unmodified
|
||||
lfs_error_t lfs_emubd_info(lfs_emubd_t *bd, struct lfs_bd_info *info);
|
||||
int lfs_emubd_info(lfs_emubd_t *bd, struct lfs_bd_info *info);
|
||||
|
||||
// Get stats of operations on the block device
|
||||
//
|
||||
// Used for debugging and optimizations
|
||||
lfs_error_t lfs_emubd_stats(lfs_emubd_t *bd, struct lfs_bd_stats *stats);
|
||||
int lfs_emubd_stats(lfs_emubd_t *bd, struct lfs_bd_stats *stats);
|
||||
|
||||
// Block device operations
|
||||
extern const struct lfs_bd_ops lfs_emubd_ops;
|
||||
|
||||
Reference in New Issue
Block a user