update lfs.c
This commit is contained in:
@@ -41,7 +41,7 @@ static inline void lfs_cache_zero(lfs_t *lfs, lfs_cache_t *pcache) {
|
||||
pcache->block = LFS_BLOCK_NULL;
|
||||
}
|
||||
|
||||
|
||||
#pragma stackfunction 100
|
||||
static int lfs_bd_read(lfs_t *lfs,
|
||||
const lfs_cache_t *pcache, lfs_cache_t *rcache, lfs_size_t hint,
|
||||
lfs_block_t block, lfs_off_t off,
|
||||
@@ -125,7 +125,7 @@ static int lfs_bd_read(lfs_t *lfs,
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#pragma stackfunction 100
|
||||
static int lfs_bd_cmp(lfs_t *lfs,
|
||||
const lfs_cache_t *pcache, lfs_cache_t *rcache, lfs_size_t hint,
|
||||
lfs_block_t block, lfs_off_t off,
|
||||
@@ -153,7 +153,7 @@ static int lfs_bd_cmp(lfs_t *lfs,
|
||||
return LFS_CMP_EQ;
|
||||
}
|
||||
|
||||
|
||||
#pragma stackfunction 100
|
||||
static int lfs_bd_crc(lfs_t *lfs,
|
||||
const lfs_cache_t *pcache, lfs_cache_t *rcache, lfs_size_t hint,
|
||||
lfs_block_t block, lfs_off_t off, lfs_size_t size, uint32_t *crc) {
|
||||
@@ -176,7 +176,7 @@ static int lfs_bd_crc(lfs_t *lfs,
|
||||
}
|
||||
|
||||
#ifndef LFS_READONLY
|
||||
|
||||
#pragma stackfunction 100
|
||||
static int lfs_bd_flush(lfs_t *lfs,
|
||||
lfs_cache_t *pcache, lfs_cache_t *rcache, bool validate) {
|
||||
if (pcache->block != LFS_BLOCK_NULL && pcache->block != LFS_BLOCK_INLINE) {
|
||||
@@ -212,7 +212,7 @@ static int lfs_bd_flush(lfs_t *lfs,
|
||||
#endif
|
||||
|
||||
#ifndef LFS_READONLY
|
||||
|
||||
#pragma stackfunction 100
|
||||
static int lfs_bd_sync(lfs_t *lfs,
|
||||
lfs_cache_t *pcache, lfs_cache_t *rcache, bool validate) {
|
||||
lfs_cache_drop(lfs, rcache);
|
||||
@@ -229,7 +229,7 @@ static int lfs_bd_sync(lfs_t *lfs,
|
||||
#endif
|
||||
|
||||
#ifndef LFS_READONLY
|
||||
|
||||
#pragma stackfunction 100
|
||||
static int lfs_bd_prog(lfs_t *lfs,
|
||||
lfs_cache_t *pcache, lfs_cache_t *rcache, bool validate,
|
||||
lfs_block_t block, lfs_off_t off,
|
||||
@@ -278,7 +278,7 @@ static int lfs_bd_prog(lfs_t *lfs,
|
||||
#endif
|
||||
|
||||
#ifndef LFS_READONLY
|
||||
|
||||
#pragma stackfunction 100
|
||||
static int lfs_bd_erase(lfs_t *lfs, lfs_block_t block) {
|
||||
LFS_ASSERT(block < lfs->block_count);
|
||||
int err = lfs->cfg->erase(lfs->cfg, block);
|
||||
@@ -608,7 +608,7 @@ static lfs_soff_t lfs_file_size_(lfs_t *lfs, lfs_file_t *file);
|
||||
|
||||
static lfs_ssize_t lfs_fs_size_(lfs_t *lfs);
|
||||
static int lfs_fs_traverse_(lfs_t *lfs,
|
||||
int (* __attribute__((fptrgroup("lfs_cb_block_fptr_grp"))) cb)(void *data, lfs_block_t block), void *data,
|
||||
int (*cb)(void *data, lfs_block_t block), void *data,
|
||||
bool includeorphans);
|
||||
|
||||
static int lfs_deinit(lfs_t *lfs);
|
||||
@@ -861,7 +861,7 @@ static int lfs_dir_getread(lfs_t *lfs, const lfs_mdir_t *dir,
|
||||
}
|
||||
|
||||
#ifndef LFS_READONLY
|
||||
|
||||
#pragma stackfunction 100
|
||||
static int lfs_dir_traverse_filter(void *p,
|
||||
lfs_tag_t tag, const void *buffer) {
|
||||
lfs_tag_t *filtertag = p;
|
||||
@@ -922,7 +922,7 @@ struct lfs_dir_traverse {
|
||||
struct lfs_diskoff disk;
|
||||
};
|
||||
|
||||
|
||||
#pragma stackfunction 200
|
||||
static int lfs_dir_traverse(lfs_t *lfs,
|
||||
const lfs_mdir_t *dir, lfs_off_t off, lfs_tag_t ptag,
|
||||
const struct lfs_mattr *attrs, int attrcount,
|
||||
@@ -1118,7 +1118,7 @@ popped:
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#pragma stackfunction 100
|
||||
static lfs_stag_t lfs_dir_fetchmatch(lfs_t *lfs,
|
||||
lfs_mdir_t *dir, const lfs_block_t pair[2],
|
||||
lfs_tag_t fmask, lfs_tag_t ftag, uint16_t *id,
|
||||
@@ -1954,7 +1954,7 @@ static int lfs_dir_commit_commit(void *p, lfs_tag_t tag, const void *buffer) {
|
||||
#endif
|
||||
|
||||
#ifndef LFS_READONLY
|
||||
|
||||
#pragma stackfunction 100
|
||||
static bool lfs_dir_needsrelocation(lfs_t *lfs, lfs_mdir_t *dir) {
|
||||
// If our revision count == n * block_cycles, we should force a relocation,
|
||||
// this is how littlefs wear-levels at the metadata-pair level. Note that we
|
||||
@@ -1968,7 +1968,7 @@ static bool lfs_dir_needsrelocation(lfs_t *lfs, lfs_mdir_t *dir) {
|
||||
#endif
|
||||
|
||||
#ifndef LFS_READONLY
|
||||
|
||||
#pragma stackfunction 100
|
||||
static int lfs_dir_compact(lfs_t *lfs,
|
||||
lfs_mdir_t *dir, const struct lfs_mattr *attrs, int attrcount,
|
||||
lfs_mdir_t *source, uint16_t begin, uint16_t end) {
|
||||
@@ -2142,7 +2142,7 @@ relocate:
|
||||
#endif
|
||||
|
||||
#ifndef LFS_READONLY
|
||||
|
||||
#pragma stackfunction 100
|
||||
static int lfs_dir_splittingcompact(lfs_t *lfs, lfs_mdir_t *dir,
|
||||
const struct lfs_mattr *attrs, int attrcount,
|
||||
lfs_mdir_t *source, uint16_t begin, uint16_t end) {
|
||||
@@ -2252,7 +2252,7 @@ static int lfs_dir_splittingcompact(lfs_t *lfs, lfs_mdir_t *dir,
|
||||
#endif
|
||||
|
||||
#ifndef LFS_READONLY
|
||||
|
||||
#pragma stackfunction 100
|
||||
static int lfs_dir_relocatingcommit(lfs_t *lfs, lfs_mdir_t *dir,
|
||||
const lfs_block_t pair[2],
|
||||
const struct lfs_mattr *attrs, int attrcount,
|
||||
@@ -2426,7 +2426,7 @@ fixmlist:;
|
||||
#endif
|
||||
|
||||
#ifndef LFS_READONLY
|
||||
|
||||
#pragma stackfunction 100
|
||||
static int lfs_dir_orphaningcommit(lfs_t *lfs, lfs_mdir_t *dir,
|
||||
const struct lfs_mattr *attrs, int attrcount) {
|
||||
// check for any inline files that aren't RAM backed and
|
||||
@@ -2620,7 +2620,7 @@ static int lfs_dir_orphaningcommit(lfs_t *lfs, lfs_mdir_t *dir,
|
||||
#endif
|
||||
|
||||
#ifndef LFS_READONLY
|
||||
|
||||
#pragma stackfunction 100
|
||||
static int lfs_dir_commit(lfs_t *lfs, lfs_mdir_t *dir,
|
||||
const struct lfs_mattr *attrs, int attrcount) {
|
||||
int orphans = lfs_dir_orphaningcommit(lfs, dir, attrs, attrcount);
|
||||
@@ -2645,7 +2645,7 @@ static int lfs_dir_commit(lfs_t *lfs, lfs_mdir_t *dir,
|
||||
|
||||
/// Top level directory operations ///
|
||||
#ifndef LFS_READONLY
|
||||
|
||||
#pragma stackfunction 100
|
||||
static int lfs_mkdir_(lfs_t *lfs, const char *path) {
|
||||
// deorphan if we haven't yet, needed at most once after poweron
|
||||
int err = lfs_fs_forceconsistency(lfs);
|
||||
@@ -2741,7 +2741,7 @@ static int lfs_mkdir_(lfs_t *lfs, const char *path) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#pragma stackfunction 100
|
||||
static int lfs_dir_open_(lfs_t *lfs, lfs_dir_t *dir, const char *path) {
|
||||
lfs_stag_t tag = lfs_dir_find(lfs, &dir->m, &path, NULL);
|
||||
if (tag < 0) {
|
||||
@@ -2786,7 +2786,7 @@ static int lfs_dir_open_(lfs_t *lfs, lfs_dir_t *dir, const char *path) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#pragma stackfunction 100
|
||||
static int lfs_dir_close_(lfs_t *lfs, lfs_dir_t *dir) {
|
||||
// remove from list of mdirs
|
||||
lfs_mlist_remove(lfs, (struct lfs_mlist *)dir);
|
||||
@@ -2794,7 +2794,7 @@ static int lfs_dir_close_(lfs_t *lfs, lfs_dir_t *dir) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#pragma stackfunction 100
|
||||
static int lfs_dir_read_(lfs_t *lfs, lfs_dir_t *dir, struct lfs_info *info) {
|
||||
memset(info, 0, sizeof(*info));
|
||||
|
||||
@@ -2840,7 +2840,7 @@ static int lfs_dir_read_(lfs_t *lfs, lfs_dir_t *dir, struct lfs_info *info) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#pragma stackfunction 100
|
||||
static int lfs_dir_seek_(lfs_t *lfs, lfs_dir_t *dir, lfs_off_t off) {
|
||||
// simply walk from head dir
|
||||
int err = lfs_dir_rewind_(lfs, dir);
|
||||
@@ -3290,7 +3290,7 @@ static int lfs_file_close_(lfs_t *lfs, lfs_file_t *file) {
|
||||
|
||||
|
||||
#ifndef LFS_READONLY
|
||||
|
||||
#pragma stackfunction 100
|
||||
static int lfs_file_relocate(lfs_t *lfs, lfs_file_t *file) {
|
||||
while (true) {
|
||||
// just relocate what exists into new block
|
||||
@@ -3456,7 +3456,7 @@ relocate:
|
||||
}
|
||||
|
||||
#ifndef LFS_READONLY
|
||||
|
||||
#pragma stackfunction 100
|
||||
static int lfs_file_sync_(lfs_t *lfs, lfs_file_t *file) {
|
||||
if (file->flags & LFS_F_ERRED) {
|
||||
// it's not safe to do anything if our file errored
|
||||
@@ -3598,7 +3598,7 @@ static lfs_ssize_t lfs_file_read_(lfs_t *lfs, lfs_file_t *file,
|
||||
|
||||
|
||||
#ifndef LFS_READONLY
|
||||
|
||||
#pragma stackfunction 100
|
||||
static lfs_ssize_t lfs_file_flushedwrite(lfs_t *lfs, lfs_file_t *file,
|
||||
const void *buffer, lfs_size_t size) {
|
||||
const uint8_t *data = buffer;
|
||||
@@ -3683,7 +3683,7 @@ relocate:
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
#pragma stackfunction 100
|
||||
static lfs_ssize_t lfs_file_write_(lfs_t *lfs, lfs_file_t *file,
|
||||
const void *buffer, lfs_size_t size) {
|
||||
LFS_ASSERT((file->flags & LFS_O_WRONLY) == LFS_O_WRONLY);
|
||||
@@ -3728,7 +3728,7 @@ static lfs_ssize_t lfs_file_write_(lfs_t *lfs, lfs_file_t *file,
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#pragma stackfunction 100
|
||||
static lfs_soff_t lfs_file_seek_(lfs_t *lfs, lfs_file_t *file,
|
||||
lfs_soff_t off, int whence) {
|
||||
// find new pos
|
||||
@@ -3787,7 +3787,7 @@ static lfs_soff_t lfs_file_seek_(lfs_t *lfs, lfs_file_t *file,
|
||||
}
|
||||
|
||||
#ifndef LFS_READONLY
|
||||
|
||||
#pragma stackfunction 100
|
||||
static int lfs_file_truncate_(lfs_t *lfs, lfs_file_t *file, lfs_off_t size) {
|
||||
LFS_ASSERT((file->flags & LFS_O_WRONLY) == LFS_O_WRONLY);
|
||||
|
||||
@@ -4684,7 +4684,7 @@ static int lfs_unmount_(lfs_t *lfs) {
|
||||
|
||||
|
||||
/// Filesystem filesystem operations ///
|
||||
|
||||
#pragma stackfunction 100
|
||||
static int lfs_fs_stat_(lfs_t *lfs, struct lfs_fsinfo *fsinfo) {
|
||||
// if the superblock is up-to-date, we must be on the most recent
|
||||
// minor version of littlefs
|
||||
@@ -4725,7 +4725,7 @@ static int lfs_fs_stat_(lfs_t *lfs, struct lfs_fsinfo *fsinfo) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#pragma stackfunction 100
|
||||
int lfs_fs_traverse_(lfs_t *lfs,
|
||||
int (* __attribute__((fptrgroup("lfs_cb_block_fptr_grp"))) cb)(void *data, lfs_block_t block), void *data,
|
||||
bool includeorphans) {
|
||||
@@ -6204,7 +6204,7 @@ int lfs_file_close(lfs_t *lfs, lfs_file_t *file) {
|
||||
}
|
||||
|
||||
#ifndef LFS_READONLY
|
||||
|
||||
#pragma stackfunction 100
|
||||
int lfs_file_sync(lfs_t *lfs, lfs_file_t *file) {
|
||||
int err = LFS_LOCK(lfs->cfg);
|
||||
if (err) {
|
||||
|
||||
Reference in New Issue
Block a user