Skip to content

Commit a76802e

Browse files
committed
Brought mbed-littlefs up to date with changes in v2.2
- Removed LFS_INFO, this has been replaced by LFS_TRACE in the core repo - Fixed a merge issue that dropped mbed-specific checks in lfs2_util.h
1 parent d0ecd9f commit a76802e

File tree

3 files changed

+47
-72
lines changed

3 files changed

+47
-72
lines changed

LittleFileSystem2.cpp

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,10 @@ LittleFileSystem2::~LittleFileSystem2()
166166
int LittleFileSystem2::mount(BlockDevice *bd)
167167
{
168168
_mutex.lock();
169-
LFS2_INFO("mount(%p)", bd);
170169
_bd = bd;
171170
int err = _bd->init();
172171
if (err) {
173172
_bd = NULL;
174-
LFS2_INFO("mount -> %d", err);
175173
_mutex.unlock();
176174
return err;
177175
}
@@ -192,20 +190,17 @@ int LittleFileSystem2::mount(BlockDevice *bd)
192190
err = lfs2_mount(&_lfs, &_config);
193191
if (err) {
194192
_bd = NULL;
195-
LFS2_INFO("mount -> %d", lfs2_toerror(err));
196193
_mutex.unlock();
197194
return lfs2_toerror(err);
198195
}
199196

200197
_mutex.unlock();
201-
LFS2_INFO("mount -> %d", 0);
202198
return 0;
203199
}
204200

205201
int LittleFileSystem2::unmount()
206202
{
207203
_mutex.lock();
208-
LFS2_INFO("unmount(%s)", "");
209204
int res = 0;
210205
if (_bd) {
211206
int err = lfs2_unmount(&_lfs);
@@ -221,7 +216,6 @@ int LittleFileSystem2::unmount()
221216
_bd = NULL;
222217
}
223218

224-
LFS2_INFO("unmount -> %d", res);
225219
_mutex.unlock();
226220
return res;
227221
}
@@ -230,11 +224,8 @@ int LittleFileSystem2::format(BlockDevice *bd,
230224
lfs2_size_t block_size, uint32_t block_cycles,
231225
lfs2_size_t cache_size, lfs2_size_t lookahead_size)
232226
{
233-
LFS2_INFO("format(%p, %ld, %ld, %ld, %ld)",
234-
bd, block_size, block_cycles, cache_size, lookahead_size);
235227
int err = bd->init();
236228
if (err) {
237-
LFS2_INFO("format -> %d", err);
238229
return err;
239230
}
240231

@@ -257,39 +248,33 @@ int LittleFileSystem2::format(BlockDevice *bd,
257248

258249
err = lfs2_format(&_lfs, &_config);
259250
if (err) {
260-
LFS2_INFO("format -> %d", lfs2_toerror(err));
261251
return lfs2_toerror(err);
262252
}
263253

264254
err = bd->deinit();
265255
if (err) {
266-
LFS2_INFO("format -> %d", err);
267256
return err;
268257
}
269258

270-
LFS2_INFO("format -> %d", 0);
271259
return 0;
272260
}
273261

274262
int LittleFileSystem2::reformat(BlockDevice *bd)
275263
{
276264
_mutex.lock();
277-
LFS2_INFO("reformat(%p)", bd);
278265
if (_bd) {
279266
if (!bd) {
280267
bd = _bd;
281268
}
282269

283270
int err = unmount();
284271
if (err) {
285-
LFS2_INFO("reformat -> %d", err);
286272
_mutex.unlock();
287273
return err;
288274
}
289275
}
290276

291277
if (!bd) {
292-
LFS2_INFO("reformat -> %d", -ENODEV);
293278
_mutex.unlock();
294279
return -ENODEV;
295280
}
@@ -300,49 +285,40 @@ int LittleFileSystem2::reformat(BlockDevice *bd)
300285
_config.cache_size,
301286
_config.lookahead_size);
302287
if (err) {
303-
LFS2_INFO("reformat -> %d", err);
304288
_mutex.unlock();
305289
return err;
306290
}
307291

308292
err = mount(bd);
309293
if (err) {
310-
LFS2_INFO("reformat -> %d", err);
311294
_mutex.unlock();
312295
return err;
313296
}
314297

315-
LFS2_INFO("reformat -> %d", 0);
316298
_mutex.unlock();
317299
return 0;
318300
}
319301

320302
int LittleFileSystem2::remove(const char *filename)
321303
{
322304
_mutex.lock();
323-
LFS2_INFO("remove(\"%s\")", filename);
324305
int err = lfs2_remove(&_lfs, filename);
325-
LFS2_INFO("remove -> %d", lfs2_toerror(err));
326306
_mutex.unlock();
327307
return lfs2_toerror(err);
328308
}
329309

330310
int LittleFileSystem2::rename(const char *oldname, const char *newname)
331311
{
332312
_mutex.lock();
333-
LFS2_INFO("rename(\"%s\", \"%s\")", oldname, newname);
334313
int err = lfs2_rename(&_lfs, oldname, newname);
335-
LFS2_INFO("rename -> %d", lfs2_toerror(err));
336314
_mutex.unlock();
337315
return lfs2_toerror(err);
338316
}
339317

340318
int LittleFileSystem2::mkdir(const char *name, mode_t mode)
341319
{
342320
_mutex.lock();
343-
LFS2_INFO("mkdir(\"%s\", 0x%lx)", name, mode);
344321
int err = lfs2_mkdir(&_lfs, name);
345-
LFS2_INFO("mkdir -> %d", lfs2_toerror(err));
346322
_mutex.unlock();
347323
return lfs2_toerror(err);
348324
}
@@ -351,9 +327,7 @@ int LittleFileSystem2::stat(const char *name, struct stat *st)
351327
{
352328
struct lfs2_info info;
353329
_mutex.lock();
354-
LFS2_INFO("stat(\"%s\", %p)", name, st);
355330
int err = lfs2_stat(&_lfs, name, &info);
356-
LFS2_INFO("stat -> %d", lfs2_toerror(err));
357331
_mutex.unlock();
358332
st->st_size = info.size;
359333
st->st_mode = lfs2_tomode(info.type);
@@ -366,9 +340,7 @@ int LittleFileSystem2::statvfs(const char *name, struct statvfs *st)
366340

367341
lfs2_ssize_t in_use = 0;
368342
_mutex.lock();
369-
LFS2_INFO("statvfs(\"%s\", %p)", name, st);
370343
in_use = lfs2_fs_size(&_lfs);
371-
LFS2_INFO("statvfs -> %d", lfs2_toerror(in_use));
372344
_mutex.unlock();
373345
if (in_use < 0) {
374346
return in_use;
@@ -388,9 +360,7 @@ int LittleFileSystem2::file_open(fs_file_t *file, const char *path, int flags)
388360
{
389361
lfs2_file_t *f = new lfs2_file_t;
390362
_mutex.lock();
391-
LFS2_INFO("file_open(%p, \"%s\", 0x%x)", *file, path, flags);
392363
int err = lfs2_file_open(&_lfs, f, path, lfs2_fromflags(flags));
393-
LFS2_INFO("file_open -> %d", lfs2_toerror(err));
394364
_mutex.unlock();
395365
if (!err) {
396366
*file = f;
@@ -404,9 +374,7 @@ int LittleFileSystem2::file_close(fs_file_t file)
404374
{
405375
lfs2_file_t *f = (lfs2_file_t *)file;
406376
_mutex.lock();
407-
LFS2_INFO("file_close(%p)", file);
408377
int err = lfs2_file_close(&_lfs, f);
409-
LFS2_INFO("file_close -> %d", lfs2_toerror(err));
410378
_mutex.unlock();
411379
delete f;
412380
return lfs2_toerror(err);
@@ -416,9 +384,7 @@ ssize_t LittleFileSystem2::file_read(fs_file_t file, void *buffer, size_t len)
416384
{
417385
lfs2_file_t *f = (lfs2_file_t *)file;
418386
_mutex.lock();
419-
LFS2_INFO("file_read(%p, %p, %d)", file, buffer, len);
420387
lfs2_ssize_t res = lfs2_file_read(&_lfs, f, buffer, len);
421-
LFS2_INFO("file_read -> %d", lfs2_toerror(res));
422388
_mutex.unlock();
423389
return lfs2_toerror(res);
424390
}
@@ -427,9 +393,7 @@ ssize_t LittleFileSystem2::file_write(fs_file_t file, const void *buffer, size_t
427393
{
428394
lfs2_file_t *f = (lfs2_file_t *)file;
429395
_mutex.lock();
430-
LFS2_INFO("file_write(%p, %p, %d)", file, buffer, len);
431396
lfs2_ssize_t res = lfs2_file_write(&_lfs, f, buffer, len);
432-
LFS2_INFO("file_write -> %d", lfs2_toerror(res));
433397
_mutex.unlock();
434398
return lfs2_toerror(res);
435399
}
@@ -438,9 +402,7 @@ int LittleFileSystem2::file_sync(fs_file_t file)
438402
{
439403
lfs2_file_t *f = (lfs2_file_t *)file;
440404
_mutex.lock();
441-
LFS2_INFO("file_sync(%p)", file);
442405
int err = lfs2_file_sync(&_lfs, f);
443-
LFS2_INFO("file_sync -> %d", lfs2_toerror(err));
444406
_mutex.unlock();
445407
return lfs2_toerror(err);
446408
}
@@ -449,9 +411,7 @@ off_t LittleFileSystem2::file_seek(fs_file_t file, off_t offset, int whence)
449411
{
450412
lfs2_file_t *f = (lfs2_file_t *)file;
451413
_mutex.lock();
452-
LFS2_INFO("file_seek(%p, %ld, %d)", file, offset, whence);
453414
off_t res = lfs2_file_seek(&_lfs, f, offset, lfs2_fromwhence(whence));
454-
LFS2_INFO("file_seek -> %d", lfs2_toerror(res));
455415
_mutex.unlock();
456416
return lfs2_toerror(res);
457417
}
@@ -460,9 +420,7 @@ off_t LittleFileSystem2::file_tell(fs_file_t file)
460420
{
461421
lfs2_file_t *f = (lfs2_file_t *)file;
462422
_mutex.lock();
463-
LFS2_INFO("file_tell(%p)", file);
464423
off_t res = lfs2_file_tell(&_lfs, f);
465-
LFS2_INFO("file_tell -> %d", lfs2_toerror(res));
466424
_mutex.unlock();
467425
return lfs2_toerror(res);
468426
}
@@ -471,9 +429,7 @@ off_t LittleFileSystem2::file_size(fs_file_t file)
471429
{
472430
lfs2_file_t *f = (lfs2_file_t *)file;
473431
_mutex.lock();
474-
LFS2_INFO("file_size(%p)", file);
475432
off_t res = lfs2_file_size(&_lfs, f);
476-
LFS2_INFO("file_size -> %d", lfs2_toerror(res));
477433
_mutex.unlock();
478434
return lfs2_toerror(res);
479435
}
@@ -482,9 +438,7 @@ int LittleFileSystem2::file_truncate(fs_file_t file, off_t length)
482438
{
483439
lfs2_file_t *f = (lfs2_file_t *)file;
484440
_mutex.lock();
485-
LFS2_INFO("file_truncate(%p)", file);
486441
int err = lfs2_file_truncate(&_lfs, f, length);
487-
LFS2_INFO("file_truncate -> %d", lfs2_toerror(err));
488442
_mutex.unlock();
489443
return lfs2_toerror(err);
490444
}
@@ -495,9 +449,7 @@ int LittleFileSystem2::dir_open(fs_dir_t *dir, const char *path)
495449
{
496450
lfs2_dir_t *d = new lfs2_dir_t;
497451
_mutex.lock();
498-
LFS2_INFO("dir_open(%p, \"%s\")", *dir, path);
499452
int err = lfs2_dir_open(&_lfs, d, path);
500-
LFS2_INFO("dir_open -> %d", lfs2_toerror(err));
501453
_mutex.unlock();
502454
if (!err) {
503455
*dir = d;
@@ -511,9 +463,7 @@ int LittleFileSystem2::dir_close(fs_dir_t dir)
511463
{
512464
lfs2_dir_t *d = (lfs2_dir_t *)dir;
513465
_mutex.lock();
514-
LFS2_INFO("dir_close(%p)", dir);
515466
int err = lfs2_dir_close(&_lfs, d);
516-
LFS2_INFO("dir_close -> %d", lfs2_toerror(err));
517467
_mutex.unlock();
518468
delete d;
519469
return lfs2_toerror(err);
@@ -524,9 +474,7 @@ ssize_t LittleFileSystem2::dir_read(fs_dir_t dir, struct dirent *ent)
524474
lfs2_dir_t *d = (lfs2_dir_t *)dir;
525475
struct lfs2_info info;
526476
_mutex.lock();
527-
LFS2_INFO("dir_read(%p, %p)", dir, ent);
528477
int res = lfs2_dir_read(&_lfs, d, &info);
529-
LFS2_INFO("dir_read -> %d", lfs2_toerror(res));
530478
_mutex.unlock();
531479
if (res == 1) {
532480
ent->d_type = lfs2_totype(info.type);
@@ -539,19 +487,15 @@ void LittleFileSystem2::dir_seek(fs_dir_t dir, off_t offset)
539487
{
540488
lfs2_dir_t *d = (lfs2_dir_t *)dir;
541489
_mutex.lock();
542-
LFS2_INFO("dir_seek(%p, %ld)", dir, offset);
543490
lfs2_dir_seek(&_lfs, d, offset);
544-
LFS2_INFO("dir_seek -> %s", "void");
545491
_mutex.unlock();
546492
}
547493

548494
off_t LittleFileSystem2::dir_tell(fs_dir_t dir)
549495
{
550496
lfs2_dir_t *d = (lfs2_dir_t *)dir;
551497
_mutex.lock();
552-
LFS2_INFO("dir_tell(%p)", dir);
553498
lfs2_soff_t res = lfs2_dir_tell(&_lfs, d);
554-
LFS2_INFO("dir_tell -> %d", lfs2_toerror(res));
555499
_mutex.unlock();
556500
return lfs2_toerror(res);
557501
}
@@ -560,9 +504,7 @@ void LittleFileSystem2::dir_rewind(fs_dir_t dir)
560504
{
561505
lfs2_dir_t *d = (lfs2_dir_t *)dir;
562506
_mutex.lock();
563-
LFS2_INFO("dir_rewind(%p)", dir);
564507
lfs2_dir_rewind(&_lfs, d);
565-
LFS2_INFO("dir_rewind -> %s", "void");
566508
_mutex.unlock();
567509
}
568510

littlefs/lfs2_util.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
// Only compile if user does not provide custom config
1010
#ifndef LFS2_CONFIG
11-
11+
#ifndef __MBED__
1212

1313
// Software CRC implementation with small lookup table
1414
uint32_t lfs2_crc(uint32_t crc, const void *buffer, size_t size) {
@@ -29,5 +29,5 @@ uint32_t lfs2_crc(uint32_t crc, const void *buffer, size_t size) {
2929
return crc;
3030
}
3131

32-
32+
#endif
3333
#endif

0 commit comments

Comments
 (0)