Added better handling for metadata pairs

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.
This commit is contained in:
Christopher Haster
2017-03-12 14:11:52 -06:00
parent 1d36fc606a
commit 106b06a457
4 changed files with 211 additions and 281 deletions
+13
View File
@@ -42,7 +42,20 @@ static inline lfs_word_t lfs_npw2(lfs_word_t a) {
return 32 - __builtin_clz(a-1);
}
static inline void lfs_swap(lfs_word_t *a, lfs_word_t *b) {
lfs_word_t temp = *a;
*a = *b;
*b = temp;
}
// Attributes
#define lfs_disk_struct struct __attribute__((packed))
// Logging operations
#include <stdio.h>
#define LFS_ERROR(fmt, ...) printf("Error: " fmt "\n", __VA_ARGS__)
#define LFS_WARN(fmt, ...) printf("Warn: " fmt "\n", __VA_ARGS__)
#define LFS_INFO(fmt, ...) printf("Info: " fmt "\n", __VA_ARGS__)
#endif