Added support for writing on-disk version lfs2.0
The intention is to help interop with older minor versions of littlefs. Unfortunately, since lfs2.0 drivers cannot mount lfs2.1 images, there are situations where it would be useful to write to write strictly lfs2.0 compatible images. The solution here adds a "disk_version" configuration option which determines the behavior of lfs2.1 dependent features. Normally you would expect this to only change write behavior. But since the main change in lfs2.1 increased validation of erased data, we also need to skip this extra validation (fcrc) or see terrible slowdowns when writing.
This commit is contained in:
+60
-15
@@ -60,7 +60,10 @@ code = '''
|
||||
|
||||
# test we can mount in a new version
|
||||
[cases.test_compat_forward_mount]
|
||||
if = 'LFS_DISK_VERSION_MAJOR == LFSP_DISK_VERSION_MAJOR'
|
||||
if = '''
|
||||
LFS_DISK_VERSION_MAJOR == LFSP_DISK_VERSION_MAJOR
|
||||
&& DISK_VERSION == 0
|
||||
'''
|
||||
code = '''
|
||||
// create the previous version
|
||||
struct lfsp_config cfgp;
|
||||
@@ -88,7 +91,10 @@ code = '''
|
||||
# test we can read dirs in a new version
|
||||
[cases.test_compat_forward_read_dirs]
|
||||
defines.COUNT = 5
|
||||
if = 'LFS_DISK_VERSION_MAJOR == LFSP_DISK_VERSION_MAJOR'
|
||||
if = '''
|
||||
LFS_DISK_VERSION_MAJOR == LFSP_DISK_VERSION_MAJOR
|
||||
&& DISK_VERSION == 0
|
||||
'''
|
||||
code = '''
|
||||
// create the previous version
|
||||
struct lfsp_config cfgp;
|
||||
@@ -145,7 +151,10 @@ code = '''
|
||||
defines.COUNT = 5
|
||||
defines.SIZE = [4, 32, 512, 8192]
|
||||
defines.CHUNK = 4
|
||||
if = 'LFS_DISK_VERSION_MAJOR == LFSP_DISK_VERSION_MAJOR'
|
||||
if = '''
|
||||
LFS_DISK_VERSION_MAJOR == LFSP_DISK_VERSION_MAJOR
|
||||
&& DISK_VERSION == 0
|
||||
'''
|
||||
code = '''
|
||||
// create the previous version
|
||||
struct lfsp_config cfgp;
|
||||
@@ -232,7 +241,10 @@ code = '''
|
||||
defines.COUNT = 5
|
||||
defines.SIZE = [4, 32, 512, 8192]
|
||||
defines.CHUNK = 4
|
||||
if = 'LFS_DISK_VERSION_MAJOR == LFSP_DISK_VERSION_MAJOR'
|
||||
if = '''
|
||||
LFS_DISK_VERSION_MAJOR == LFSP_DISK_VERSION_MAJOR
|
||||
&& DISK_VERSION == 0
|
||||
'''
|
||||
code = '''
|
||||
// create the previous version
|
||||
struct lfsp_config cfgp;
|
||||
@@ -344,7 +356,10 @@ code = '''
|
||||
# test we can write dirs in a new version
|
||||
[cases.test_compat_forward_write_dirs]
|
||||
defines.COUNT = 10
|
||||
if = 'LFS_DISK_VERSION_MAJOR == LFSP_DISK_VERSION_MAJOR'
|
||||
if = '''
|
||||
LFS_DISK_VERSION_MAJOR == LFSP_DISK_VERSION_MAJOR
|
||||
&& DISK_VERSION == 0
|
||||
'''
|
||||
code = '''
|
||||
// create the previous version
|
||||
struct lfsp_config cfgp;
|
||||
@@ -408,7 +423,10 @@ code = '''
|
||||
defines.COUNT = 5
|
||||
defines.SIZE = [4, 32, 512, 8192]
|
||||
defines.CHUNK = 2
|
||||
if = 'LFS_DISK_VERSION_MAJOR == LFSP_DISK_VERSION_MAJOR'
|
||||
if = '''
|
||||
LFS_DISK_VERSION_MAJOR == LFSP_DISK_VERSION_MAJOR
|
||||
&& DISK_VERSION == 0
|
||||
'''
|
||||
code = '''
|
||||
// create the previous version
|
||||
struct lfsp_config cfgp;
|
||||
@@ -527,7 +545,10 @@ code = '''
|
||||
defines.COUNT = 5
|
||||
defines.SIZE = [4, 32, 512, 8192]
|
||||
defines.CHUNK = 2
|
||||
if = 'LFS_DISK_VERSION_MAJOR == LFSP_DISK_VERSION_MAJOR'
|
||||
if = '''
|
||||
LFS_DISK_VERSION_MAJOR == LFSP_DISK_VERSION_MAJOR
|
||||
&& DISK_VERSION == 0
|
||||
'''
|
||||
code = '''
|
||||
// create the previous version
|
||||
struct lfsp_config cfgp;
|
||||
@@ -674,7 +695,10 @@ code = '''
|
||||
|
||||
# test we can mount in an old version
|
||||
[cases.test_compat_backward_mount]
|
||||
if = 'LFS_DISK_VERSION == LFSP_DISK_VERSION'
|
||||
if = '''
|
||||
LFS_DISK_VERSION == LFSP_DISK_VERSION
|
||||
&& DISK_VERSION == 0
|
||||
'''
|
||||
code = '''
|
||||
// create the new version
|
||||
lfs_t lfs;
|
||||
@@ -696,7 +720,10 @@ code = '''
|
||||
# test we can read dirs in an old version
|
||||
[cases.test_compat_backward_read_dirs]
|
||||
defines.COUNT = 5
|
||||
if = 'LFS_DISK_VERSION == LFSP_DISK_VERSION'
|
||||
if = '''
|
||||
LFS_DISK_VERSION == LFSP_DISK_VERSION
|
||||
&& DISK_VERSION == 0
|
||||
'''
|
||||
code = '''
|
||||
// create the new version
|
||||
lfs_t lfs;
|
||||
@@ -748,7 +775,10 @@ code = '''
|
||||
defines.COUNT = 5
|
||||
defines.SIZE = [4, 32, 512, 8192]
|
||||
defines.CHUNK = 4
|
||||
if = 'LFS_DISK_VERSION == LFSP_DISK_VERSION'
|
||||
if = '''
|
||||
LFS_DISK_VERSION == LFSP_DISK_VERSION
|
||||
&& DISK_VERSION == 0
|
||||
'''
|
||||
code = '''
|
||||
// create the new version
|
||||
lfs_t lfs;
|
||||
@@ -830,7 +860,10 @@ code = '''
|
||||
defines.COUNT = 5
|
||||
defines.SIZE = [4, 32, 512, 8192]
|
||||
defines.CHUNK = 4
|
||||
if = 'LFS_DISK_VERSION == LFSP_DISK_VERSION'
|
||||
if = '''
|
||||
LFS_DISK_VERSION == LFSP_DISK_VERSION
|
||||
&& DISK_VERSION == 0
|
||||
'''
|
||||
code = '''
|
||||
// create the new version
|
||||
lfs_t lfs;
|
||||
@@ -937,7 +970,10 @@ code = '''
|
||||
# test we can write dirs in an old version
|
||||
[cases.test_compat_backward_write_dirs]
|
||||
defines.COUNT = 10
|
||||
if = 'LFS_DISK_VERSION == LFSP_DISK_VERSION'
|
||||
if = '''
|
||||
LFS_DISK_VERSION == LFSP_DISK_VERSION
|
||||
&& DISK_VERSION == 0
|
||||
'''
|
||||
code = '''
|
||||
// create the new version
|
||||
lfs_t lfs;
|
||||
@@ -996,7 +1032,10 @@ code = '''
|
||||
defines.COUNT = 5
|
||||
defines.SIZE = [4, 32, 512, 8192]
|
||||
defines.CHUNK = 2
|
||||
if = 'LFS_DISK_VERSION == LFSP_DISK_VERSION'
|
||||
if = '''
|
||||
LFS_DISK_VERSION == LFSP_DISK_VERSION
|
||||
&& DISK_VERSION == 0
|
||||
'''
|
||||
code = '''
|
||||
// create the previous version
|
||||
lfs_t lfs;
|
||||
@@ -1110,7 +1149,10 @@ code = '''
|
||||
defines.COUNT = 5
|
||||
defines.SIZE = [4, 32, 512, 8192]
|
||||
defines.CHUNK = 2
|
||||
if = 'LFS_DISK_VERSION == LFSP_DISK_VERSION'
|
||||
if = '''
|
||||
LFS_DISK_VERSION == LFSP_DISK_VERSION
|
||||
&& DISK_VERSION == 0
|
||||
'''
|
||||
code = '''
|
||||
// create the previous version
|
||||
lfs_t lfs;
|
||||
@@ -1319,7 +1361,10 @@ code = '''
|
||||
# test that we correctly bump the minor version
|
||||
[cases.test_compat_minor_bump]
|
||||
in = 'lfs.c'
|
||||
if = 'LFS_DISK_VERSION_MINOR > 0'
|
||||
if = '''
|
||||
LFS_DISK_VERSION_MINOR > 0
|
||||
&& DISK_VERSION == 0
|
||||
'''
|
||||
code = '''
|
||||
// create a superblock
|
||||
lfs_t lfs;
|
||||
|
||||
Reference in New Issue
Block a user