Extended lfsr_mount to accept mount flags

This has been a long-time coming, mount flags are just too useful for
configuring a filesystem at runtime.

Currently this is limited to LFS_M_RDONLY and LFS_M_CKPROGS, but there
are a few more planned in the future:

  LFS_M_RDWR     = 0x0000, // Mount the filesystem as read and write
  LFS_M_RDONLY   = 0x0001, // Mount the filesystem as readonly
  LFS_M_STRICT*  = 0x0002, // Error if on-disk config does not match
  LFS_M_FORCE*   = 0x0004, // Ignore compat flags, mount readonly
  LFS_M_FORCEWITHRECKLESSABANDON*
                 = 0x0008, // Ignore compat flags, mount read write

  LFS_M_CKPROGS  = 0x0010, // Check progs by reading back progged data
  LFS_M_CKREADS* = 0x0020, // Check reads via checksums

  * Hypothetical

As a convenience, we also return mount flags in the struct lfs_fsinfo's
flags field as their relevant LFS_I_* variants. Though only to match
statvfs, and only because it's cheap, littlefs's API is low-level and we
should expect users to know what flags they passed to lfsr_mount.

As for the new mount flags:

- LFS_M_RDONLY - For consistency with existing APIs, this just asserts
  on write operations, which makes it a bit useless... But the info flag
  LFS_I_RDONLY may be useful for falling back to a readonly mode if
  we encounter on-disk compat issues.

  At least if implement the theoretical LFS_UNTRUSTED_USER mode
  LFS_M_RDONLY could become a runtime error.

- LFS_M_RDWR - This really just exists to compliment LFS_M_RDONLY and to
  match LFS_O_RDONLY/LFS_O_RDWR. It's just an alias for 0, and I don't
  think there will ever be a reason to make it non-0 (but I can always
  be wrong!).

- LFS_M_CKPROGS - This replaces the check_progs config option and avoids
  using a full byte to store a bool.

  We should probably also have a compile-time option to compile this out
  (LFS_NO_CKPROGS?), but that's a future thing to do.

This ended up adding a surprising bit of code, considering we're just
moving flags around, and noise in lfs_alloc added a bit of stack again:

           code          stack
  before: 35880           2672
  after:  35932 (+0.1%)   2680 (+0.3%)
This commit is contained in:
Christopher Haster
2024-07-15 01:48:37 -05:00
parent 0a3cb2dd3a
commit acfae9e072
25 changed files with 1322 additions and 1126 deletions
+186 -67
View File
@@ -6,6 +6,7 @@ after = [
'test_forphans',
'test_traversal',
'test_gc',
'test_mount',
]
@@ -26,7 +27,7 @@ defines.BADBLOCK_BEHAVIOR = [
'LFS_EMUBD_BADBLOCK_ERASENOOP',
]
# we need prog checking to detect read errors
defines.CHECK_PROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.CKPROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.N = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]
# maximize lookahead buffer to avoid alloc scans
defines.LOOKAHEAD_SIZE = 'lfs_alignup(BLOCK_COUNT / 8, 8)'
@@ -45,7 +46,10 @@ code = '''
// test creating a btree
lfs_t lfs;
lfs_init(&lfs, CFG) => 0;
lfs_init(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
// create free lookahead
memset(lfs.lookahead.buffer, 0, CFG->lookahead_size);
lfs.lookahead.start = 2;
@@ -134,7 +138,7 @@ defines.BADBLOCK_BEHAVIOR = [
'LFS_EMUBD_BADBLOCK_ERASENOOP',
]
# we need prog checking to detect read errors
defines.CHECK_PROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.CKPROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.N = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]
code = '''
// test all possible bad blocks
@@ -149,7 +153,10 @@ code = '''
// test creating directories
lfs_t lfs;
lfsr_format(&lfs, CFG) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
// make this many directories
for (lfs_size_t i = 0; i < N; i++) {
@@ -163,7 +170,10 @@ code = '''
// remount?
if (remount) {
lfsr_unmount(&lfs) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
}
// grm should be zero here
@@ -238,7 +248,7 @@ defines.BADBLOCK_BEHAVIOR = [
'LFS_EMUBD_BADBLOCK_ERASENOOP',
]
# we need prog checking to detect read errors
defines.CHECK_PROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.CKPROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.N = [1, 2, 4, 8, 16, 32, 64, 128, 256]
defines.OPS = '2*N'
defines.SEED = 42
@@ -256,7 +266,10 @@ code = '''
// test fuzz with dirs
lfs_t lfs;
lfsr_format(&lfs, CFG) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
// set up a simulation to compare against
lfs_size_t *sim = malloc(N*sizeof(lfs_size_t));
@@ -350,7 +363,10 @@ code = '''
// remount?
if (remount) {
lfsr_unmount(&lfs) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
}
// grm should be zero here
@@ -413,7 +429,7 @@ defines.BADBLOCK_BEHAVIOR = [
'LFS_EMUBD_BADBLOCK_ERASENOOP',
]
# we need prog checking to detect read errors
defines.CHECK_PROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.CKPROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.N = [1, 2, 4, 8, 16, 32, 64]
defines.SIZE = [
'0',
@@ -438,7 +454,10 @@ code = '''
// test creating files
lfs_t lfs;
lfsr_format(&lfs, CFG) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
// create this many files
uint32_t prng = 42;
@@ -462,7 +481,10 @@ code = '''
// remount?
if (remount) {
lfsr_unmount(&lfs) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
}
// check that our writes worked
@@ -511,7 +533,7 @@ defines.BADBLOCK_BEHAVIOR = [
'LFS_EMUBD_BADBLOCK_ERASENOOP',
]
# we need prog checking to detect read errors
defines.CHECK_PROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.CKPROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.N = [1, 2, 4, 8, 16, 32, 64]
defines.OPS = '2*N'
defines.SIZE = [
@@ -539,7 +561,10 @@ code = '''
// test fuzz with files
lfs_t lfs;
lfsr_format(&lfs, CFG) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
// set up a simulation to compare against
lfs_size_t *sim = malloc(N*sizeof(lfs_size_t));
@@ -670,7 +695,10 @@ code = '''
// remount?
if (remount) {
lfsr_unmount(&lfs) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
}
// check that our files match our simulation
@@ -748,7 +776,7 @@ defines.BADBLOCK_BEHAVIOR = [
'LFS_EMUBD_BADBLOCK_ERASENOOP',
]
# we need prog checking to detect read errors
defines.CHECK_PROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.CKPROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.OPS = 20
defines.SIZE = [
'FILE_BUFFER_SIZE/2',
@@ -785,7 +813,10 @@ code = '''
// test with complex file writes
lfs_t lfs;
lfsr_format(&lfs, CFG) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
// create a file
lfsr_file_t file;
@@ -847,7 +878,10 @@ code = '''
// remount?
if (remount) {
lfsr_unmount(&lfs) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
}
// check our file with stat
@@ -907,7 +941,7 @@ defines.BADBLOCK_BEHAVIOR = [
'LFS_EMUBD_BADBLOCK_ERASENOOP',
]
# we need prog checking to detect read errors
defines.CHECK_PROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.CKPROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.N = [1, 2, 4, 8, 16, 32, 64]
defines.OPS = '2*N'
defines.SIZE = [
@@ -935,7 +969,10 @@ code = '''
// test with orphans, zombies, etc
lfs_t lfs;
lfsr_format(&lfs, CFG) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
// set up a simulation to compare against
lfs_size_t *sim = malloc(N*sizeof(lfs_size_t));
@@ -1270,7 +1307,7 @@ defines.BADBLOCK_BEHAVIOR = [
'LFS_EMUBD_BADBLOCK_ERASENOOP',
]
# we need prog checking to detect read errors
defines.CHECK_PROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.CKPROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.N = [1, 2, 4, 8, 16, 32, 64]
defines.OPS = '2*N'
defines.SIZE = [
@@ -1298,7 +1335,10 @@ code = '''
// test with orphans, zombies, dirs, etc
lfs_t lfs;
lfsr_format(&lfs, CFG) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
// set up a simulation to compare against
lfs_size_t *sim = malloc(N*sizeof(lfs_size_t));
@@ -1720,7 +1760,7 @@ defines.BADBLOCK_BEHAVIOR = [
'LFS_EMUBD_BADBLOCK_ERASENOOP',
]
# we need prog checking to detect read errors
defines.CHECK_PROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.CKPROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.MIRROR = [false, true]
defines.N = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]
# maximize lookahead buffer to avoid alloc scans
@@ -1741,7 +1781,10 @@ code = '''
// test creating a btree
lfs_t lfs;
lfs_init(&lfs, CFG) => 0;
lfs_init(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
// create free lookahead
memset(lfs.lookahead.buffer, 0, CFG->lookahead_size);
lfs.lookahead.start = 2;
@@ -1825,7 +1868,7 @@ defines.BADBLOCK_BEHAVIOR = [
'LFS_EMUBD_BADBLOCK_ERASENOOP',
]
# we need prog checking to detect read errors
defines.CHECK_PROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.CKPROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.MIRROR = [false, true]
defines.N = [1, 2, 4, 8, 16, 32, 64, 128, 256]
code = '''
@@ -1846,7 +1889,10 @@ code = '''
// test creating directories
lfs_t lfs;
lfsr_format(&lfs, CFG) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
// make this many directories
for (lfs_size_t i = 0; i < N; i++) {
@@ -1860,7 +1906,10 @@ code = '''
// remount?
if (remount) {
lfsr_unmount(&lfs) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
}
// grm should be zero here
@@ -1930,7 +1979,7 @@ defines.BADBLOCK_BEHAVIOR = [
'LFS_EMUBD_BADBLOCK_ERASENOOP',
]
# we need prog checking to detect read errors
defines.CHECK_PROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.CKPROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.MIRROR = [false, true]
defines.N = [1, 2, 4, 8, 16, 32, 64, 128, 256]
defines.OPS = '2*N'
@@ -1954,7 +2003,10 @@ code = '''
// test fuzz with dirs
lfs_t lfs;
lfsr_format(&lfs, CFG) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
// set up a simulation to compare against
lfs_size_t *sim = malloc(N*sizeof(lfs_size_t));
@@ -2048,7 +2100,10 @@ code = '''
// remount?
if (remount) {
lfsr_unmount(&lfs) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
}
// grm should be zero here
@@ -2106,7 +2161,7 @@ defines.BADBLOCK_BEHAVIOR = [
'LFS_EMUBD_BADBLOCK_ERASENOOP',
]
# we need prog checking to detect read errors
defines.CHECK_PROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.CKPROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.MIRROR = [false, true]
defines.N = [1, 2, 4, 8, 16, 32, 64]
defines.SIZE = [
@@ -2137,7 +2192,10 @@ code = '''
// test creating files
lfs_t lfs;
lfsr_format(&lfs, CFG) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
// create this many files
uint32_t prng = 42;
@@ -2161,7 +2219,10 @@ code = '''
// remount?
if (remount) {
lfsr_unmount(&lfs) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
}
// check that our writes worked
@@ -2205,7 +2266,7 @@ defines.BADBLOCK_BEHAVIOR = [
'LFS_EMUBD_BADBLOCK_ERASENOOP',
]
# we need prog checking to detect read errors
defines.CHECK_PROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.CKPROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.MIRROR = [false, true]
defines.N = [1, 2, 4, 8, 16, 32, 64]
defines.OPS = '2*N'
@@ -2239,7 +2300,10 @@ code = '''
// test fuzz with files
lfs_t lfs;
lfsr_format(&lfs, CFG) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
// set up a simulation to compare against
lfs_size_t *sim = malloc(N*sizeof(lfs_size_t));
@@ -2370,7 +2434,10 @@ code = '''
// remount?
if (remount) {
lfsr_unmount(&lfs) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
}
// check that our files match our simulation
@@ -2443,7 +2510,7 @@ defines.BADBLOCK_BEHAVIOR = [
'LFS_EMUBD_BADBLOCK_ERASENOOP',
]
# we need prog checking to detect read errors
defines.CHECK_PROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.CKPROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.MIRROR = [false, true]
defines.OPS = 20
defines.SIZE = [
@@ -2486,7 +2553,10 @@ code = '''
// test with complex file writes
lfs_t lfs;
lfsr_format(&lfs, CFG) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
// create a file
lfsr_file_t file;
@@ -2548,7 +2618,10 @@ code = '''
// remount?
if (remount) {
lfsr_unmount(&lfs) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
}
// check our file with stat
@@ -2603,7 +2676,7 @@ defines.BADBLOCK_BEHAVIOR = [
'LFS_EMUBD_BADBLOCK_ERASENOOP',
]
# we need prog checking to detect read errors
defines.CHECK_PROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.CKPROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.MIRROR = [false, true]
defines.N = [1, 2, 4, 8, 16, 32, 64]
defines.OPS = '2*N'
@@ -2637,7 +2710,10 @@ code = '''
// test with orphans, zombies, etc
lfs_t lfs;
lfsr_format(&lfs, CFG) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
// set up a simulation to compare against
lfs_size_t *sim = malloc(N*sizeof(lfs_size_t));
@@ -2967,7 +3043,7 @@ defines.BADBLOCK_BEHAVIOR = [
'LFS_EMUBD_BADBLOCK_ERASENOOP',
]
# we need prog checking to detect read errors
defines.CHECK_PROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.CKPROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.MIRROR = [false, true]
defines.N = [1, 2, 4, 8, 16, 32, 64]
defines.OPS = '2*N'
@@ -3001,7 +3077,10 @@ code = '''
// test with orphans, zombies, dirs, etc
lfs_t lfs;
lfsr_format(&lfs, CFG) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
// set up a simulation to compare against
lfs_size_t *sim = malloc(N*sizeof(lfs_size_t));
@@ -3416,7 +3495,7 @@ defines.BADBLOCK_BEHAVIOR = [
'LFS_EMUBD_BADBLOCK_ERASENOOP',
]
# we need prog checking to detect read errors
defines.CHECK_PROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.CKPROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.MIRROR = [false, true]
defines.N = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]
# maximize lookahead buffer to avoid alloc scans
@@ -3437,7 +3516,10 @@ code = '''
// test creating a btree
lfs_t lfs;
lfs_init(&lfs, CFG) => 0;
lfs_init(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
// create free lookahead
memset(lfs.lookahead.buffer, 0, CFG->lookahead_size);
lfs.lookahead.start = 2;
@@ -3521,7 +3603,7 @@ defines.BADBLOCK_BEHAVIOR = [
'LFS_EMUBD_BADBLOCK_ERASENOOP',
]
# we need prog checking to detect read errors
defines.CHECK_PROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.CKPROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.MIRROR = [false, true]
defines.N = [1, 2, 4, 8, 16, 32, 64, 128, 256]
code = '''
@@ -3542,7 +3624,10 @@ code = '''
// test creating directories
lfs_t lfs;
lfsr_format(&lfs, CFG) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
// make this many directories
for (lfs_size_t i = 0; i < N; i++) {
@@ -3556,7 +3641,10 @@ code = '''
// remount?
if (remount) {
lfsr_unmount(&lfs) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
}
// grm should be zero here
@@ -3626,7 +3714,7 @@ defines.BADBLOCK_BEHAVIOR = [
'LFS_EMUBD_BADBLOCK_ERASENOOP',
]
# we need prog checking to detect read errors
defines.CHECK_PROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.CKPROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.MIRROR = [false, true]
defines.N = [1, 2, 4, 8, 16, 32, 64, 128, 256]
defines.OPS = '2*N'
@@ -3650,7 +3738,10 @@ code = '''
// test fuzz with dirs
lfs_t lfs;
lfsr_format(&lfs, CFG) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
// set up a simulation to compare against
lfs_size_t *sim = malloc(N*sizeof(lfs_size_t));
@@ -3744,7 +3835,10 @@ code = '''
// remount?
if (remount) {
lfsr_unmount(&lfs) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
}
// grm should be zero here
@@ -3802,7 +3896,7 @@ defines.BADBLOCK_BEHAVIOR = [
'LFS_EMUBD_BADBLOCK_ERASENOOP',
]
# we need prog checking to detect read errors
defines.CHECK_PROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.CKPROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.MIRROR = [false, true]
defines.N = [1, 2, 4, 8, 16, 32, 64]
defines.SIZE = [
@@ -3833,7 +3927,10 @@ code = '''
// test creating files
lfs_t lfs;
lfsr_format(&lfs, CFG) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
// create this many files
uint32_t prng = 42;
@@ -3857,7 +3954,10 @@ code = '''
// remount?
if (remount) {
lfsr_unmount(&lfs) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
}
// check that our writes worked
@@ -3901,7 +4001,7 @@ defines.BADBLOCK_BEHAVIOR = [
'LFS_EMUBD_BADBLOCK_ERASENOOP',
]
# we need prog checking to detect read errors
defines.CHECK_PROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.CKPROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.MIRROR = [false, true]
defines.N = [1, 2, 4, 8, 16, 32, 64]
defines.OPS = '2*N'
@@ -3935,7 +4035,10 @@ code = '''
// test fuzz with files
lfs_t lfs;
lfsr_format(&lfs, CFG) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
// set up a simulation to compare against
lfs_size_t *sim = malloc(N*sizeof(lfs_size_t));
@@ -4066,7 +4169,10 @@ code = '''
// remount?
if (remount) {
lfsr_unmount(&lfs) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
}
// check that our files match our simulation
@@ -4139,7 +4245,7 @@ defines.BADBLOCK_BEHAVIOR = [
'LFS_EMUBD_BADBLOCK_ERASENOOP',
]
# we need prog checking to detect read errors
defines.CHECK_PROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.CKPROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.MIRROR = [false, true]
defines.OPS = 20
defines.SIZE = [
@@ -4182,7 +4288,10 @@ code = '''
// test with complex file writes
lfs_t lfs;
lfsr_format(&lfs, CFG) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
// create a file
lfsr_file_t file;
@@ -4242,7 +4351,10 @@ code = '''
// remount?
if (remount) {
lfsr_unmount(&lfs) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
}
// check our file with stat
@@ -4297,7 +4409,7 @@ defines.BADBLOCK_BEHAVIOR = [
'LFS_EMUBD_BADBLOCK_ERASENOOP',
]
# we need prog checking to detect read errors
defines.CHECK_PROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.CKPROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.MIRROR = [false, true]
defines.N = [1, 2, 4, 8, 16, 32, 64]
defines.OPS = '2*N'
@@ -4331,7 +4443,10 @@ code = '''
// test with orphans, zombies, etc
lfs_t lfs;
lfsr_format(&lfs, CFG) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
// set up a simulation to compare against
lfs_size_t *sim = malloc(N*sizeof(lfs_size_t));
@@ -4661,7 +4776,7 @@ defines.BADBLOCK_BEHAVIOR = [
'LFS_EMUBD_BADBLOCK_ERASENOOP',
]
# we need prog checking to detect read errors
defines.CHECK_PROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.CKPROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.MIRROR = [false, true]
defines.N = [1, 2, 4, 8, 16, 32, 64]
defines.OPS = '2*N'
@@ -4695,7 +4810,10 @@ code = '''
// test with orphans, zombies, dirs, etc
lfs_t lfs;
lfsr_format(&lfs, CFG) => 0;
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
// set up a simulation to compare against
lfs_size_t *sim = malloc(N*sizeof(lfs_size_t));
@@ -5107,8 +5225,6 @@ defines.BADBLOCK_BEHAVIOR = [
'LFS_EMUBD_BADBLOCK_PROGNOOP',
'LFS_EMUBD_BADBLOCK_ERASENOOP',
]
# we need prog checking to detect read errors
defines.CHECK_PROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
code = '''
if (BADBLOCKS & 0x1) {
lfs_emubd_setwear(CFG, 0, 0xffffffff) => 0;
@@ -5133,7 +5249,7 @@ defines.BADBLOCK_BEHAVIOR = [
'LFS_EMUBD_BADBLOCK_ERASENOOP',
]
# we need prog checking to detect read errors
defines.CHECK_PROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
defines.CKPROGS = 'BADBLOCK_BEHAVIOR >= LFS_EMUBD_BADBLOCK_READERROR'
code = '''
lfs_t lfs;
lfsr_format(&lfs, CFG) => 0;
@@ -5145,7 +5261,10 @@ code = '''
lfs_emubd_setwear(CFG, 1, 0xffffffff) => 0;
}
lfsr_mount(&lfs, CFG) => 0;
lfsr_mount(&lfs,
LFS_M_RDWR
| ((CKPROGS) ? LFS_M_CKPROGS : 0),
CFG) => 0;
for (lfs_size_t i = 0;; i++) {
// this should eventually fail