Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/littlefs-project/littlefs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/emubd
diff options
context:
space:
mode:
authorChristopher Haster <chaster@utexas.edu>2017-11-16 23:53:45 +0300
committerChristopher Haster <chaster@utexas.edu>2017-11-16 23:53:45 +0300
commit6664723e18034b3685d7d56374ec53b66cfcf47d (patch)
treef1382d1c126e0222d5ced794395d40b52e0de515 /emubd
parent3f31c8cba31e0f6cef5b02dba2e050d8df1168b7 (diff)
Fixed issue with committing directories to bad-blocks that are stuck
This is only an issue in the weird case that are worn down block is left in the odd state of not being able to change the data that resides on the block. That being said, this does pop up often when simulating wear on block devices. Currently, directory commits checked if the write succeeded by crcing the block to avoid the additional RAM cost for another buffer. However, before this commit, directory commits just checked if the block crc was valid, rather than comparing to the expected crc. This would usually work, unless the block was stuck in a state with valid crc. The fix is to simply compare with the expected crc to find errors.
Diffstat (limited to 'emubd')
-rw-r--r--emubd/lfs_emubd.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/emubd/lfs_emubd.c b/emubd/lfs_emubd.c
index ca2b6b9..b87d6de 100644
--- a/emubd/lfs_emubd.c
+++ b/emubd/lfs_emubd.c
@@ -138,8 +138,8 @@ int lfs_emubd_prog(const struct lfs_config *cfg, lfs_block_t block,
snprintf(emu->child, LFS_NAME_MAX, "%x", block);
FILE *f = fopen(emu->path, "r+b");
- if (!f && errno != ENOENT) {
- return -errno;
+ if (!f) {
+ return (errno == EACCES) ? 0 : -errno;
}
// Check that file was erased
@@ -189,14 +189,14 @@ int lfs_emubd_erase(const struct lfs_config *cfg, lfs_block_t block) {
return -errno;
}
- if (!err && S_ISREG(st.st_mode)) {
+ if (!err && S_ISREG(st.st_mode) && (S_IWUSR & st.st_mode)) {
int err = unlink(emu->path);
if (err) {
return -errno;
}
}
- if (err || S_ISREG(st.st_mode)) {
+ if (errno == ENOENT || (S_ISREG(st.st_mode) && (S_IWUSR & st.st_mode))) {
FILE *f = fopen(emu->path, "w");
if (!f) {
return -errno;