|
@@ -979,7 +979,7 @@ static lfs_stag_t lfs_dir_fetchmatch(lfs_t *lfs,
|
|
|
dir->rev = revs[(r+1)%2];
|
|
dir->rev = revs[(r+1)%2];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- LFS_ERROR("Corrupted dir pair at %"PRIx32" %"PRIx32,
|
|
|
|
|
|
|
+ LFS_ERROR("Corrupted dir pair at {0x%"PRIx32", 0x%"PRIx32"}",
|
|
|
dir->pair[0], dir->pair[1]);
|
|
dir->pair[0], dir->pair[1]);
|
|
|
return LFS_ERR_CORRUPT;
|
|
return LFS_ERR_CORRUPT;
|
|
|
}
|
|
}
|
|
@@ -1667,12 +1667,13 @@ relocate:
|
|
|
relocated = true;
|
|
relocated = true;
|
|
|
lfs_cache_drop(lfs, &lfs->pcache);
|
|
lfs_cache_drop(lfs, &lfs->pcache);
|
|
|
if (!tired) {
|
|
if (!tired) {
|
|
|
- LFS_DEBUG("Bad block at %"PRIx32, dir->pair[1]);
|
|
|
|
|
|
|
+ LFS_DEBUG("Bad block at 0x%"PRIx32, dir->pair[1]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// can't relocate superblock, filesystem is now frozen
|
|
// can't relocate superblock, filesystem is now frozen
|
|
|
if (lfs_pair_cmp(dir->pair, (const lfs_block_t[2]){0, 1}) == 0) {
|
|
if (lfs_pair_cmp(dir->pair, (const lfs_block_t[2]){0, 1}) == 0) {
|
|
|
- LFS_WARN("Superblock %"PRIx32" has become unwritable", dir->pair[1]);
|
|
|
|
|
|
|
+ LFS_WARN("Superblock 0x%"PRIx32" has become unwritable",
|
|
|
|
|
+ dir->pair[1]);
|
|
|
return LFS_ERR_NOSPC;
|
|
return LFS_ERR_NOSPC;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1688,7 +1689,8 @@ relocate:
|
|
|
|
|
|
|
|
if (relocated) {
|
|
if (relocated) {
|
|
|
// update references if we relocated
|
|
// update references if we relocated
|
|
|
- LFS_DEBUG("Relocating %"PRIx32" %"PRIx32" -> %"PRIx32" %"PRIx32,
|
|
|
|
|
|
|
+ LFS_DEBUG("Relocating {0x%"PRIx32", 0x%"PRIx32"} "
|
|
|
|
|
+ "-> {0x%"PRIx32", 0x%"PRIx32"}",
|
|
|
oldpair[0], oldpair[1], dir->pair[0], dir->pair[1]);
|
|
oldpair[0], oldpair[1], dir->pair[0], dir->pair[1]);
|
|
|
int err = lfs_fs_relocate(lfs, oldpair, dir->pair);
|
|
int err = lfs_fs_relocate(lfs, oldpair, dir->pair);
|
|
|
if (err) {
|
|
if (err) {
|
|
@@ -2311,7 +2313,7 @@ static int lfs_ctz_extend(lfs_t *lfs,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
relocate:
|
|
relocate:
|
|
|
- LFS_DEBUG("Bad block at %"PRIx32, nblock);
|
|
|
|
|
|
|
+ LFS_DEBUG("Bad block at 0x%"PRIx32, nblock);
|
|
|
|
|
|
|
|
// just clear cache and try a new block
|
|
// just clear cache and try a new block
|
|
|
lfs_cache_drop(lfs, pcache);
|
|
lfs_cache_drop(lfs, pcache);
|
|
@@ -2615,7 +2617,7 @@ static int lfs_file_relocate(lfs_t *lfs, lfs_file_t *file) {
|
|
|
return 0;
|
|
return 0;
|
|
|
|
|
|
|
|
relocate:
|
|
relocate:
|
|
|
- LFS_DEBUG("Bad block at %"PRIx32, nblock);
|
|
|
|
|
|
|
+ LFS_DEBUG("Bad block at 0x%"PRIx32, nblock);
|
|
|
|
|
|
|
|
// just clear cache and try a new block
|
|
// just clear cache and try a new block
|
|
|
lfs_cache_drop(lfs, &lfs->pcache);
|
|
lfs_cache_drop(lfs, &lfs->pcache);
|
|
@@ -2692,7 +2694,7 @@ static int lfs_file_flush(lfs_t *lfs, lfs_file_t *file) {
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
relocate:
|
|
relocate:
|
|
|
- LFS_DEBUG("Bad block at %"PRIx32, file->block);
|
|
|
|
|
|
|
+ LFS_DEBUG("Bad block at 0x%"PRIx32, file->block);
|
|
|
err = lfs_file_relocate(lfs, file);
|
|
err = lfs_file_relocate(lfs, file);
|
|
|
if (err) {
|
|
if (err) {
|
|
|
return err;
|
|
return err;
|
|
@@ -3716,7 +3718,7 @@ int lfs_mount(lfs_t *lfs, const struct lfs_config *cfg) {
|
|
|
uint16_t minor_version = (0xffff & (superblock.version >> 0));
|
|
uint16_t minor_version = (0xffff & (superblock.version >> 0));
|
|
|
if ((major_version != LFS_DISK_VERSION_MAJOR ||
|
|
if ((major_version != LFS_DISK_VERSION_MAJOR ||
|
|
|
minor_version > LFS_DISK_VERSION_MINOR)) {
|
|
minor_version > LFS_DISK_VERSION_MINOR)) {
|
|
|
- LFS_ERROR("Invalid version %"PRIu16".%"PRIu16,
|
|
|
|
|
|
|
+ LFS_ERROR("Invalid version v%"PRIu16".%"PRIu16,
|
|
|
major_version, minor_version);
|
|
major_version, minor_version);
|
|
|
err = LFS_ERR_INVAL;
|
|
err = LFS_ERR_INVAL;
|
|
|
goto cleanup;
|
|
goto cleanup;
|
|
@@ -3772,7 +3774,7 @@ int lfs_mount(lfs_t *lfs, const struct lfs_config *cfg) {
|
|
|
|
|
|
|
|
// update littlefs with gstate
|
|
// update littlefs with gstate
|
|
|
if (!lfs_gstate_iszero(&lfs->gstate)) {
|
|
if (!lfs_gstate_iszero(&lfs->gstate)) {
|
|
|
- LFS_DEBUG("Found pending gstate %08"PRIx32" %08"PRIx32" %08"PRIx32,
|
|
|
|
|
|
|
+ LFS_DEBUG("Found pending gstate 0x%08"PRIx32"%08"PRIx32"%08"PRIx32,
|
|
|
lfs->gstate.tag,
|
|
lfs->gstate.tag,
|
|
|
lfs->gstate.pair[0],
|
|
lfs->gstate.pair[0],
|
|
|
lfs->gstate.pair[1]);
|
|
lfs->gstate.pair[1]);
|
|
@@ -3987,8 +3989,6 @@ static int lfs_fs_relocate(lfs_t *lfs,
|
|
|
const lfs_block_t oldpair[2], lfs_block_t newpair[2]) {
|
|
const lfs_block_t oldpair[2], lfs_block_t newpair[2]) {
|
|
|
// update internal root
|
|
// update internal root
|
|
|
if (lfs_pair_cmp(oldpair, lfs->root) == 0) {
|
|
if (lfs_pair_cmp(oldpair, lfs->root) == 0) {
|
|
|
- LFS_DEBUG("Relocating root %"PRIx32" %"PRIx32,
|
|
|
|
|
- newpair[0], newpair[1]);
|
|
|
|
|
lfs->root[0] = newpair[0];
|
|
lfs->root[0] = newpair[0];
|
|
|
lfs->root[1] = newpair[1];
|
|
lfs->root[1] = newpair[1];
|
|
|
}
|
|
}
|
|
@@ -4024,7 +4024,7 @@ static int lfs_fs_relocate(lfs_t *lfs,
|
|
|
if (lfs_gstate_hasmovehere(&lfs->gstate, parent.pair)) {
|
|
if (lfs_gstate_hasmovehere(&lfs->gstate, parent.pair)) {
|
|
|
moveid = lfs_tag_id(lfs->gstate.tag);
|
|
moveid = lfs_tag_id(lfs->gstate.tag);
|
|
|
LFS_DEBUG("Fixing move while relocating "
|
|
LFS_DEBUG("Fixing move while relocating "
|
|
|
- "%"PRIx32" %"PRIx32" %"PRIx16"\n",
|
|
|
|
|
|
|
+ "{0x%"PRIx32", 0x%"PRIx32"} 0x%"PRIx16"\n",
|
|
|
parent.pair[0], parent.pair[1], moveid);
|
|
parent.pair[0], parent.pair[1], moveid);
|
|
|
lfs_fs_prepmove(lfs, 0x3ff, NULL);
|
|
lfs_fs_prepmove(lfs, 0x3ff, NULL);
|
|
|
if (moveid < lfs_tag_id(tag)) {
|
|
if (moveid < lfs_tag_id(tag)) {
|
|
@@ -4060,7 +4060,7 @@ static int lfs_fs_relocate(lfs_t *lfs,
|
|
|
if (lfs_gstate_hasmovehere(&lfs->gstate, parent.pair)) {
|
|
if (lfs_gstate_hasmovehere(&lfs->gstate, parent.pair)) {
|
|
|
moveid = lfs_tag_id(lfs->gstate.tag);
|
|
moveid = lfs_tag_id(lfs->gstate.tag);
|
|
|
LFS_DEBUG("Fixing move while relocating "
|
|
LFS_DEBUG("Fixing move while relocating "
|
|
|
- "%"PRIx32" %"PRIx32" %"PRIx16"\n",
|
|
|
|
|
|
|
+ "{0x%"PRIx32", 0x%"PRIx32"} 0x%"PRIx16"\n",
|
|
|
parent.pair[0], parent.pair[1], moveid);
|
|
parent.pair[0], parent.pair[1], moveid);
|
|
|
lfs_fs_prepmove(lfs, 0x3ff, NULL);
|
|
lfs_fs_prepmove(lfs, 0x3ff, NULL);
|
|
|
}
|
|
}
|
|
@@ -4101,7 +4101,7 @@ static int lfs_fs_demove(lfs_t *lfs) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Fix bad moves
|
|
// Fix bad moves
|
|
|
- LFS_DEBUG("Fixing move %"PRIx32" %"PRIx32" %"PRIx16,
|
|
|
|
|
|
|
+ LFS_DEBUG("Fixing move {0x%"PRIx32", 0x%"PRIx32"} 0x%"PRIx16,
|
|
|
lfs->gdisk.pair[0],
|
|
lfs->gdisk.pair[0],
|
|
|
lfs->gdisk.pair[1],
|
|
lfs->gdisk.pair[1],
|
|
|
lfs_tag_id(lfs->gdisk.tag));
|
|
lfs_tag_id(lfs->gdisk.tag));
|
|
@@ -4152,7 +4152,7 @@ static int lfs_fs_deorphan(lfs_t *lfs) {
|
|
|
|
|
|
|
|
if (tag == LFS_ERR_NOENT) {
|
|
if (tag == LFS_ERR_NOENT) {
|
|
|
// we are an orphan
|
|
// we are an orphan
|
|
|
- LFS_DEBUG("Fixing orphan %"PRIx32" %"PRIx32,
|
|
|
|
|
|
|
+ LFS_DEBUG("Fixing orphan {0x%"PRIx32", 0x%"PRIx32"}",
|
|
|
pdir.tail[0], pdir.tail[1]);
|
|
pdir.tail[0], pdir.tail[1]);
|
|
|
|
|
|
|
|
err = lfs_dir_drop(lfs, &pdir, &dir);
|
|
err = lfs_dir_drop(lfs, &pdir, &dir);
|
|
@@ -4174,8 +4174,8 @@ static int lfs_fs_deorphan(lfs_t *lfs) {
|
|
|
|
|
|
|
|
if (!lfs_pair_sync(pair, pdir.tail)) {
|
|
if (!lfs_pair_sync(pair, pdir.tail)) {
|
|
|
// we have desynced
|
|
// we have desynced
|
|
|
- LFS_DEBUG("Fixing half-orphan "
|
|
|
|
|
- "%"PRIx32" %"PRIx32" -> %"PRIx32" %"PRIx32,
|
|
|
|
|
|
|
+ LFS_DEBUG("Fixing half-orphan {0x%"PRIx32", 0x%"PRIx32"} "
|
|
|
|
|
+ "-> {0x%"PRIx32", 0x%"PRIx32"}",
|
|
|
pdir.tail[0], pdir.tail[1], pair[0], pair[1]);
|
|
pdir.tail[0], pdir.tail[1], pair[0], pair[1]);
|
|
|
|
|
|
|
|
lfs_pair_tole32(pair);
|
|
lfs_pair_tole32(pair);
|
|
@@ -4438,7 +4438,7 @@ static int lfs1_dir_fetch(lfs_t *lfs,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (!valid) {
|
|
if (!valid) {
|
|
|
- LFS_ERROR("Corrupted dir pair at %" PRIx32 " %" PRIx32 ,
|
|
|
|
|
|
|
+ LFS_ERROR("Corrupted dir pair at {0x%"PRIx32", 0x%"PRIx32"}",
|
|
|
tpair[0], tpair[1]);
|
|
tpair[0], tpair[1]);
|
|
|
return LFS_ERR_CORRUPT;
|
|
return LFS_ERR_CORRUPT;
|
|
|
}
|
|
}
|
|
@@ -4626,7 +4626,8 @@ static int lfs1_mount(lfs_t *lfs, struct lfs1 *lfs1,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (err || memcmp(superblock.d.magic, "littlefs", 8) != 0) {
|
|
if (err || memcmp(superblock.d.magic, "littlefs", 8) != 0) {
|
|
|
- LFS_ERROR("Invalid superblock at %d %d", 0, 1);
|
|
|
|
|
|
|
+ LFS_ERROR("Invalid superblock at {0x%"PRIx32", 0x%"PRIx32"}",
|
|
|
|
|
+ 0, 1);
|
|
|
err = LFS_ERR_CORRUPT;
|
|
err = LFS_ERR_CORRUPT;
|
|
|
goto cleanup;
|
|
goto cleanup;
|
|
|
}
|
|
}
|
|
@@ -4635,7 +4636,7 @@ static int lfs1_mount(lfs_t *lfs, struct lfs1 *lfs1,
|
|
|
uint16_t minor_version = (0xffff & (superblock.d.version >> 0));
|
|
uint16_t minor_version = (0xffff & (superblock.d.version >> 0));
|
|
|
if ((major_version != LFS1_DISK_VERSION_MAJOR ||
|
|
if ((major_version != LFS1_DISK_VERSION_MAJOR ||
|
|
|
minor_version > LFS1_DISK_VERSION_MINOR)) {
|
|
minor_version > LFS1_DISK_VERSION_MINOR)) {
|
|
|
- LFS_ERROR("Invalid version %d.%d", major_version, minor_version);
|
|
|
|
|
|
|
+ LFS_ERROR("Invalid version v%d.%d", major_version, minor_version);
|
|
|
err = LFS_ERR_INVAL;
|
|
err = LFS_ERR_INVAL;
|
|
|
goto cleanup;
|
|
goto cleanup;
|
|
|
}
|
|
}
|
|
@@ -4801,7 +4802,8 @@ int lfs_migrate(lfs_t *lfs, const struct lfs_config *cfg) {
|
|
|
|
|
|
|
|
// Copy over first block to thread into fs. Unfortunately
|
|
// Copy over first block to thread into fs. Unfortunately
|
|
|
// if this fails there is not much we can do.
|
|
// if this fails there is not much we can do.
|
|
|
- LFS_DEBUG("Migrating %"PRIx32" %"PRIx32" -> %"PRIx32" %"PRIx32,
|
|
|
|
|
|
|
+ LFS_DEBUG("Migrating {0x%"PRIx32", 0x%"PRIx32"} "
|
|
|
|
|
+ "-> {0x%"PRIx32", 0x%"PRIx32"}",
|
|
|
lfs->root[0], lfs->root[1], dir1.head[0], dir1.head[1]);
|
|
lfs->root[0], lfs->root[1], dir1.head[0], dir1.head[1]);
|
|
|
|
|
|
|
|
err = lfs_bd_erase(lfs, dir1.head[1]);
|
|
err = lfs_bd_erase(lfs, dir1.head[1]);
|