File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
features/storage/filesystem/littlefs/littlefs Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -2206,6 +2206,10 @@ int lfs_mount(lfs_t *lfs, const struct lfs_config *cfg) {
2206
2206
2207
2207
lfs -> root [0 ] = superblock .d .root [0 ];
2208
2208
lfs -> root [1 ] = superblock .d .root [1 ];
2209
+ if (lfs_paircmp (lfs -> root , dir .d .tail ) != 0 ) {
2210
+ err = LFS_ERR_CORRUPT ;
2211
+ goto cleanup ;
2212
+ }
2209
2213
}
2210
2214
2211
2215
if (err || memcmp (superblock .d .magic , "littlefs" , 8 ) != 0 ) {
@@ -2223,10 +2227,18 @@ int lfs_mount(lfs_t *lfs, const struct lfs_config *cfg) {
2223
2227
goto cleanup ;
2224
2228
}
2225
2229
2230
+ // verify that no metadata pairs are corrupt
2231
+ while (!lfs_pairisnull (dir .d .tail )) {
2232
+ err = lfs_dir_fetch (lfs , & dir , dir .d .tail );
2233
+ if (err ) {
2234
+ goto cleanup ;
2235
+ }
2236
+ }
2237
+
2238
+ // succuessfully mounted
2226
2239
return 0 ;
2227
2240
2228
2241
cleanup :
2229
-
2230
2242
lfs_deinit (lfs );
2231
2243
return err ;
2232
2244
}
You can’t perform that action at this time.
0 commit comments