Skip to content

Commit

Permalink
Added better handling for metadata pairs
Browse files Browse the repository at this point in the history
The core algorithim that backs this filesystem's goal of fault
tolerance is the alternating of "metadata pairs". Backed by a
simple core function for reading and writing, makes heavy use
of c99 designated initializers for passing info about multiple
chunks in an erase block.
  • Loading branch information
geky committed Mar 20, 2017
1 parent 1d36fc6 commit 106b06a
Show file tree
Hide file tree
Showing 4 changed files with 204 additions and 274 deletions.
11 changes: 10 additions & 1 deletion emubd/lfs_emubd.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <stdio.h>
#include <limits.h>
#include <dirent.h>
#include <sys/stat.h>


// Block device emulated on existing filesystem
Expand Down Expand Up @@ -168,11 +169,19 @@ lfs_error_t lfs_emubd_erase(lfs_emubd_t *emu,
// Iterate and erase blocks
while (size > 0) {
snprintf(emu->child, LFS_NAME_MAX, "%d", ino);
int err = unlink(emu->path);
struct stat st;
int err = stat(emu->path, &st);
if (err && errno != ENOENT) {
return -errno;
}

if (!err && S_ISREG(st.st_mode)) {
int err = unlink(emu->path);
if (err) {
return -errno;
}
}

size -= emu->info.erase_size;
ino += 1;
off = 0;
Expand Down
Loading

0 comments on commit 106b06a

Please sign in to comment.