Skip to content

Extended mount to check all metadata-pairs #9406

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion features/storage/filesystem/littlefs/littlefs/lfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2206,6 +2206,10 @@ int lfs_mount(lfs_t *lfs, const struct lfs_config *cfg) {

lfs->root[0] = superblock.d.root[0];
lfs->root[1] = superblock.d.root[1];
if (lfs_paircmp(lfs->root, dir.d.tail) != 0) {
err = LFS_ERR_CORRUPT;
goto cleanup;
}
}

if (err || memcmp(superblock.d.magic, "littlefs", 8) != 0) {
Expand All @@ -2223,10 +2227,18 @@ int lfs_mount(lfs_t *lfs, const struct lfs_config *cfg) {
goto cleanup;
}

// verify that no metadata pairs are corrupt
while (!lfs_pairisnull(dir.d.tail)) {
err = lfs_dir_fetch(lfs, &dir, dir.d.tail);
if (err) {
goto cleanup;
}
}

// succuessfully mounted
return 0;

cleanup:

lfs_deinit(lfs);
return err;
}
Expand Down