mirror of
https://github.com/eledio-devices/thirdparty-littlefs.git
synced 2025-11-01 16:14:13 +01:00
Compare commits
10 Commits
v2.0.0
...
fix-read-h
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c64bf1a17b | ||
|
|
f35fb8c148 | ||
|
|
0a1f706ca2 | ||
|
|
fdd239fe21 | ||
|
|
780ef2fce4 | ||
|
|
73ea008b74 | ||
|
|
c849748453 | ||
|
|
25a843aab7 | ||
|
|
905727b684 | ||
|
|
26d25608b6 |
@@ -136,10 +136,11 @@ jobs:
|
||||
env:
|
||||
- STAGE=test
|
||||
- NAME=littlefs-migration
|
||||
if: branch !~ -prefix$
|
||||
install:
|
||||
- sudo apt-get install libfuse-dev
|
||||
- git clone --depth 1 https://github.com/geky/littlefs-fuse -b v2-alpha v2
|
||||
- git clone --depth 1 https://github.com/geky/littlefs-fuse v1
|
||||
- git clone --depth 1 https://github.com/geky/littlefs-fuse -b v1 v1
|
||||
- fusermount -V
|
||||
- gcc --version
|
||||
before_script:
|
||||
|
||||
30
lfs.c
30
lfs.c
@@ -29,7 +29,7 @@ static inline void lfs_cache_drop(lfs_t *lfs, lfs_cache_t *rcache) {
|
||||
|
||||
static inline void lfs_cache_zero(lfs_t *lfs, lfs_cache_t *pcache) {
|
||||
// zero to avoid information leak
|
||||
memset(pcache->buffer, 0xff, lfs->cfg->prog_size);
|
||||
memset(pcache->buffer, 0xff, lfs->cfg->cache_size);
|
||||
pcache->block = 0xffffffff;
|
||||
}
|
||||
|
||||
@@ -80,28 +80,16 @@ static int lfs_bd_read(lfs_t *lfs,
|
||||
diff = lfs_min(diff, rcache->off-off);
|
||||
}
|
||||
|
||||
if (size >= hint && off % lfs->cfg->read_size == 0 &&
|
||||
size >= lfs->cfg->read_size) {
|
||||
// bypass cache?
|
||||
diff = lfs_aligndown(diff, lfs->cfg->read_size);
|
||||
int err = lfs->cfg->read(lfs->cfg, block, off, data, diff);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
data += diff;
|
||||
off += diff;
|
||||
size -= diff;
|
||||
continue;
|
||||
}
|
||||
|
||||
// load to cache, first condition can no longer fail
|
||||
LFS_ASSERT(block < lfs->cfg->block_count);
|
||||
rcache->block = block;
|
||||
rcache->off = lfs_aligndown(off, lfs->cfg->read_size);
|
||||
rcache->size = lfs_min(lfs_alignup(off+hint, lfs->cfg->read_size),
|
||||
lfs_min(lfs->cfg->block_size - rcache->off,
|
||||
lfs->cfg->cache_size));
|
||||
rcache->size = lfs_min(
|
||||
lfs_min(
|
||||
lfs_alignup(off+hint, lfs->cfg->read_size),
|
||||
lfs->cfg->block_size)
|
||||
- rcache->off,
|
||||
lfs->cfg->cache_size);
|
||||
int err = lfs->cfg->read(lfs->cfg, rcache->block,
|
||||
rcache->off, rcache->buffer, rcache->size);
|
||||
if (err) {
|
||||
@@ -2864,6 +2852,10 @@ int lfs_file_truncate(lfs_t *lfs, lfs_file_t *file, lfs_off_t size) {
|
||||
return LFS_ERR_BADF;
|
||||
}
|
||||
|
||||
if (size > LFS_FILE_MAX) {
|
||||
return LFS_ERR_INVAL;
|
||||
}
|
||||
|
||||
lfs_off_t oldsize = lfs_file_size(lfs, file);
|
||||
if (size < oldsize) {
|
||||
// need to flush since directly changing metadata
|
||||
|
||||
3
lfs.h
3
lfs.h
@@ -578,7 +578,8 @@ int lfs_dir_close(lfs_t *lfs, lfs_dir_t *dir);
|
||||
// Read an entry in the directory
|
||||
//
|
||||
// Fills out the info structure, based on the specified file or directory.
|
||||
// Returns a negative error code on failure.
|
||||
// Returns a positive value on success, 0 at the end of directory,
|
||||
// or a negative error code on failure.
|
||||
int lfs_dir_read(lfs_t *lfs, lfs_dir_t *dir, struct lfs_info *info);
|
||||
|
||||
// Change the position of the directory
|
||||
|
||||
Reference in New Issue
Block a user