24#define LFS2_VERSION 0x00020002
25#define LFS2_VERSION_MAJOR (0xffff & (LFS2_VERSION >> 16))
26#define LFS2_VERSION_MINOR (0xffff & (LFS2_VERSION >> 0))
31#define LFS2_DISK_VERSION 0x00020000
32#define LFS2_DISK_VERSION_MAJOR (0xffff & (LFS2_DISK_VERSION >> 16))
33#define LFS2_DISK_VERSION_MINOR (0xffff & (LFS2_DISK_VERSION >> 0))
39typedef uint32_t lfs2_size_t;
40typedef uint32_t lfs2_off_t;
42typedef int32_t lfs2_ssize_t;
43typedef int32_t lfs2_soff_t;
45typedef uint32_t lfs2_block_t;
51#define LFS2_NAME_MAX 255
60#define LFS2_FILE_MAX 2147483647
66#define LFS2_ATTR_MAX 1022
74 LFS2_ERR_CORRUPT = -84,
77 LFS2_ERR_NOTDIR = -20,
79 LFS2_ERR_NOTEMPTY = -39,
85 LFS2_ERR_NOATTR = -61,
86 LFS2_ERR_NAMETOOLONG = -36,
92 LFS2_TYPE_REG = 0x001,
93 LFS2_TYPE_DIR = 0x002,
96 LFS2_TYPE_SPLICE = 0x400,
97 LFS2_TYPE_NAME = 0x000,
98 LFS2_TYPE_STRUCT = 0x200,
99 LFS2_TYPE_USERATTR = 0x300,
100 LFS2_TYPE_FROM = 0x100,
101 LFS2_TYPE_TAIL = 0x600,
102 LFS2_TYPE_GLOBALS = 0x700,
103 LFS2_TYPE_CRC = 0x500,
106 LFS2_TYPE_CREATE = 0x401,
107 LFS2_TYPE_DELETE = 0x4ff,
108 LFS2_TYPE_SUPERBLOCK = 0x0ff,
109 LFS2_TYPE_DIRSTRUCT = 0x200,
110 LFS2_TYPE_CTZSTRUCT = 0x202,
111 LFS2_TYPE_INLINESTRUCT = 0x201,
112 LFS2_TYPE_SOFTTAIL = 0x600,
113 LFS2_TYPE_HARDTAIL = 0x601,
114 LFS2_TYPE_MOVESTATE = 0x7ff,
117 LFS2_FROM_NOOP = 0x000,
118 LFS2_FROM_MOVE = 0x101,
119 LFS2_FROM_USERATTRS = 0x102,
123enum lfs2_open_flags {
128 LFS2_O_CREAT = 0x0100,
129 LFS2_O_EXCL = 0x0200,
130 LFS2_O_TRUNC = 0x0400,
131 LFS2_O_APPEND = 0x0800,
134 LFS2_F_DIRTY = 0x010000,
135 LFS2_F_WRITING = 0x020000,
136 LFS2_F_READING = 0x040000,
137 LFS2_F_ERRED = 0x080000,
138 LFS2_F_INLINE = 0x100000,
139 LFS2_F_OPENED = 0x200000,
143enum lfs2_whence_flags {
158 int (*read)(
const struct lfs2_config *c, lfs2_block_t block,
159 lfs2_off_t off,
void *buffer, lfs2_size_t size);
164 int (*prog)(
const struct lfs2_config *c, lfs2_block_t block,
165 lfs2_off_t off,
const void *buffer, lfs2_size_t size);
171 int (*erase)(
const struct lfs2_config *c, lfs2_block_t block);
179 lfs2_size_t read_size;
183 lfs2_size_t prog_size;
189 lfs2_size_t block_size;
192 lfs2_size_t block_count;
200 int32_t block_cycles;
207 lfs2_size_t cache_size;
213 lfs2_size_t lookahead_size;
226 void *lookahead_buffer;
232 lfs2_size_t name_max;
237 lfs2_size_t file_max;
242 lfs2_size_t attr_max;
257 char name[LFS2_NAME_MAX+1];
294 lfs2_size_t attr_count;
307 lfs2_block_t pair[2];
314 lfs2_block_t tail[2];
325 lfs2_block_t head[2];
351 lfs2_size_t block_size;
352 lfs2_size_t block_count;
353 lfs2_size_t name_max;
354 lfs2_size_t file_max;
355 lfs2_size_t attr_max;
360 lfs2_block_t pair[2];
368 lfs2_block_t root[2];
390 lfs2_size_t name_max;
391 lfs2_size_t file_max;
392 lfs2_size_t attr_max;
433int lfs2_remove(
lfs2_t *
lfs2,
const char *path);
441int lfs2_rename(
lfs2_t *
lfs2,
const char *oldpath,
const char *newpath);
461lfs2_ssize_t lfs2_getattr(
lfs2_t *
lfs2,
const char *path,
462 uint8_t type,
void *buffer, lfs2_size_t size);
471int lfs2_setattr(
lfs2_t *
lfs2,
const char *path,
472 uint8_t type,
const void *buffer, lfs2_size_t size);
479int lfs2_removeattr(
lfs2_t *
lfs2,
const char *path, uint8_t type);
491 const char *path,
int flags);
504 const char *path,
int flags,
526 void *buffer, lfs2_size_t size);
535 const void *buffer, lfs2_size_t size);
542 lfs2_soff_t off,
int whence);
573int lfs2_mkdir(
lfs2_t *
lfs2,
const char *path);
633int lfs2_fs_traverse(
lfs2_t *
lfs2,
int (*cb)(
void*, lfs2_block_t),
void *data);
internal littlefs data structures ///