@@ -21,7 +21,7 @@ extern "C"
21
21
// Software library version
22
22
// Major (top-nibble), incremented on backwards incompatible changes
23
23
// Minor (bottom-nibble), incremented on feature additions
24
- #define LFS_VERSION 0x00010004
24
+ #define LFS_VERSION 0x00010005
25
25
#define LFS_VERSION_MAJOR (0xffff & (LFS_VERSION >> 16))
26
26
#define LFS_VERSION_MINOR (0xffff & (LFS_VERSION >> 0))
27
27
@@ -167,6 +167,12 @@ struct lfs_config {
167
167
void * file_buffer ;
168
168
};
169
169
170
+ // Optional configuration provided during lfs_file_opencfg
171
+ struct lfs_file_config {
172
+ // Optional, statically allocated buffer for files. Must be program sized.
173
+ // If NULL, malloc will be used by default.
174
+ void * buffer ;
175
+ };
170
176
171
177
// File info structure
172
178
struct lfs_info {
@@ -214,6 +220,7 @@ typedef struct lfs_file {
214
220
lfs_block_t head ;
215
221
lfs_size_t size ;
216
222
223
+ const struct lfs_file_config * cfg ;
217
224
uint32_t flags ;
218
225
lfs_off_t pos ;
219
226
lfs_block_t block ;
@@ -281,7 +288,8 @@ typedef struct lfs {
281
288
// Format a block device with the littlefs
282
289
//
283
290
// Requires a littlefs object and config struct. This clobbers the littlefs
284
- // object, and does not leave the filesystem mounted.
291
+ // object, and does not leave the filesystem mounted. The config struct must
292
+ // be zeroed for defaults and backwards compatibility.
285
293
//
286
294
// Returns a negative error code on failure.
287
295
int lfs_format (lfs_t * lfs , const struct lfs_config * config );
@@ -290,7 +298,8 @@ int lfs_format(lfs_t *lfs, const struct lfs_config *config);
290
298
//
291
299
// Requires a littlefs object and config struct. Multiple filesystems
292
300
// may be mounted simultaneously with multiple littlefs objects. Both
293
- // lfs and config must be allocated while mounted.
301
+ // lfs and config must be allocated while mounted. The config struct must
302
+ // be zeroed for defaults and backwards compatibility.
294
303
//
295
304
// Returns a negative error code on failure.
296
305
int lfs_mount (lfs_t * lfs , const struct lfs_config * config );
@@ -328,14 +337,27 @@ int lfs_stat(lfs_t *lfs, const char *path, struct lfs_info *info);
328
337
329
338
// Open a file
330
339
//
331
- // The mode that the file is opened in is determined
332
- // by the flags, which are values from the enum lfs_open_flags
333
- // that are bitwise-ored together.
340
+ // The mode that the file is opened in is determined by the flags, which
341
+ // are values from the enum lfs_open_flags that are bitwise-ored together.
334
342
//
335
343
// Returns a negative error code on failure.
336
344
int lfs_file_open (lfs_t * lfs , lfs_file_t * file ,
337
345
const char * path , int flags );
338
346
347
+ // Open a file with extra configuration
348
+ //
349
+ // The mode that the file is opened in is determined by the flags, which
350
+ // are values from the enum lfs_open_flags that are bitwise-ored together.
351
+ //
352
+ // The config struct provides additional config options per file as described
353
+ // above. The config struct must be allocated while the file is open, and the
354
+ // config struct must be zeroed for defaults and backwards compatibility.
355
+ //
356
+ // Returns a negative error code on failure.
357
+ int lfs_file_opencfg (lfs_t * lfs , lfs_file_t * file ,
358
+ const char * path , int flags ,
359
+ const struct lfs_file_config * config );
360
+
339
361
// Close a file
340
362
//
341
363
// Any pending writes are written out to storage as though
0 commit comments