7
7
#include "lfs.h"
8
8
#include "lfs_util.h"
9
9
10
+ #include <inttypes.h>
11
+
10
12
11
13
/// Caching block device operations ///
12
14
static int lfs_cache_read (lfs_t * lfs , lfs_cache_t * rcache ,
@@ -308,7 +310,8 @@ static int lfs_alloc(lfs_t *lfs, lfs_block_t *block) {
308
310
309
311
// check if we have looked at all blocks since last ack
310
312
if (lfs -> free .ack == 0 ) {
311
- LFS_WARN ("No more free space %d" , lfs -> free .i + lfs -> free .off );
313
+ LFS_WARN ("No more free space %" PRIu32 ,
314
+ lfs -> free .i + lfs -> free .off );
312
315
return LFS_ERR_NOSPC ;
313
316
}
314
317
@@ -478,7 +481,8 @@ static int lfs_dir_fetch(lfs_t *lfs,
478
481
}
479
482
480
483
if (!valid ) {
481
- LFS_ERROR ("Corrupted dir pair at %d %d" , tpair [0 ], tpair [1 ]);
484
+ LFS_ERROR ("Corrupted dir pair at %" PRIu32 " %" PRIu32 ,
485
+ tpair [0 ], tpair [1 ]);
482
486
return LFS_ERR_CORRUPT ;
483
487
}
484
488
@@ -601,15 +605,16 @@ static int lfs_dir_commit(lfs_t *lfs, lfs_dir_t *dir,
601
605
break ;
602
606
relocate :
603
607
//commit was corrupted
604
- LFS_DEBUG ("Bad block at %d" , dir -> pair [0 ]);
608
+ LFS_DEBUG ("Bad block at %" PRIu32 , dir -> pair [0 ]);
605
609
606
610
// drop caches and prepare to relocate block
607
611
relocated = true;
608
612
lfs_cache_drop (lfs , & lfs -> pcache );
609
613
610
614
// can't relocate superblock, filesystem is now frozen
611
615
if (lfs_paircmp (oldpair , (const lfs_block_t [2 ]){0 , 1 }) == 0 ) {
612
- LFS_WARN ("Superblock %d has become unwritable" , oldpair [0 ]);
616
+ LFS_WARN ("Superblock %" PRIu32 " has become unwritable" ,
617
+ oldpair [0 ]);
613
618
return LFS_ERR_CORRUPT ;
614
619
}
615
620
@@ -622,7 +627,7 @@ static int lfs_dir_commit(lfs_t *lfs, lfs_dir_t *dir,
622
627
623
628
if (relocated ) {
624
629
// update references if we relocated
625
- LFS_DEBUG ("Relocating %d %d to %d %d" ,
630
+ LFS_DEBUG ("Relocating %" PRIu32 " %" PRIu32 " to %" PRIu32 " %" PRIu32 ,
626
631
oldpair [0 ], oldpair [1 ], dir -> pair [0 ], dir -> pair [1 ]);
627
632
int err = lfs_relocate (lfs , oldpair , dir -> pair );
628
633
if (err ) {
@@ -1227,7 +1232,7 @@ static int lfs_ctz_extend(lfs_t *lfs,
1227
1232
}
1228
1233
1229
1234
relocate :
1230
- LFS_DEBUG ("Bad block at %d" , nblock );
1235
+ LFS_DEBUG ("Bad block at %" PRIu32 , nblock );
1231
1236
1232
1237
// just clear cache and try a new block
1233
1238
lfs_cache_drop (lfs , & lfs -> pcache );
@@ -1384,7 +1389,7 @@ int lfs_file_close(lfs_t *lfs, lfs_file_t *file) {
1384
1389
1385
1390
static int lfs_file_relocate (lfs_t * lfs , lfs_file_t * file ) {
1386
1391
relocate :
1387
- LFS_DEBUG ("Bad block at %d" , file -> block );
1392
+ LFS_DEBUG ("Bad block at %" PRIu32 , file -> block );
1388
1393
1389
1394
// just relocate what exists into new block
1390
1395
lfs_block_t nblock ;
@@ -2395,7 +2400,8 @@ static int lfs_relocate(lfs_t *lfs,
2395
2400
2396
2401
// update internal root
2397
2402
if (lfs_paircmp (oldpair , lfs -> root ) == 0 ) {
2398
- LFS_DEBUG ("Relocating root %d %d" , newpair [0 ], newpair [1 ]);
2403
+ LFS_DEBUG ("Relocating root %" PRIu32 " %" PRIu32 ,
2404
+ newpair [0 ], newpair [1 ]);
2399
2405
lfs -> root [0 ] = newpair [0 ];
2400
2406
lfs -> root [1 ] = newpair [1 ];
2401
2407
}
@@ -2451,7 +2457,7 @@ int lfs_deorphan(lfs_t *lfs) {
2451
2457
2452
2458
if (!res ) {
2453
2459
// we are an orphan
2454
- LFS_DEBUG ("Found orphan %d %d" ,
2460
+ LFS_DEBUG ("Found orphan %" PRIu32 " %" PRIu32 ,
2455
2461
pdir .d .tail [0 ], pdir .d .tail [1 ]);
2456
2462
2457
2463
pdir .d .tail [0 ] = cwd .d .tail [0 ];
@@ -2467,7 +2473,7 @@ int lfs_deorphan(lfs_t *lfs) {
2467
2473
2468
2474
if (!lfs_pairsync (entry .d .u .dir , pdir .d .tail )) {
2469
2475
// we have desynced
2470
- LFS_DEBUG ("Found desync %d %d" ,
2476
+ LFS_DEBUG ("Found desync %" PRIu32 " %" PRIu32 ,
2471
2477
entry .d .u .dir [0 ], entry .d .u .dir [1 ]);
2472
2478
2473
2479
pdir .d .tail [0 ] = entry .d .u .dir [0 ];
@@ -2502,14 +2508,14 @@ int lfs_deorphan(lfs_t *lfs) {
2502
2508
}
2503
2509
2504
2510
if (moved ) {
2505
- LFS_DEBUG ("Found move %d %d" ,
2511
+ LFS_DEBUG ("Found move %" PRIu32 " %" PRIu32 ,
2506
2512
entry .d .u .dir [0 ], entry .d .u .dir [1 ]);
2507
2513
err = lfs_dir_remove (lfs , & cwd , & entry );
2508
2514
if (err ) {
2509
2515
return err ;
2510
2516
}
2511
2517
} else {
2512
- LFS_DEBUG ("Found partial move %d %d" ,
2518
+ LFS_DEBUG ("Found partial move %" PRIu32 " %" PRIu32 ,
2513
2519
entry .d .u .dir [0 ], entry .d .u .dir [1 ]);
2514
2520
entry .d .type &= ~0x80 ;
2515
2521
err = lfs_dir_update (lfs , & cwd , & entry , NULL );
@@ -2525,4 +2531,3 @@ int lfs_deorphan(lfs_t *lfs) {
2525
2531
2526
2532
return 0 ;
2527
2533
}
2528
-
0 commit comments