Restructured the major interfaces of the filesystem

This commit is contained in:
Christopher Haster
2017-03-25 16:20:31 -05:00
parent f566846223
commit 84a57642e5
8 changed files with 481 additions and 444 deletions
+5 -36
View File
@@ -10,48 +10,17 @@
#include <stdint.h>
// Type definitions
typedef uint64_t lfs_lword_t;
typedef uint32_t lfs_word_t;
typedef uint16_t lfs_hword_t;
typedef uint32_t lfs_size_t;
typedef uint32_t lfs_off_t;
typedef lfs_word_t lfs_size_t;
typedef int32_t lfs_ssize_t;
typedef lfs_word_t lfs_off_t;
typedef int lfs_error_t;
typedef int32_t lfs_ssize_t;
typedef int32_t lfs_soff_t;
typedef lfs_lword_t lfs_lsize_t;
typedef lfs_word_t lfs_ino_t;
typedef lfs_hword_t lfs_ioff_t;
typedef uint32_t lfs_block_t;
// Maximum length of file name
#define LFS_NAME_MAX 255
// Builtin functions
static inline lfs_word_t lfs_max(lfs_word_t a, lfs_word_t b) {
return (a > b) ? a : b;
}
static inline lfs_word_t lfs_min(lfs_word_t a, lfs_word_t b) {
return (a < b) ? a : b;
}
static inline lfs_word_t lfs_ctz(lfs_word_t a) {
return __builtin_ctz(a);
}
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__)