mirror of
https://github.com/eledio-devices/thirdparty-littlefs.git
synced 2025-11-01 16:14:13 +01:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d3a2cf48d4 | ||
|
|
22b0456623 | ||
|
|
ec4d8b68ad | ||
|
|
c7894a61e1 | ||
|
|
195075819e | ||
|
|
97d8d5e96a | ||
|
|
0bb1f7af17 | ||
|
|
447d89cbd8 | ||
|
|
28d2d96a83 |
48
.travis.yml
48
.travis.yml
@@ -140,12 +140,13 @@ jobs:
|
|||||||
- LFS_VERSION_MINOR=$((0xffff & ($LFS_VERSION >> 0)))
|
- LFS_VERSION_MINOR=$((0xffff & ($LFS_VERSION >> 0)))
|
||||||
# Grab latests patch from repo tags, default to 0, needs finagling to get past github's pagination api
|
# Grab latests patch from repo tags, default to 0, needs finagling to get past github's pagination api
|
||||||
- PREV_URL=https://api.github.com/repos/$TRAVIS_REPO_SLUG/git/refs/tags/v$LFS_VERSION_MAJOR.$LFS_VERSION_MINOR.
|
- PREV_URL=https://api.github.com/repos/$TRAVIS_REPO_SLUG/git/refs/tags/v$LFS_VERSION_MAJOR.$LFS_VERSION_MINOR.
|
||||||
- PREV_URL=$(curl -f -u "$GEKY_BOT_RELEASES" "$PREV_URL" -I
|
- PREV_URL=$(curl -u "$GEKY_BOT_RELEASES" "$PREV_URL" -I
|
||||||
| sed -n '/^Link/{s/.*<\(.*\)>; rel="last"/\1/;p;q0};$q1'
|
| sed -n '/^Link/{s/.*<\(.*\)>; rel="last"/\1/;p;q0};$q1'
|
||||||
|| echo $PREV_URL)
|
|| echo $PREV_URL)
|
||||||
- LFS_VERSION_PATCH=$(curl -f -u "$GEKY_BOT_RELEASES" "$PREV_URL"
|
- LFS_VERSION_PATCH=$(curl -u "$GEKY_BOT_RELEASES" "$PREV_URL"
|
||||||
| jq 'map(.ref | match("\\bv.*\\..*\\.(.*)$";"g")
|
| jq 'map(.ref | match("\\bv.*\\..*\\.(.*)$";"g")
|
||||||
.captures[].string | tonumber + 1) | max // 0')
|
.captures[].string | tonumber) | max + 1'
|
||||||
|
|| echo 0)
|
||||||
# We have our new version
|
# We have our new version
|
||||||
- LFS_VERSION="v$LFS_VERSION_MAJOR.$LFS_VERSION_MINOR.$LFS_VERSION_PATCH"
|
- LFS_VERSION="v$LFS_VERSION_MAJOR.$LFS_VERSION_MINOR.$LFS_VERSION_PATCH"
|
||||||
- echo "VERSION $LFS_VERSION"
|
- echo "VERSION $LFS_VERSION"
|
||||||
@@ -156,24 +157,35 @@ jobs:
|
|||||||
| jq -re '.sha')
|
| jq -re '.sha')
|
||||||
if [ "$TRAVIS_COMMIT" == "$CURRENT_COMMIT" ]
|
if [ "$TRAVIS_COMMIT" == "$CURRENT_COMMIT" ]
|
||||||
then
|
then
|
||||||
# Build release notes
|
# Create a simple tag
|
||||||
PREV=$(git tag --sort=-v:refname -l "v*" | head -1)
|
|
||||||
if [ ! -z "$PREV" ]
|
|
||||||
then
|
|
||||||
echo "PREV $PREV"
|
|
||||||
CHANGES=$'### Changes\n\n'$( \
|
|
||||||
git log --oneline $PREV.. --grep='^Merge' --invert-grep)
|
|
||||||
printf "CHANGES\n%s\n\n" "$CHANGES"
|
|
||||||
fi
|
|
||||||
# Create the release
|
|
||||||
curl -f -u "$GEKY_BOT_RELEASES" -X POST \
|
curl -f -u "$GEKY_BOT_RELEASES" -X POST \
|
||||||
https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases \
|
https://api.github.com/repos/$TRAVIS_REPO_SLUG/git/refs \
|
||||||
-d "{
|
-d "{
|
||||||
\"tag_name\": \"$LFS_VERSION\",
|
\"ref\": \"refs/tags/$LFS_VERSION\",
|
||||||
\"target_commitish\": \"$TRAVIS_COMMIT\",
|
\"sha\": \"$TRAVIS_COMMIT\"
|
||||||
\"name\": \"${LFS_VERSION%.0}\",
|
|
||||||
\"body\": $(jq -sR '.' <<< "$CHANGES")
|
|
||||||
}"
|
}"
|
||||||
|
# Minor release?
|
||||||
|
if [[ "$LFS_VERSION" == *.0 ]]
|
||||||
|
then
|
||||||
|
# Build release notes
|
||||||
|
PREV=$(git tag --sort=-v:refname -l "v*.0" | head -1)
|
||||||
|
if [ ! -z "$PREV" ]
|
||||||
|
then
|
||||||
|
echo "PREV $PREV"
|
||||||
|
CHANGES=$'### Changes\n\n'$( \
|
||||||
|
git log --oneline $PREV.. --grep='^Merge' --invert-grep)
|
||||||
|
printf "CHANGES\n%s\n\n" "$CHANGES"
|
||||||
|
fi
|
||||||
|
# Create the release
|
||||||
|
curl -f -u "$GEKY_BOT_RELEASES" -X POST \
|
||||||
|
https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases \
|
||||||
|
-d "{
|
||||||
|
\"tag_name\": \"$LFS_VERSION\",
|
||||||
|
\"name\": \"${LFS_VERSION%.0}\",
|
||||||
|
\"draft\": true,
|
||||||
|
\"body\": $(jq -sR '.' <<< "$CHANGES")
|
||||||
|
}"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Manage statuses
|
# Manage statuses
|
||||||
|
|||||||
2
Makefile
2
Makefile
@@ -26,7 +26,7 @@ override CFLAGS += -m$(WORD)
|
|||||||
endif
|
endif
|
||||||
override CFLAGS += -I.
|
override CFLAGS += -I.
|
||||||
override CFLAGS += -std=c99 -Wall -pedantic
|
override CFLAGS += -std=c99 -Wall -pedantic
|
||||||
override CFLAGS += -Wshadow -Wunused-parameter -Wjump-misses-init
|
override CFLAGS += -Wshadow -Wunused-parameter -Wjump-misses-init -Wsign-compare
|
||||||
|
|
||||||
|
|
||||||
all: $(TARGET)
|
all: $(TARGET)
|
||||||
|
|||||||
21
README.md
21
README.md
@@ -111,9 +111,9 @@ filesystem until sync or close is called on the file.
|
|||||||
|
|
||||||
## Other notes
|
## Other notes
|
||||||
|
|
||||||
All littlefs have the potential to return a negative error code. The errors
|
All littlefs calls have the potential to return a negative error code. The
|
||||||
can be either one of those found in the `enum lfs_error` in [lfs.h](lfs.h),
|
errors can be either one of those found in the `enum lfs_error` in
|
||||||
or an error returned by the user's block device operations.
|
[lfs.h](lfs.h), or an error returned by the user's block device operations.
|
||||||
|
|
||||||
In the configuration struct, the `prog` and `erase` function provided by the
|
In the configuration struct, the `prog` and `erase` function provided by the
|
||||||
user may return a `LFS_ERR_CORRUPT` error if the implementation already can
|
user may return a `LFS_ERR_CORRUPT` error if the implementation already can
|
||||||
@@ -175,3 +175,18 @@ handy.
|
|||||||
[littlefs-js](https://github.com/geky/littlefs-js) - A javascript wrapper for
|
[littlefs-js](https://github.com/geky/littlefs-js) - A javascript wrapper for
|
||||||
littlefs. I'm not sure why you would want this, but it is handy for demos.
|
littlefs. I'm not sure why you would want this, but it is handy for demos.
|
||||||
You can see it in action [here](http://littlefs.geky.net/demo.html).
|
You can see it in action [here](http://littlefs.geky.net/demo.html).
|
||||||
|
|
||||||
|
[mklfs](https://github.com/whitecatboard/Lua-RTOS-ESP32/tree/master/components/mklfs/src) -
|
||||||
|
A command line tool built by the [Lua RTOS](https://github.com/whitecatboard/Lua-RTOS-ESP32)
|
||||||
|
guys for making littlefs images from a host PC. Supports Windows, Mac OS,
|
||||||
|
and Linux.
|
||||||
|
|
||||||
|
[SPIFFS](https://github.com/pellepl/spiffs) - Another excellent embedded
|
||||||
|
filesystem for NOR flash. As a more traditional logging filesystem with full
|
||||||
|
static wear-leveling, SPIFFS will likely outperform littlefs on small
|
||||||
|
memories such as the internal flash on microcontrollers.
|
||||||
|
|
||||||
|
[Dhara](https://github.com/dlbeer/dhara) - An interesting NAND flash
|
||||||
|
translation layer designed for small MCUs. It offers static wear-leveling and
|
||||||
|
power-resilience with only a fixed O(|address|) pointer structure stored on
|
||||||
|
each block and in RAM.
|
||||||
|
|||||||
72
lfs.c
72
lfs.c
@@ -888,7 +888,7 @@ nextname:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check that entry has not been moved
|
// check that entry has not been moved
|
||||||
if (entry->d.type & 0x80) {
|
if (!lfs->moving && entry->d.type & 0x80) {
|
||||||
int moved = lfs_moved(lfs, &entry->d.u);
|
int moved = lfs_moved(lfs, &entry->d.u);
|
||||||
if (moved < 0 || moved) {
|
if (moved < 0 || moved) {
|
||||||
return (moved < 0) ? moved : LFS_ERR_NOENT;
|
return (moved < 0) ? moved : LFS_ERR_NOENT;
|
||||||
@@ -1644,6 +1644,11 @@ lfs_ssize_t lfs_file_write(lfs_t *lfs, lfs_file_t *file,
|
|||||||
file->pos = file->size;
|
file->pos = file->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (file->pos + size > LFS_FILE_MAX) {
|
||||||
|
// larger than file limit?
|
||||||
|
return LFS_ERR_FBIG;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(file->flags & LFS_F_WRITING) && file->pos > file->size) {
|
if (!(file->flags & LFS_F_WRITING) && file->pos > file->size) {
|
||||||
// fill with zeros
|
// fill with zeros
|
||||||
lfs_off_t pos = file->pos;
|
lfs_off_t pos = file->pos;
|
||||||
@@ -1730,24 +1735,24 @@ lfs_soff_t lfs_file_seek(lfs_t *lfs, lfs_file_t *file,
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// update pos
|
// find new pos
|
||||||
|
lfs_soff_t npos = file->pos;
|
||||||
if (whence == LFS_SEEK_SET) {
|
if (whence == LFS_SEEK_SET) {
|
||||||
file->pos = off;
|
npos = off;
|
||||||
} else if (whence == LFS_SEEK_CUR) {
|
} else if (whence == LFS_SEEK_CUR) {
|
||||||
if (off < 0 && (lfs_off_t)-off > file->pos) {
|
npos = file->pos + off;
|
||||||
return LFS_ERR_INVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
file->pos = file->pos + off;
|
|
||||||
} else if (whence == LFS_SEEK_END) {
|
} else if (whence == LFS_SEEK_END) {
|
||||||
if (off < 0 && (lfs_off_t)-off > file->size) {
|
npos = file->size + off;
|
||||||
return LFS_ERR_INVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
file->pos = file->size + off;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return file->pos;
|
if (npos < 0 || npos > LFS_FILE_MAX) {
|
||||||
|
// file position out of range
|
||||||
|
return LFS_ERR_INVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// update pos
|
||||||
|
file->pos = npos;
|
||||||
|
return npos;
|
||||||
}
|
}
|
||||||
|
|
||||||
int lfs_file_truncate(lfs_t *lfs, lfs_file_t *file, lfs_off_t size) {
|
int lfs_file_truncate(lfs_t *lfs, lfs_file_t *file, lfs_off_t size) {
|
||||||
@@ -1922,7 +1927,14 @@ int lfs_rename(lfs_t *lfs, const char *oldpath, const char *newpath) {
|
|||||||
// find old entry
|
// find old entry
|
||||||
lfs_dir_t oldcwd;
|
lfs_dir_t oldcwd;
|
||||||
lfs_entry_t oldentry;
|
lfs_entry_t oldentry;
|
||||||
int err = lfs_dir_find(lfs, &oldcwd, &oldentry, &oldpath);
|
int err = lfs_dir_find(lfs, &oldcwd, &oldentry, &(const char *){oldpath});
|
||||||
|
if (err) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// mark as moving
|
||||||
|
oldentry.d.type |= 0x80;
|
||||||
|
err = lfs_dir_update(lfs, &oldcwd, &oldentry, NULL);
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@@ -1935,11 +1947,9 @@ int lfs_rename(lfs_t *lfs, const char *oldpath, const char *newpath) {
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool prevexists = (err != LFS_ERR_NOENT);
|
|
||||||
bool samepair = (lfs_paircmp(oldcwd.pair, newcwd.pair) == 0);
|
|
||||||
|
|
||||||
// must have same type
|
// must have same type
|
||||||
if (prevexists && preventry.d.type != oldentry.d.type) {
|
bool prevexists = (err != LFS_ERR_NOENT);
|
||||||
|
if (prevexists && preventry.d.type != (0x7f & oldentry.d.type)) {
|
||||||
return LFS_ERR_ISDIR;
|
return LFS_ERR_ISDIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1956,18 +1966,6 @@ int lfs_rename(lfs_t *lfs, const char *oldpath, const char *newpath) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// mark as moving
|
|
||||||
oldentry.d.type |= 0x80;
|
|
||||||
err = lfs_dir_update(lfs, &oldcwd, &oldentry, NULL);
|
|
||||||
if (err) {
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
// update pair if newcwd == oldcwd
|
|
||||||
if (samepair) {
|
|
||||||
newcwd = oldcwd;
|
|
||||||
}
|
|
||||||
|
|
||||||
// move to new location
|
// move to new location
|
||||||
lfs_entry_t newentry = preventry;
|
lfs_entry_t newentry = preventry;
|
||||||
newentry.d = oldentry.d;
|
newentry.d = oldentry.d;
|
||||||
@@ -1986,10 +1984,13 @@ int lfs_rename(lfs_t *lfs, const char *oldpath, const char *newpath) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// update pair if newcwd == oldcwd
|
// fetch old pair again in case dir block changed
|
||||||
if (samepair) {
|
lfs->moving = true;
|
||||||
oldcwd = newcwd;
|
err = lfs_dir_find(lfs, &oldcwd, &oldentry, &oldpath);
|
||||||
|
if (err) {
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
lfs->moving = false;
|
||||||
|
|
||||||
// remove old entry
|
// remove old entry
|
||||||
err = lfs_dir_remove(lfs, &oldcwd, &oldentry);
|
err = lfs_dir_remove(lfs, &oldcwd, &oldentry);
|
||||||
@@ -2087,6 +2088,7 @@ static int lfs_init(lfs_t *lfs, const struct lfs_config *cfg) {
|
|||||||
lfs->files = NULL;
|
lfs->files = NULL;
|
||||||
lfs->dirs = NULL;
|
lfs->dirs = NULL;
|
||||||
lfs->deorphaned = false;
|
lfs->deorphaned = false;
|
||||||
|
lfs->moving = false;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -2481,7 +2483,7 @@ int lfs_deorphan(lfs_t *lfs) {
|
|||||||
lfs_dir_t cwd = {.d.tail[0] = 0, .d.tail[1] = 1};
|
lfs_dir_t cwd = {.d.tail[0] = 0, .d.tail[1] = 1};
|
||||||
|
|
||||||
// iterate over all directory directory entries
|
// iterate over all directory directory entries
|
||||||
for (int i = 0; i < lfs->cfg->block_count; i++) {
|
for (lfs_size_t i = 0; i < lfs->cfg->block_count; i++) {
|
||||||
if (lfs_pairisnull(cwd.d.tail)) {
|
if (lfs_pairisnull(cwd.d.tail)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
9
lfs.h
9
lfs.h
@@ -21,7 +21,7 @@ extern "C"
|
|||||||
// Software library version
|
// Software library version
|
||||||
// Major (top-nibble), incremented on backwards incompatible changes
|
// Major (top-nibble), incremented on backwards incompatible changes
|
||||||
// Minor (bottom-nibble), incremented on feature additions
|
// Minor (bottom-nibble), incremented on feature additions
|
||||||
#define LFS_VERSION 0x00010006
|
#define LFS_VERSION 0x00010007
|
||||||
#define LFS_VERSION_MAJOR (0xffff & (LFS_VERSION >> 16))
|
#define LFS_VERSION_MAJOR (0xffff & (LFS_VERSION >> 16))
|
||||||
#define LFS_VERSION_MINOR (0xffff & (LFS_VERSION >> 0))
|
#define LFS_VERSION_MINOR (0xffff & (LFS_VERSION >> 0))
|
||||||
|
|
||||||
@@ -49,6 +49,11 @@ typedef uint32_t lfs_block_t;
|
|||||||
#define LFS_NAME_MAX 255
|
#define LFS_NAME_MAX 255
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Max file size in bytes
|
||||||
|
#ifndef LFS_FILE_MAX
|
||||||
|
#define LFS_FILE_MAX 2147483647
|
||||||
|
#endif
|
||||||
|
|
||||||
// Possible error codes, these are negative to allow
|
// Possible error codes, these are negative to allow
|
||||||
// valid positive return values
|
// valid positive return values
|
||||||
enum lfs_error {
|
enum lfs_error {
|
||||||
@@ -61,6 +66,7 @@ enum lfs_error {
|
|||||||
LFS_ERR_ISDIR = -21, // Entry is a dir
|
LFS_ERR_ISDIR = -21, // Entry is a dir
|
||||||
LFS_ERR_NOTEMPTY = -39, // Dir is not empty
|
LFS_ERR_NOTEMPTY = -39, // Dir is not empty
|
||||||
LFS_ERR_BADF = -9, // Bad file number
|
LFS_ERR_BADF = -9, // Bad file number
|
||||||
|
LFS_ERR_FBIG = -27, // File too large
|
||||||
LFS_ERR_INVAL = -22, // Invalid parameter
|
LFS_ERR_INVAL = -22, // Invalid parameter
|
||||||
LFS_ERR_NOSPC = -28, // No space left on device
|
LFS_ERR_NOSPC = -28, // No space left on device
|
||||||
LFS_ERR_NOMEM = -12, // No more memory available
|
LFS_ERR_NOMEM = -12, // No more memory available
|
||||||
@@ -280,6 +286,7 @@ typedef struct lfs {
|
|||||||
|
|
||||||
lfs_free_t free;
|
lfs_free_t free;
|
||||||
bool deorphaned;
|
bool deorphaned;
|
||||||
|
bool moving;
|
||||||
} lfs_t;
|
} lfs_t;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -32,18 +32,18 @@ lfs_alloc_singleproc() {
|
|||||||
tests/test.py << TEST
|
tests/test.py << TEST
|
||||||
const char *names[] = {"bacon", "eggs", "pancakes"};
|
const char *names[] = {"bacon", "eggs", "pancakes"};
|
||||||
lfs_mount(&lfs, &cfg) => 0;
|
lfs_mount(&lfs, &cfg) => 0;
|
||||||
for (int n = 0; n < sizeof(names)/sizeof(names[0]); n++) {
|
for (unsigned n = 0; n < sizeof(names)/sizeof(names[0]); n++) {
|
||||||
sprintf((char*)buffer, "$1/%s", names[n]);
|
sprintf((char*)buffer, "$1/%s", names[n]);
|
||||||
lfs_file_open(&lfs, &file[n], (char*)buffer,
|
lfs_file_open(&lfs, &file[n], (char*)buffer,
|
||||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0;
|
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0;
|
||||||
}
|
}
|
||||||
for (int n = 0; n < sizeof(names)/sizeof(names[0]); n++) {
|
for (unsigned n = 0; n < sizeof(names)/sizeof(names[0]); n++) {
|
||||||
size = strlen(names[n]);
|
size = strlen(names[n]);
|
||||||
for (int i = 0; i < $SIZE; i++) {
|
for (int i = 0; i < $SIZE; i++) {
|
||||||
lfs_file_write(&lfs, &file[n], names[n], size) => size;
|
lfs_file_write(&lfs, &file[n], names[n], size) => size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int n = 0; n < sizeof(names)/sizeof(names[0]); n++) {
|
for (unsigned n = 0; n < sizeof(names)/sizeof(names[0]); n++) {
|
||||||
lfs_file_close(&lfs, &file[n]) => 0;
|
lfs_file_close(&lfs, &file[n]) => 0;
|
||||||
}
|
}
|
||||||
lfs_unmount(&lfs) => 0;
|
lfs_unmount(&lfs) => 0;
|
||||||
|
|||||||
@@ -326,13 +326,42 @@ tests/test.py << TEST
|
|||||||
lfs_unmount(&lfs) => 0;
|
lfs_unmount(&lfs) => 0;
|
||||||
TEST
|
TEST
|
||||||
|
|
||||||
|
echo "--- Multi-block rename ---"
|
||||||
|
tests/test.py << TEST
|
||||||
|
lfs_mount(&lfs, &cfg) => 0;
|
||||||
|
for (int i = 0; i < $LARGESIZE; i++) {
|
||||||
|
sprintf((char*)buffer, "cactus/test%d", i);
|
||||||
|
sprintf((char*)wbuffer, "cactus/tedd%d", i);
|
||||||
|
lfs_rename(&lfs, (char*)buffer, (char*)wbuffer) => 0;
|
||||||
|
}
|
||||||
|
lfs_unmount(&lfs) => 0;
|
||||||
|
TEST
|
||||||
|
tests/test.py << TEST
|
||||||
|
lfs_mount(&lfs, &cfg) => 0;
|
||||||
|
lfs_dir_open(&lfs, &dir[0], "cactus") => 0;
|
||||||
|
lfs_dir_read(&lfs, &dir[0], &info) => 1;
|
||||||
|
strcmp(info.name, ".") => 0;
|
||||||
|
info.type => LFS_TYPE_DIR;
|
||||||
|
lfs_dir_read(&lfs, &dir[0], &info) => 1;
|
||||||
|
strcmp(info.name, "..") => 0;
|
||||||
|
info.type => LFS_TYPE_DIR;
|
||||||
|
for (int i = 0; i < $LARGESIZE; i++) {
|
||||||
|
sprintf((char*)buffer, "tedd%d", i);
|
||||||
|
lfs_dir_read(&lfs, &dir[0], &info) => 1;
|
||||||
|
strcmp(info.name, (char*)buffer) => 0;
|
||||||
|
info.type => LFS_TYPE_DIR;
|
||||||
|
}
|
||||||
|
lfs_dir_read(&lfs, &dir[0], &info) => 0;
|
||||||
|
lfs_unmount(&lfs) => 0;
|
||||||
|
TEST
|
||||||
|
|
||||||
echo "--- Multi-block remove ---"
|
echo "--- Multi-block remove ---"
|
||||||
tests/test.py << TEST
|
tests/test.py << TEST
|
||||||
lfs_mount(&lfs, &cfg) => 0;
|
lfs_mount(&lfs, &cfg) => 0;
|
||||||
lfs_remove(&lfs, "cactus") => LFS_ERR_NOTEMPTY;
|
lfs_remove(&lfs, "cactus") => LFS_ERR_NOTEMPTY;
|
||||||
|
|
||||||
for (int i = 0; i < $LARGESIZE; i++) {
|
for (int i = 0; i < $LARGESIZE; i++) {
|
||||||
sprintf((char*)buffer, "cactus/test%d", i);
|
sprintf((char*)buffer, "cactus/tedd%d", i);
|
||||||
lfs_remove(&lfs, (char*)buffer) => 0;
|
lfs_remove(&lfs, (char*)buffer) => 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -391,13 +420,43 @@ tests/test.py << TEST
|
|||||||
lfs_unmount(&lfs) => 0;
|
lfs_unmount(&lfs) => 0;
|
||||||
TEST
|
TEST
|
||||||
|
|
||||||
|
echo "--- Multi-block rename with files ---"
|
||||||
|
tests/test.py << TEST
|
||||||
|
lfs_mount(&lfs, &cfg) => 0;
|
||||||
|
for (int i = 0; i < $LARGESIZE; i++) {
|
||||||
|
sprintf((char*)buffer, "prickly-pear/test%d", i);
|
||||||
|
sprintf((char*)wbuffer, "prickly-pear/tedd%d", i);
|
||||||
|
lfs_rename(&lfs, (char*)buffer, (char*)wbuffer) => 0;
|
||||||
|
}
|
||||||
|
lfs_unmount(&lfs) => 0;
|
||||||
|
TEST
|
||||||
|
tests/test.py << TEST
|
||||||
|
lfs_mount(&lfs, &cfg) => 0;
|
||||||
|
lfs_dir_open(&lfs, &dir[0], "prickly-pear") => 0;
|
||||||
|
lfs_dir_read(&lfs, &dir[0], &info) => 1;
|
||||||
|
strcmp(info.name, ".") => 0;
|
||||||
|
info.type => LFS_TYPE_DIR;
|
||||||
|
lfs_dir_read(&lfs, &dir[0], &info) => 1;
|
||||||
|
strcmp(info.name, "..") => 0;
|
||||||
|
info.type => LFS_TYPE_DIR;
|
||||||
|
for (int i = 0; i < $LARGESIZE; i++) {
|
||||||
|
sprintf((char*)buffer, "tedd%d", i);
|
||||||
|
lfs_dir_read(&lfs, &dir[0], &info) => 1;
|
||||||
|
strcmp(info.name, (char*)buffer) => 0;
|
||||||
|
info.type => LFS_TYPE_REG;
|
||||||
|
info.size => 6;
|
||||||
|
}
|
||||||
|
lfs_dir_read(&lfs, &dir[0], &info) => 0;
|
||||||
|
lfs_unmount(&lfs) => 0;
|
||||||
|
TEST
|
||||||
|
|
||||||
echo "--- Multi-block remove with files ---"
|
echo "--- Multi-block remove with files ---"
|
||||||
tests/test.py << TEST
|
tests/test.py << TEST
|
||||||
lfs_mount(&lfs, &cfg) => 0;
|
lfs_mount(&lfs, &cfg) => 0;
|
||||||
lfs_remove(&lfs, "prickly-pear") => LFS_ERR_NOTEMPTY;
|
lfs_remove(&lfs, "prickly-pear") => LFS_ERR_NOTEMPTY;
|
||||||
|
|
||||||
for (int i = 0; i < $LARGESIZE; i++) {
|
for (int i = 0; i < $LARGESIZE; i++) {
|
||||||
sprintf((char*)buffer, "prickly-pear/test%d", i);
|
sprintf((char*)buffer, "prickly-pear/tedd%d", i);
|
||||||
lfs_remove(&lfs, (char*)buffer) => 0;
|
lfs_remove(&lfs, (char*)buffer) => 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -301,7 +301,7 @@ tests/test.py << TEST
|
|||||||
size = strlen("hedgehoghog");
|
size = strlen("hedgehoghog");
|
||||||
const lfs_soff_t offsets[] = {512, 1020, 513, 1021, 511, 1019};
|
const lfs_soff_t offsets[] = {512, 1020, 513, 1021, 511, 1019};
|
||||||
|
|
||||||
for (int i = 0; i < sizeof(offsets) / sizeof(offsets[0]); i++) {
|
for (unsigned i = 0; i < sizeof(offsets) / sizeof(offsets[0]); i++) {
|
||||||
lfs_soff_t off = offsets[i];
|
lfs_soff_t off = offsets[i];
|
||||||
memcpy(buffer, "hedgehoghog", size);
|
memcpy(buffer, "hedgehoghog", size);
|
||||||
lfs_file_seek(&lfs, &file[0], off, LFS_SEEK_SET) => off;
|
lfs_file_seek(&lfs, &file[0], off, LFS_SEEK_SET) => off;
|
||||||
|
|||||||
@@ -23,14 +23,14 @@ tests/test.py << TEST
|
|||||||
|
|
||||||
lfs_mount(&lfs, &cfg) => 0;
|
lfs_mount(&lfs, &cfg) => 0;
|
||||||
|
|
||||||
for (int i = 0; i < sizeof(startsizes)/sizeof(startsizes[0]); i++) {
|
for (unsigned i = 0; i < sizeof(startsizes)/sizeof(startsizes[0]); i++) {
|
||||||
sprintf((char*)buffer, "hairyhead%d", i);
|
sprintf((char*)buffer, "hairyhead%d", i);
|
||||||
lfs_file_open(&lfs, &file[0], (const char*)buffer,
|
lfs_file_open(&lfs, &file[0], (const char*)buffer,
|
||||||
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
|
LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
|
||||||
|
|
||||||
strcpy((char*)buffer, "hair");
|
strcpy((char*)buffer, "hair");
|
||||||
size = strlen((char*)buffer);
|
size = strlen((char*)buffer);
|
||||||
for (int j = 0; j < startsizes[i]; j += size) {
|
for (lfs_off_t j = 0; j < startsizes[i]; j += size) {
|
||||||
lfs_file_write(&lfs, &file[0], buffer, size) => size;
|
lfs_file_write(&lfs, &file[0], buffer, size) => size;
|
||||||
}
|
}
|
||||||
lfs_file_size(&lfs, &file[0]) => startsizes[i];
|
lfs_file_size(&lfs, &file[0]) => startsizes[i];
|
||||||
@@ -55,13 +55,13 @@ tests/test.py << TEST
|
|||||||
|
|
||||||
lfs_mount(&lfs, &cfg) => 0;
|
lfs_mount(&lfs, &cfg) => 0;
|
||||||
|
|
||||||
for (int i = 0; i < sizeof(startsizes)/sizeof(startsizes[0]); i++) {
|
for (unsigned i = 0; i < sizeof(startsizes)/sizeof(startsizes[0]); i++) {
|
||||||
sprintf((char*)buffer, "hairyhead%d", i);
|
sprintf((char*)buffer, "hairyhead%d", i);
|
||||||
lfs_file_open(&lfs, &file[0], (const char*)buffer, LFS_O_RDWR) => 0;
|
lfs_file_open(&lfs, &file[0], (const char*)buffer, LFS_O_RDWR) => 0;
|
||||||
lfs_file_size(&lfs, &file[0]) => hotsizes[i];
|
lfs_file_size(&lfs, &file[0]) => hotsizes[i];
|
||||||
|
|
||||||
size = strlen("hair");
|
size = strlen("hair");
|
||||||
int j = 0;
|
lfs_off_t j = 0;
|
||||||
for (; j < startsizes[i] && j < hotsizes[i]; j += size) {
|
for (; j < startsizes[i] && j < hotsizes[i]; j += size) {
|
||||||
lfs_file_read(&lfs, &file[0], buffer, size) => size;
|
lfs_file_read(&lfs, &file[0], buffer, size) => size;
|
||||||
memcmp(buffer, "hair", size) => 0;
|
memcmp(buffer, "hair", size) => 0;
|
||||||
@@ -87,13 +87,13 @@ tests/test.py << TEST
|
|||||||
|
|
||||||
lfs_mount(&lfs, &cfg) => 0;
|
lfs_mount(&lfs, &cfg) => 0;
|
||||||
|
|
||||||
for (int i = 0; i < sizeof(startsizes)/sizeof(startsizes[0]); i++) {
|
for (unsigned i = 0; i < sizeof(startsizes)/sizeof(startsizes[0]); i++) {
|
||||||
sprintf((char*)buffer, "hairyhead%d", i);
|
sprintf((char*)buffer, "hairyhead%d", i);
|
||||||
lfs_file_open(&lfs, &file[0], (const char*)buffer, LFS_O_RDONLY) => 0;
|
lfs_file_open(&lfs, &file[0], (const char*)buffer, LFS_O_RDONLY) => 0;
|
||||||
lfs_file_size(&lfs, &file[0]) => coldsizes[i];
|
lfs_file_size(&lfs, &file[0]) => coldsizes[i];
|
||||||
|
|
||||||
size = strlen("hair");
|
size = strlen("hair");
|
||||||
int j = 0;
|
lfs_off_t j = 0;
|
||||||
for (; j < startsizes[i] && j < hotsizes[i] && j < coldsizes[i];
|
for (; j < startsizes[i] && j < hotsizes[i] && j < coldsizes[i];
|
||||||
j += size) {
|
j += size) {
|
||||||
lfs_file_read(&lfs, &file[0], buffer, size) => size;
|
lfs_file_read(&lfs, &file[0], buffer, size) => size;
|
||||||
|
|||||||
Reference in New Issue
Block a user