@@ -44,29 +44,28 @@ typedef int32_t lfs_soff_t;
4444
4545typedef uint32_t lfs_block_t ;
4646
47- // Maximum size of all attributes per file in bytes, may be redefined but a
48- // a smaller LFS_ATTR_MAX has no benefit. Stored in 12-bits and limited
49- // to <= 0xfff. Stored in superblock and must be respected by other
50- // littlefs drivers.
51- #ifndef LFS_ATTR_MAX
52- #define LFS_ATTR_MAX 0x1ffe
53- #endif
54-
5547// Maximum name size in bytes, may be redefined to reduce the size of the
56- // info struct. Limited to <= LFS_ATTR_MAX . Stored in superblock and must
57- // be respected by other littlefs drivers.
48+ // info struct. Limited to <= 8190 . Stored in superblock and must be
49+ // respected by other littlefs drivers.
5850#ifndef LFS_NAME_MAX
5951#define LFS_NAME_MAX 0xff
6052#endif
6153
62- // Maximum inline file size in bytes. Large inline files require a larger
63- // cache size, but if a file can be inline it does not need its own data
64- // block . Limited to <= LFS_ATTR_MAX and <= cache_size . Stored in superblock
65- // and must be respected by other littlefs drivers.
54+ // Maximum inline file size in bytes, may be redefined to limit RAM usage,
55+ // but littlefs will automatically limit the LFS_INLINE_MAX to the
56+ // configured cache_size . Limited to <= 8190 . Stored in superblock and must
57+ // be respected by other littlefs drivers.
6658#ifndef LFS_INLINE_MAX
6759#define LFS_INLINE_MAX 0x1ffe
6860#endif
6961
62+ // Maximum size of custom attributes in bytes, may be redefined, but there is
63+ // no real benefit to using a smaller LFS_ATTR_MAX. Limited to <= 8190. Stored
64+ // in superblock and must be respected by other littlefs drivers.
65+ #ifndef LFS_ATTR_MAX
66+ #define LFS_ATTR_MAX 0x1ffe
67+ #endif
68+
7069// Possible error codes, these are negative to allow
7170// valid positive return values
7271enum lfs_error {
@@ -213,35 +212,39 @@ struct lfs_config {
213212 // lookahead block.
214213 void * lookahead_buffer ;
215214
216- // Optional upper limit on file attributes in bytes. No downside for larger
217- // attributes size but must be less than LFS_ATTR_MAX. Defaults to
218- // LFS_ATTR_MAX when zero.Stored in superblock and must be respected by
219- // other littlefs drivers.
220- lfs_size_t attr_max ;
221-
222215 // Optional upper limit on length of file names in bytes. No downside for
223216 // larger names except the size of the info struct which is controlled by
224217 // the LFS_NAME_MAX define. Defaults to LFS_NAME_MAX when zero. Stored in
225218 // superblock and must be respected by other littlefs drivers.
226219 lfs_size_t name_max ;
227220
228- // Optional upper limit on inlined files in bytes. Large inline files
229- // require a larger cache size, but if a file can be inlined it does not
230- // need its own data block. Must be smaller than cache_size and less than
231- // LFS_INLINE_MAX. Defaults to min(LFS_INLINE_MAX, read_size) when zero.
232- // Stored in superblock and must be respected by other littlefs drivers.
221+ // Optional upper limit on inlined files in bytes. Inline files must be
222+ // backed by RAM, but if a file fits in RAM it can be inlined into its
223+ // directory block without needing its own data block. Must be <=
224+ // cache_size and LFS_INLINE_MAX. Defaults to min(LFS_INLINE_MAX,
225+ // cache_size) when zero. Stored in superblock and must be respected by
226+ // other littlefs drivers.
233227 lfs_size_t inline_max ;
228+
229+ // Optional upper limit on custom attributes in bytes. No downside for
230+ // larger attributes size but must be <= LFS_ATTR_MAX. Defaults to
231+ // LFS_ATTR_MAX when zero. Stored in superblock and must be respected by
232+ // other littlefs drivers.
233+ lfs_size_t attr_max ;
234234};
235235
236236// File info structure
237237struct lfs_info {
238238 // Type of the file, either LFS_TYPE_REG or LFS_TYPE_DIR
239239 uint8_t type ;
240240
241- // Size of the file, only valid for REG files
241+ // Size of the file, only valid for REG files. Limited to 32-bits.
242242 lfs_size_t size ;
243243
244- // Name of the file stored as a null-terminated string
244+ // Name of the file stored as a null-terminated string. Limited to
245+ // LFS_NAME_MAX+1, which can be changed by redefining LFS_NAME_MAX to
246+ // reduce RAM. LFS_NAME_MAX is stored in superblock and must be
247+ // respected by other littlefs drivers.
245248 char name [LFS_NAME_MAX + 1 ];
246249};
247250
@@ -340,9 +343,9 @@ typedef struct lfs_superblock {
340343 lfs_size_t block_size ;
341344 lfs_size_t block_count ;
342345
343- lfs_size_t attr_max ;
344346 lfs_size_t name_max ;
345347 lfs_size_t inline_max ;
348+ lfs_size_t attr_max ;
346349} lfs_superblock_t ;
347350
348351// The littlefs filesystem type
@@ -377,9 +380,9 @@ typedef struct lfs {
377380 const struct lfs_config * cfg ;
378381 lfs_size_t block_size ;
379382 lfs_size_t block_count ;
380- lfs_size_t attr_max ;
381383 lfs_size_t name_max ;
382384 lfs_size_t inline_max ;
385+ lfs_size_t attr_max ;
383386} lfs_t ;
384387
385388
0 commit comments