Renamed traversal -> trv

- test_traversal -> test_trvs
- lfs3_traversal_t -> lfs3_trv_t
- lfs3_btraversal_t -> lfs3_btrv_t
- t -> trv
- bt -> btrv
- lfs3_traversal_* -> lfs3_trv_*
- lfs3_btraversal_* -> lfs3_btrv_*

The traversal type is becoming one of the more fundamental types in
littlefs, and if DIR and REG both get shortened names, it makes sense
for TRV to have one as well.

This also removes the temptation to use t for traversals, which is
probably an even worse name.

---

Note that lfs3_btree_traverse, lfs3_mtree_traverse, etc, remain
unaffected. This may change in the future, but it's interesting to note
that verbs seem to need much less typing than nouns.
This commit is contained in:
Christopher Haster
2025-07-18 17:46:16 -05:00
parent 4cea5af96f
commit 2586fe68a2
12 changed files with 1376 additions and 1376 deletions
+254 -254
View File
File diff suppressed because it is too large Load Diff
+14 -14
View File
@@ -108,7 +108,7 @@ enum lfs3_type {
// internally used types, don't use these // internally used types, don't use these
LFS3_type_BOOKMARK = 4, // Directory bookmark LFS3_type_BOOKMARK = 4, // Directory bookmark
LFS3_type_ORPHAN = 5, // An orphaned stickynote LFS3_type_ORPHAN = 5, // An orphaned stickynote
LFS3_type_TRAVERSAL = 6, // An open traversal object LFS3_type_TRV = 6, // An open traversal object
}; };
// File open flags // File open flags
@@ -757,20 +757,20 @@ typedef struct lfs3_dir {
lfs3_off_t pos; lfs3_off_t pos;
} lfs3_dir_t; } lfs3_dir_t;
typedef struct lfs3_btraversal { typedef struct lfs3_btrv {
lfs3_bid_t bid; lfs3_bid_t bid;
const lfs3_rbyd_t *branch; const lfs3_rbyd_t *branch;
lfs3_srid_t rid; lfs3_srid_t rid;
lfs3_rbyd_t rbyd; lfs3_rbyd_t rbyd;
} lfs3_btraversal_t; } lfs3_btrv_t;
// littlefs traversal type // littlefs traversal type
typedef struct lfs3_traversal { typedef struct lfs3_trv {
// mdir/bshrub/btree state, this also includes our traversal // mdir/bshrub/btree state, this also includes our traversal
// state machine // state machine
lfs3_bshrub_t b; lfs3_bshrub_t b;
// opened file state // opened file state
lfs3_handle_t *ht; lfs3_handle_t *htrv;
union { union {
// cycle detection state, only valid when traversing the mroot chain // cycle detection state, only valid when traversing the mroot chain
struct { struct {
@@ -779,16 +779,16 @@ typedef struct lfs3_traversal {
uint8_t power; uint8_t power;
} mtortoise; } mtortoise;
// btree traversal state // btree traversal state
lfs3_btraversal_t bt; lfs3_btrv_t btrv;
// graft traversal state // graft traversal state
lfs3_size_t gt; lfs3_size_t gtrv;
} u; } u;
// recalculate gcksum when traversing with ckmeta // recalculate gcksum when traversing with ckmeta
uint32_t gcksum; uint32_t gcksum;
// pending blocks, only used in lfs3_traversal_read // pending blocks, only used in lfs3_trv_read
lfs3_sblock_t blocks[2]; lfs3_sblock_t blocks[2];
} lfs3_traversal_t; } lfs3_trv_t;
// grm encoding: // grm encoding:
// .- -+- -+- -+- -+- -. mids: 2 leb128s <=2x5 bytes // .- -+- -+- -+- -+- -. mids: 2 leb128s <=2x5 bytes
@@ -886,7 +886,7 @@ typedef struct lfs3 {
// optional incremental gc state // optional incremental gc state
#ifdef LFS3_GC #ifdef LFS3_GC
struct { struct {
lfs3_traversal_t t; lfs3_trv_t trv;
} gc; } gc;
#endif #endif
} lfs3_t; } lfs3_t;
@@ -1241,13 +1241,13 @@ int lfs3_dir_rewind(lfs3_t *lfs3, lfs3_dir_t *dir);
// the filesystem. // the filesystem.
// //
// Returns a negative error code on failure. // Returns a negative error code on failure.
int lfs3_traversal_open(lfs3_t *lfs3, lfs3_traversal_t *t, uint32_t flags); int lfs3_trv_open(lfs3_t *lfs3, lfs3_trv_t *trv, uint32_t flags);
// Close a traversal // Close a traversal
// //
// Releases any allocated resources. // Releases any allocated resources.
// Returns a negative error code on failure. // Returns a negative error code on failure.
int lfs3_traversal_close(lfs3_t *lfs3, lfs3_traversal_t *t); int lfs3_trv_close(lfs3_t *lfs3, lfs3_trv_t *trv);
// Progress the traversal and read an entry // Progress the traversal and read an entry
// //
@@ -1255,13 +1255,13 @@ int lfs3_traversal_close(lfs3_t *lfs3, lfs3_traversal_t *t);
// //
// Returns 0 on success, LFS3_ERR_NOENT at the end of traversal, or a // Returns 0 on success, LFS3_ERR_NOENT at the end of traversal, or a
// negative error code on failure. // negative error code on failure.
int lfs3_traversal_read(lfs3_t *lfs3, lfs3_traversal_t *t, int lfs3_trv_read(lfs3_t *lfs3, lfs3_trv_t *trv,
struct lfs3_tinfo *tinfo); struct lfs3_tinfo *tinfo);
// Reset the traversal // Reset the traversal
// //
// Returns a negative error code on failure. // Returns a negative error code on failure.
int lfs3_traversal_rewind(lfs3_t *lfs3, lfs3_traversal_t *t); int lfs3_trv_rewind(lfs3_t *lfs3, lfs3_trv_t *trv);
/// Filesystem-level filesystem operations /// Filesystem-level filesystem operations
+9 -9
View File
@@ -180,8 +180,8 @@ code = '''
uint8_t *seen = malloc((BLOCK_COUNT+7)/8); uint8_t *seen = malloc((BLOCK_COUNT+7)/8);
memset(seen, 0, (BLOCK_COUNT+7)/8); memset(seen, 0, (BLOCK_COUNT+7)/8);
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_init(&t, lfs3_trv_init(&trv,
LFS3_T_RDONLY LFS3_T_RDONLY
| ((CKMETA) ? LFS3_T_CKMETA : 0)); | ((CKMETA) ? LFS3_T_CKMETA : 0));
for (lfs3_block_t i = 0;; i++) { for (lfs3_block_t i = 0;; i++) {
@@ -190,7 +190,7 @@ code = '''
lfs3_stag_t tag; lfs3_stag_t tag;
lfs3_bptr_t bptr; lfs3_bptr_t bptr;
tag = lfs3_mtree_traverse(&lfs3, &t, tag = lfs3_mtree_traverse(&lfs3, &trv,
&bptr); &bptr);
assert(tag >= 0 || tag == LFS3_ERR_NOENT); assert(tag >= 0 || tag == LFS3_ERR_NOENT);
if (tag == LFS3_ERR_NOENT) { if (tag == LFS3_ERR_NOENT) {
@@ -351,8 +351,8 @@ code = '''
uint8_t *seen = malloc((BLOCK_COUNT+7)/8); uint8_t *seen = malloc((BLOCK_COUNT+7)/8);
memset(seen, 0, (BLOCK_COUNT+7)/8); memset(seen, 0, (BLOCK_COUNT+7)/8);
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_init(&t, lfs3_trv_init(&trv,
LFS3_T_RDONLY LFS3_T_RDONLY
| ((CKMETA) ? LFS3_T_CKMETA : 0)); | ((CKMETA) ? LFS3_T_CKMETA : 0));
for (lfs3_block_t i = 0;; i++) { for (lfs3_block_t i = 0;; i++) {
@@ -361,7 +361,7 @@ code = '''
lfs3_stag_t tag; lfs3_stag_t tag;
lfs3_bptr_t bptr; lfs3_bptr_t bptr;
tag = lfs3_mtree_traverse(&lfs3, &t, tag = lfs3_mtree_traverse(&lfs3, &trv,
&bptr); &bptr);
assert(tag >= 0 || tag == LFS3_ERR_NOENT); assert(tag >= 0 || tag == LFS3_ERR_NOENT);
if (tag == LFS3_ERR_NOENT) { if (tag == LFS3_ERR_NOENT) {
@@ -508,8 +508,8 @@ code = '''
uint8_t *seen = malloc((BLOCK_COUNT+7)/8); uint8_t *seen = malloc((BLOCK_COUNT+7)/8);
memset(seen, 0, (BLOCK_COUNT+7)/8); memset(seen, 0, (BLOCK_COUNT+7)/8);
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_init(&t, lfs3_trv_init(&trv,
LFS3_T_RDONLY LFS3_T_RDONLY
| ((CKMETA) ? LFS3_T_CKMETA : 0)); | ((CKMETA) ? LFS3_T_CKMETA : 0));
for (lfs3_block_t i = 0;; i++) { for (lfs3_block_t i = 0;; i++) {
@@ -518,7 +518,7 @@ code = '''
lfs3_stag_t tag; lfs3_stag_t tag;
lfs3_bptr_t bptr; lfs3_bptr_t bptr;
tag = lfs3_mtree_traverse(&lfs3, &t, tag = lfs3_mtree_traverse(&lfs3, &trv,
&bptr); &bptr);
assert(tag >= 0 || tag == LFS3_ERR_NOENT); assert(tag >= 0 || tag == LFS3_ERR_NOENT);
if (tag == LFS3_ERR_NOENT) { if (tag == LFS3_ERR_NOENT) {
+1 -1
View File
@@ -4,7 +4,7 @@ after = [
'test_files', 'test_files',
'test_fwrite', 'test_fwrite',
'test_stickynotes', 'test_stickynotes',
'test_traversal', 'test_trvs',
'test_gc', 'test_gc',
'test_mount', 'test_mount',
'test_ck', 'test_ck',
+6 -6
View File
@@ -4305,8 +4305,8 @@ code = '''
uint8_t *seen = malloc((BLOCK_COUNT+7)/8); uint8_t *seen = malloc((BLOCK_COUNT+7)/8);
memset(seen, 0, (BLOCK_COUNT+7)/8); memset(seen, 0, (BLOCK_COUNT+7)/8);
lfs3_btraversal_t bt; lfs3_btrv_t btrv;
lfs3_btraversal_init(&bt); lfs3_btrv_init(&btrv);
for (lfs3_block_t i = 0;; i++) { for (lfs3_block_t i = 0;; i++) {
// a bit hacky, but this catches infinite loops // a bit hacky, but this catches infinite loops
assert(i <= 2*N); assert(i <= 2*N);
@@ -4315,7 +4315,7 @@ code = '''
lfs3_stag_t tag; lfs3_stag_t tag;
lfs3_bid_t weight; lfs3_bid_t weight;
lfs3_data_t data; lfs3_data_t data;
tag = lfs3_btree_traverse(&lfs3, &btree, &bt, tag = lfs3_btree_traverse(&lfs3, &btree, &btrv,
&bid, &weight, &data); &bid, &weight, &data);
assert(tag >= 0 || tag == LFS3_ERR_NOENT); assert(tag >= 0 || tag == LFS3_ERR_NOENT);
if (tag == LFS3_ERR_NOENT) { if (tag == LFS3_ERR_NOENT) {
@@ -4463,8 +4463,8 @@ code = '''
uint8_t *seen = malloc((BLOCK_COUNT+7)/8); uint8_t *seen = malloc((BLOCK_COUNT+7)/8);
memset(seen, 0, (BLOCK_COUNT+7)/8); memset(seen, 0, (BLOCK_COUNT+7)/8);
lfs3_btraversal_t bt; lfs3_btrv_t btrv;
lfs3_btraversal_init(&bt); lfs3_btrv_init(&btrv);
for (lfs3_block_t i = 0;; i++) { for (lfs3_block_t i = 0;; i++) {
// a bit hacky, but this catches infinite loops // a bit hacky, but this catches infinite loops
assert(i <= 2*N); assert(i <= 2*N);
@@ -4473,7 +4473,7 @@ code = '''
lfs3_stag_t tag; lfs3_stag_t tag;
lfs3_bid_t weight; lfs3_bid_t weight;
lfs3_data_t data; lfs3_data_t data;
tag = lfs3_btree_traverse(&lfs3, &btree, &bt, tag = lfs3_btree_traverse(&lfs3, &btree, &btrv,
&bid, &weight, &data); &bid, &weight, &data);
assert(tag >= 0 || tag == LFS3_ERR_NOENT); assert(tag >= 0 || tag == LFS3_ERR_NOENT);
if (tag == LFS3_ERR_NOENT) { if (tag == LFS3_ERR_NOENT) {
+116 -116
View File
@@ -1,5 +1,5 @@
# Test checksum validation things # Test checksum validation things
after = ['test_traversal', 'test_gc', 'test_mount'] after = ['test_trvs', 'test_gc', 'test_mount']
code = ''' code = '''
@@ -182,7 +182,7 @@ code = '''
[cases.test_ck_ckmeta_easy] [cases.test_ck_ckmeta_easy]
# METHOD=0 => lfs3_fs_ckmeta # METHOD=0 => lfs3_fs_ckmeta
# METHOD=1 => lfs3_fs_gc # METHOD=1 => lfs3_fs_gc
# METHOD=2 => lfs3_traversal_read # METHOD=2 => lfs3_trv_read
# METHOD=3 => lfs3_mount # METHOD=3 => lfs3_mount
defines.METHOD = [0, 1, 2, 3] defines.METHOD = [0, 1, 2, 3]
defines.GC_FLAGS = 'LFS3_GC_CKMETA' defines.GC_FLAGS = 'LFS3_GC_CKMETA'
@@ -230,17 +230,17 @@ code = '''
} }
// traverse to find blocks // traverse to find blocks
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, LFS3_T_RDONLY) => 0; lfs3_trv_open(&lfs3, &trv, LFS3_T_RDONLY) => 0;
lfs3_block_t k = 0; lfs3_block_t k = 0;
for (lfs3_block_t j = 0;; j++) { for (lfs3_block_t j = 0;; j++) {
assert(j < 2*BLOCK_COUNT); assert(j < 2*BLOCK_COUNT);
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(!err || err == LFS3_ERR_NOENT); assert(!err || err == LFS3_ERR_NOENT);
if (err == LFS3_ERR_NOENT) { if (err == LFS3_ERR_NOENT) {
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
lfs3_unmount(&lfs3) => 0; lfs3_unmount(&lfs3) => 0;
goto done; goto done;
} }
@@ -259,7 +259,7 @@ code = '''
clobber_buf, BLOCK_SIZE) => 0; clobber_buf, BLOCK_SIZE) => 0;
if (tinfo.btype != LFS3_BTYPE_MDIR || k == i+1) { if (tinfo.btype != LFS3_BTYPE_MDIR || k == i+1) {
i += (tinfo.btype == LFS3_BTYPE_MDIR) ? 2 : 1; i += (tinfo.btype == LFS3_BTYPE_MDIR) ? 2 : 1;
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
goto clobbered; goto clobbered;
} }
} }
@@ -280,22 +280,22 @@ code = '''
LFS3_UNREACHABLE(); LFS3_UNREACHABLE();
#endif #endif
// find clobbered blocks with lfs3_traversal_read // find clobbered blocks with lfs3_trv_read
} else if (METHOD == 2) { } else if (METHOD == 2) {
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, LFS3_T_RDONLY | LFS3_T_CKMETA) => 0; lfs3_trv_open(&lfs3, &trv, LFS3_T_RDONLY | LFS3_T_CKMETA) => 0;
for (lfs3_block_t i = 0;; i++) { for (lfs3_block_t i = 0;; i++) {
// a bit hacky, but this catches infinite loops // a bit hacky, but this catches infinite loops
LFS3_ASSERT(i < 2*BLOCK_COUNT); LFS3_ASSERT(i < 2*BLOCK_COUNT);
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(!err || err == LFS3_ERR_CORRUPT); assert(!err || err == LFS3_ERR_CORRUPT);
if (err == LFS3_ERR_CORRUPT) { if (err == LFS3_ERR_CORRUPT) {
break; break;
} }
} }
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
// find clobbered blocks with lfs3_mount // find clobbered blocks with lfs3_mount
} else if (METHOD == 3) { } else if (METHOD == 3) {
@@ -319,7 +319,7 @@ done:;
[cases.test_ck_ckdata_easy] [cases.test_ck_ckdata_easy]
# METHOD=0 => lfs3_fs_ckdata # METHOD=0 => lfs3_fs_ckdata
# METHOD=1 => lfs3_fs_gc # METHOD=1 => lfs3_fs_gc
# METHOD=2 => lfs3_traversal_read # METHOD=2 => lfs3_trv_read
# METHOD=3 => lfs3_mount # METHOD=3 => lfs3_mount
defines.METHOD = [0, 1, 2, 3] defines.METHOD = [0, 1, 2, 3]
defines.GC_FLAGS = 'LFS3_GC_CKDATA' defines.GC_FLAGS = 'LFS3_GC_CKDATA'
@@ -367,17 +367,17 @@ code = '''
} }
// traverse to find blocks // traverse to find blocks
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, LFS3_T_RDONLY) => 0; lfs3_trv_open(&lfs3, &trv, LFS3_T_RDONLY) => 0;
lfs3_block_t k = 0; lfs3_block_t k = 0;
for (lfs3_block_t j = 0;; j++) { for (lfs3_block_t j = 0;; j++) {
assert(j < 2*BLOCK_COUNT); assert(j < 2*BLOCK_COUNT);
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(!err || err == LFS3_ERR_NOENT); assert(!err || err == LFS3_ERR_NOENT);
if (err == LFS3_ERR_NOENT) { if (err == LFS3_ERR_NOENT) {
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
lfs3_unmount(&lfs3) => 0; lfs3_unmount(&lfs3) => 0;
goto done; goto done;
} }
@@ -397,7 +397,7 @@ code = '''
clobber_buf, BLOCK_SIZE) => 0; clobber_buf, BLOCK_SIZE) => 0;
if (tinfo.btype != LFS3_BTYPE_MDIR || k == i+1) { if (tinfo.btype != LFS3_BTYPE_MDIR || k == i+1) {
i += (tinfo.btype == LFS3_BTYPE_MDIR) ? 2 : 1; i += (tinfo.btype == LFS3_BTYPE_MDIR) ? 2 : 1;
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
goto clobbered; goto clobbered;
} }
} }
@@ -418,22 +418,22 @@ code = '''
LFS3_UNREACHABLE(); LFS3_UNREACHABLE();
#endif #endif
// find clobbered blocks with lfs3_traversal_read // find clobbered blocks with lfs3_trv_read
} else if (METHOD == 2) { } else if (METHOD == 2) {
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, LFS3_T_RDONLY | LFS3_T_CKDATA) => 0; lfs3_trv_open(&lfs3, &trv, LFS3_T_RDONLY | LFS3_T_CKDATA) => 0;
for (lfs3_block_t i = 0;; i++) { for (lfs3_block_t i = 0;; i++) {
// a bit hacky, but this catches infinite loops // a bit hacky, but this catches infinite loops
LFS3_ASSERT(i < 2*BLOCK_COUNT); LFS3_ASSERT(i < 2*BLOCK_COUNT);
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(!err || err == LFS3_ERR_CORRUPT); assert(!err || err == LFS3_ERR_CORRUPT);
if (err == LFS3_ERR_CORRUPT) { if (err == LFS3_ERR_CORRUPT) {
break; break;
} }
} }
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
// find clobbered blocks with lfs3_mount // find clobbered blocks with lfs3_mount
} else if (METHOD == 3) { } else if (METHOD == 3) {
@@ -458,7 +458,7 @@ done:;
[cases.test_ck_ckmeta_hard] [cases.test_ck_ckmeta_hard]
# METHOD=0 => lfs3_fs_ckmeta # METHOD=0 => lfs3_fs_ckmeta
# METHOD=1 => lfs3_fs_gc # METHOD=1 => lfs3_fs_gc
# METHOD=2 => lfs3_traversal_read # METHOD=2 => lfs3_trv_read
# METHOD=3 => lfs3_mount # METHOD=3 => lfs3_mount
defines.METHOD = [0, 1, 2, 3] defines.METHOD = [0, 1, 2, 3]
defines.GC_FLAGS = 'LFS3_GC_CKMETA' defines.GC_FLAGS = 'LFS3_GC_CKMETA'
@@ -509,18 +509,18 @@ code = '''
} }
// traverse to find blocks // traverse to find blocks
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, LFS3_T_RDONLY) => 0; lfs3_trv_open(&lfs3, &trv, LFS3_T_RDONLY) => 0;
lfs3_block_t k = 0; lfs3_block_t k = 0;
lfs3_block_t badblock; lfs3_block_t badblock;
for (lfs3_block_t j = 0;; j++) { for (lfs3_block_t j = 0;; j++) {
assert(j < 2*BLOCK_COUNT); assert(j < 2*BLOCK_COUNT);
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(!err || err == LFS3_ERR_NOENT); assert(!err || err == LFS3_ERR_NOENT);
if (err == LFS3_ERR_NOENT) { if (err == LFS3_ERR_NOENT) {
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
lfs3_unmount(&lfs3) => 0; lfs3_unmount(&lfs3) => 0;
goto done; goto done;
} }
@@ -530,7 +530,7 @@ code = '''
// found an interesting block? // found an interesting block?
if (k == i) { if (k == i) {
badblock = tinfo.block; badblock = tinfo.block;
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
goto clobber; goto clobber;
} }
k += 1; k += 1;
@@ -570,17 +570,17 @@ code = '''
LFS3_UNREACHABLE(); LFS3_UNREACHABLE();
#endif #endif
// find clobbered blocks with lfs3_traversal_read // find clobbered blocks with lfs3_trv_read
} else if (METHOD == 2) { } else if (METHOD == 2) {
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, lfs3_trv_open(&lfs3, &trv,
LFS3_T_RDONLY | LFS3_T_CKMETA) => 0; LFS3_T_RDONLY | LFS3_T_CKMETA) => 0;
for (lfs3_block_t i = 0;; i++) { for (lfs3_block_t i = 0;; i++) {
// a bit hacky, but this catches infinite loops // a bit hacky, but this catches infinite loops
LFS3_ASSERT(i < 2*BLOCK_COUNT); LFS3_ASSERT(i < 2*BLOCK_COUNT);
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(!err assert(!err
|| err == LFS3_ERR_NOENT || err == LFS3_ERR_NOENT
|| err == LFS3_ERR_CORRUPT); || err == LFS3_ERR_CORRUPT);
@@ -588,11 +588,11 @@ code = '''
break; break;
} }
if (err == LFS3_ERR_CORRUPT) { if (err == LFS3_ERR_CORRUPT) {
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
goto detected; goto detected;
} }
} }
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
// find clobbered blocks with lfs3_mount // find clobbered blocks with lfs3_mount
} else if (METHOD == 3) { } else if (METHOD == 3) {
@@ -713,7 +713,7 @@ done:;
[cases.test_ck_ckdata_hard] [cases.test_ck_ckdata_hard]
# METHOD=0 => lfs3_fs_ckdata # METHOD=0 => lfs3_fs_ckdata
# METHOD=1 => lfs3_fs_gc # METHOD=1 => lfs3_fs_gc
# METHOD=2 => lfs3_traversal_read # METHOD=2 => lfs3_trv_read
# METHOD=3 => lfs3_mount # METHOD=3 => lfs3_mount
defines.METHOD = [0, 1, 2, 3] defines.METHOD = [0, 1, 2, 3]
defines.GC_FLAGS = 'LFS3_GC_CKDATA' defines.GC_FLAGS = 'LFS3_GC_CKDATA'
@@ -764,18 +764,18 @@ code = '''
} }
// traverse to find blocks // traverse to find blocks
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, LFS3_T_RDONLY) => 0; lfs3_trv_open(&lfs3, &trv, LFS3_T_RDONLY) => 0;
lfs3_block_t k = 0; lfs3_block_t k = 0;
lfs3_block_t badblock; lfs3_block_t badblock;
for (lfs3_block_t j = 0;; j++) { for (lfs3_block_t j = 0;; j++) {
assert(j < 2*BLOCK_COUNT); assert(j < 2*BLOCK_COUNT);
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(!err || err == LFS3_ERR_NOENT); assert(!err || err == LFS3_ERR_NOENT);
if (err == LFS3_ERR_NOENT) { if (err == LFS3_ERR_NOENT) {
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
lfs3_unmount(&lfs3) => 0; lfs3_unmount(&lfs3) => 0;
goto done; goto done;
} }
@@ -786,7 +786,7 @@ code = '''
// found an interesting block? // found an interesting block?
if (k == i) { if (k == i) {
badblock = tinfo.block; badblock = tinfo.block;
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
goto clobber; goto clobber;
} }
k += 1; k += 1;
@@ -826,17 +826,17 @@ code = '''
LFS3_UNREACHABLE(); LFS3_UNREACHABLE();
#endif #endif
// find clobbered blocks with lfs3_traversal_read // find clobbered blocks with lfs3_trv_read
} else if (METHOD == 2) { } else if (METHOD == 2) {
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, lfs3_trv_open(&lfs3, &trv,
LFS3_T_RDONLY | LFS3_T_CKDATA) => 0; LFS3_T_RDONLY | LFS3_T_CKDATA) => 0;
for (lfs3_block_t i = 0;; i++) { for (lfs3_block_t i = 0;; i++) {
// a bit hacky, but this catches infinite loops // a bit hacky, but this catches infinite loops
LFS3_ASSERT(i < 2*BLOCK_COUNT); LFS3_ASSERT(i < 2*BLOCK_COUNT);
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(!err assert(!err
|| err == LFS3_ERR_NOENT || err == LFS3_ERR_NOENT
|| err == LFS3_ERR_CORRUPT); || err == LFS3_ERR_CORRUPT);
@@ -844,11 +844,11 @@ code = '''
break; break;
} }
if (err == LFS3_ERR_CORRUPT) { if (err == LFS3_ERR_CORRUPT) {
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
goto detected; goto detected;
} }
} }
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
// find clobbered blocks with lfs3_mount // find clobbered blocks with lfs3_mount
} else if (METHOD == 3) { } else if (METHOD == 3) {
@@ -1007,17 +1007,17 @@ code = '''
lfs3_file_write(&lfs3, &file, wbuf, SIZE) => SIZE; lfs3_file_write(&lfs3, &file, wbuf, SIZE) => SIZE;
// traverse to find blocks // traverse to find blocks
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, LFS3_T_RDONLY) => 0; lfs3_trv_open(&lfs3, &trv, LFS3_T_RDONLY) => 0;
lfs3_block_t k = 0; lfs3_block_t k = 0;
for (lfs3_block_t j = 0;; j++) { for (lfs3_block_t j = 0;; j++) {
assert(j < 2*BLOCK_COUNT); assert(j < 2*BLOCK_COUNT);
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(!err || err == LFS3_ERR_NOENT); assert(!err || err == LFS3_ERR_NOENT);
if (err == LFS3_ERR_NOENT) { if (err == LFS3_ERR_NOENT) {
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
lfs3_file_close(&lfs3, &file) => 0; lfs3_file_close(&lfs3, &file) => 0;
lfs3_unmount(&lfs3) => 0; lfs3_unmount(&lfs3) => 0;
goto done; goto done;
@@ -1032,7 +1032,7 @@ code = '''
CFG->erase(CFG, tinfo.block) => 0; CFG->erase(CFG, tinfo.block) => 0;
CFG->prog(CFG, tinfo.block, 0, CFG->prog(CFG, tinfo.block, 0,
clobber_buf, BLOCK_SIZE) => 0; clobber_buf, BLOCK_SIZE) => 0;
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
goto clobbered; goto clobbered;
} }
k += 1; k += 1;
@@ -1104,17 +1104,17 @@ code = '''
lfs3_file_write(&lfs3, &file, wbuf, SIZE) => SIZE; lfs3_file_write(&lfs3, &file, wbuf, SIZE) => SIZE;
// traverse to find blocks // traverse to find blocks
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, LFS3_T_RDONLY) => 0; lfs3_trv_open(&lfs3, &trv, LFS3_T_RDONLY) => 0;
lfs3_block_t k = 0; lfs3_block_t k = 0;
for (lfs3_block_t j = 0;; j++) { for (lfs3_block_t j = 0;; j++) {
assert(j < 2*BLOCK_COUNT); assert(j < 2*BLOCK_COUNT);
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(!err || err == LFS3_ERR_NOENT); assert(!err || err == LFS3_ERR_NOENT);
if (err == LFS3_ERR_NOENT) { if (err == LFS3_ERR_NOENT) {
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
lfs3_file_close(&lfs3, &file) => 0; lfs3_file_close(&lfs3, &file) => 0;
lfs3_unmount(&lfs3) => 0; lfs3_unmount(&lfs3) => 0;
goto done; goto done;
@@ -1130,7 +1130,7 @@ code = '''
CFG->erase(CFG, tinfo.block) => 0; CFG->erase(CFG, tinfo.block) => 0;
CFG->prog(CFG, tinfo.block, 0, CFG->prog(CFG, tinfo.block, 0,
clobber_buf, BLOCK_SIZE) => 0; clobber_buf, BLOCK_SIZE) => 0;
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
goto clobbered; goto clobbered;
} }
k += 1; k += 1;
@@ -1208,18 +1208,18 @@ code = '''
lfs3_file_write(&lfs3, &file, wbuf, SIZE) => SIZE; lfs3_file_write(&lfs3, &file, wbuf, SIZE) => SIZE;
// traverse to find blocks // traverse to find blocks
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, LFS3_T_RDONLY) => 0; lfs3_trv_open(&lfs3, &trv, LFS3_T_RDONLY) => 0;
lfs3_block_t k = 0; lfs3_block_t k = 0;
lfs3_block_t badblock; lfs3_block_t badblock;
for (lfs3_block_t j = 0;; j++) { for (lfs3_block_t j = 0;; j++) {
assert(j < 2*BLOCK_COUNT); assert(j < 2*BLOCK_COUNT);
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(!err || err == LFS3_ERR_NOENT); assert(!err || err == LFS3_ERR_NOENT);
if (err == LFS3_ERR_NOENT) { if (err == LFS3_ERR_NOENT) {
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
lfs3_file_close(&lfs3, &file) => 0; lfs3_file_close(&lfs3, &file) => 0;
lfs3_unmount(&lfs3) => 0; lfs3_unmount(&lfs3) => 0;
goto done; goto done;
@@ -1229,7 +1229,7 @@ code = '''
// found an interesting block? // found an interesting block?
if (k == i) { if (k == i) {
badblock = tinfo.block; badblock = tinfo.block;
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
goto clobber; goto clobber;
} }
k += 1; k += 1;
@@ -1356,18 +1356,18 @@ code = '''
lfs3_file_write(&lfs3, &file, wbuf, SIZE) => SIZE; lfs3_file_write(&lfs3, &file, wbuf, SIZE) => SIZE;
// traverse to find blocks // traverse to find blocks
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, LFS3_T_RDONLY) => 0; lfs3_trv_open(&lfs3, &trv, LFS3_T_RDONLY) => 0;
lfs3_block_t k = 0; lfs3_block_t k = 0;
lfs3_block_t badblock; lfs3_block_t badblock;
for (lfs3_block_t j = 0;; j++) { for (lfs3_block_t j = 0;; j++) {
assert(j < 2*BLOCK_COUNT); assert(j < 2*BLOCK_COUNT);
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(!err || err == LFS3_ERR_NOENT); assert(!err || err == LFS3_ERR_NOENT);
if (err == LFS3_ERR_NOENT) { if (err == LFS3_ERR_NOENT) {
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
lfs3_file_close(&lfs3, &file) => 0; lfs3_file_close(&lfs3, &file) => 0;
lfs3_unmount(&lfs3) => 0; lfs3_unmount(&lfs3) => 0;
goto done; goto done;
@@ -1378,7 +1378,7 @@ code = '''
// found an interesting block? // found an interesting block?
if (k == i) { if (k == i) {
badblock = tinfo.block; badblock = tinfo.block;
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
goto clobber; goto clobber;
} }
k += 1; k += 1;
@@ -1578,18 +1578,18 @@ code = '''
lfs3_file_close(&lfs3, &file) => 0; lfs3_file_close(&lfs3, &file) => 0;
// find the data block // find the data block
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, LFS3_T_RDONLY) => 0; lfs3_trv_open(&lfs3, &trv, LFS3_T_RDONLY) => 0;
lfs3_block_t badblock; lfs3_block_t badblock;
while (true) { while (true) {
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
lfs3_traversal_read(&lfs3, &t, &tinfo) => 0; lfs3_trv_read(&lfs3, &trv, &tinfo) => 0;
if (tinfo.btype == LFS3_BTYPE_DATA) { if (tinfo.btype == LFS3_BTYPE_DATA) {
badblock = tinfo.block; badblock = tinfo.block;
break; break;
} }
} }
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
lfs3_unmount(&lfs3) => 0; lfs3_unmount(&lfs3) => 0;
@@ -1689,18 +1689,18 @@ code = '''
lfs3_file_close(&lfs3, &file) => 0; lfs3_file_close(&lfs3, &file) => 0;
// find the btree block // find the btree block
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, LFS3_T_RDONLY) => 0; lfs3_trv_open(&lfs3, &trv, LFS3_T_RDONLY) => 0;
lfs3_block_t badblock; lfs3_block_t badblock;
while (true) { while (true) {
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
lfs3_traversal_read(&lfs3, &t, &tinfo) => 0; lfs3_trv_read(&lfs3, &trv, &tinfo) => 0;
if (tinfo.btype == LFS3_BTYPE_BTREE) { if (tinfo.btype == LFS3_BTYPE_BTREE) {
badblock = tinfo.block; badblock = tinfo.block;
break; break;
} }
} }
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
lfs3_unmount(&lfs3) => 0; lfs3_unmount(&lfs3) => 0;
@@ -2088,18 +2088,18 @@ code = '''
lfs3_file_close(&lfs3, &file) => 0; lfs3_file_close(&lfs3, &file) => 0;
// find the data block // find the data block
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, LFS3_T_RDONLY) => 0; lfs3_trv_open(&lfs3, &trv, LFS3_T_RDONLY) => 0;
lfs3_block_t badblock; lfs3_block_t badblock;
while (true) { while (true) {
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
lfs3_traversal_read(&lfs3, &t, &tinfo) => 0; lfs3_trv_read(&lfs3, &trv, &tinfo) => 0;
if (tinfo.btype == LFS3_BTYPE_DATA) { if (tinfo.btype == LFS3_BTYPE_DATA) {
badblock = tinfo.block; badblock = tinfo.block;
break; break;
} }
} }
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
lfs3_unmount(&lfs3) => 0; lfs3_unmount(&lfs3) => 0;
@@ -2199,18 +2199,18 @@ code = '''
lfs3_file_close(&lfs3, &file) => 0; lfs3_file_close(&lfs3, &file) => 0;
// find the btree block // find the btree block
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, LFS3_T_RDONLY) => 0; lfs3_trv_open(&lfs3, &trv, LFS3_T_RDONLY) => 0;
lfs3_block_t badblock; lfs3_block_t badblock;
while (true) { while (true) {
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
lfs3_traversal_read(&lfs3, &t, &tinfo) => 0; lfs3_trv_read(&lfs3, &trv, &tinfo) => 0;
if (tinfo.btype == LFS3_BTYPE_BTREE) { if (tinfo.btype == LFS3_BTYPE_BTREE) {
badblock = tinfo.block; badblock = tinfo.block;
break; break;
} }
} }
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
lfs3_unmount(&lfs3) => 0; lfs3_unmount(&lfs3) => 0;
@@ -2462,18 +2462,18 @@ code = '''
lfs3_file_close(&lfs3, &file) => 0; lfs3_file_close(&lfs3, &file) => 0;
// find the btree block // find the btree block
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, LFS3_T_RDONLY) => 0; lfs3_trv_open(&lfs3, &trv, LFS3_T_RDONLY) => 0;
lfs3_block_t badblock; lfs3_block_t badblock;
while (true) { while (true) {
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
lfs3_traversal_read(&lfs3, &t, &tinfo) => 0; lfs3_trv_read(&lfs3, &trv, &tinfo) => 0;
if (tinfo.btype == LFS3_BTYPE_BTREE) { if (tinfo.btype == LFS3_BTYPE_BTREE) {
badblock = tinfo.block; badblock = tinfo.block;
break; break;
} }
} }
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
lfs3_unmount(&lfs3) => 0; lfs3_unmount(&lfs3) => 0;
@@ -2606,18 +2606,18 @@ code = '''
lfs3_file_close(&lfs3, &file) => 0; lfs3_file_close(&lfs3, &file) => 0;
// find the data block // find the data block
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, LFS3_T_RDONLY) => 0; lfs3_trv_open(&lfs3, &trv, LFS3_T_RDONLY) => 0;
lfs3_block_t badblock; lfs3_block_t badblock;
while (true) { while (true) {
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
lfs3_traversal_read(&lfs3, &t, &tinfo) => 0; lfs3_trv_read(&lfs3, &trv, &tinfo) => 0;
if (tinfo.btype == LFS3_BTYPE_DATA) { if (tinfo.btype == LFS3_BTYPE_DATA) {
badblock = tinfo.block; badblock = tinfo.block;
break; break;
} }
} }
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
lfs3_unmount(&lfs3) => 0; lfs3_unmount(&lfs3) => 0;
@@ -2834,15 +2834,15 @@ code = '''
// run ckmeta mtreeonly? // run ckmeta mtreeonly?
} else if (CKMETA && MTREEONLY) { } else if (CKMETA && MTREEONLY) {
// need an explicit traversal for this // need an explicit traversal for this
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, lfs3_trv_open(&lfs3, &trv,
LFS3_T_RDONLY | LFS3_T_MTREEONLY | LFS3_T_CKMETA) => 0; LFS3_T_RDONLY | LFS3_T_MTREEONLY | LFS3_T_CKMETA) => 0;
for (lfs3_block_t i = 0;; i++) { for (lfs3_block_t i = 0;; i++) {
// a bit hacky, but this catches infinite loops // a bit hacky, but this catches infinite loops
LFS3_ASSERT(i < 2*BLOCK_COUNT); LFS3_ASSERT(i < 2*BLOCK_COUNT);
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(!err assert(!err
|| err == LFS3_ERR_NOENT || err == LFS3_ERR_NOENT
|| err == LFS3_ERR_CORRUPT); || err == LFS3_ERR_CORRUPT);
@@ -2850,11 +2850,11 @@ code = '''
break; break;
} }
if (err == LFS3_ERR_CORRUPT) { if (err == LFS3_ERR_CORRUPT) {
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
goto corrupt_mounted; goto corrupt_mounted;
} }
} }
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
} }
} }
@@ -3152,15 +3152,15 @@ code = '''
// run ckmeta mtreeonly? // run ckmeta mtreeonly?
} else if (CKMETA && MTREEONLY) { } else if (CKMETA && MTREEONLY) {
// need an explicit traversal for this // need an explicit traversal for this
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, lfs3_trv_open(&lfs3, &trv,
LFS3_T_RDONLY | LFS3_T_MTREEONLY | LFS3_T_CKMETA) => 0; LFS3_T_RDONLY | LFS3_T_MTREEONLY | LFS3_T_CKMETA) => 0;
for (lfs3_block_t i = 0;; i++) { for (lfs3_block_t i = 0;; i++) {
// a bit hacky, but this catches infinite loops // a bit hacky, but this catches infinite loops
LFS3_ASSERT(i < 2*BLOCK_COUNT); LFS3_ASSERT(i < 2*BLOCK_COUNT);
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(!err assert(!err
|| err == LFS3_ERR_NOENT || err == LFS3_ERR_NOENT
|| err == LFS3_ERR_CORRUPT); || err == LFS3_ERR_CORRUPT);
@@ -3168,11 +3168,11 @@ code = '''
break; break;
} }
if (err == LFS3_ERR_CORRUPT) { if (err == LFS3_ERR_CORRUPT) {
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
goto corrupt_mounted; goto corrupt_mounted;
} }
} }
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
} }
} }
@@ -3568,15 +3568,15 @@ code = '''
// run ckmeta mtreeonly? // run ckmeta mtreeonly?
} else if (CKMETA && MTREEONLY) { } else if (CKMETA && MTREEONLY) {
// need an explicit traversal for this // need an explicit traversal for this
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, lfs3_trv_open(&lfs3, &trv,
LFS3_T_RDONLY | LFS3_T_MTREEONLY | LFS3_T_CKMETA) => 0; LFS3_T_RDONLY | LFS3_T_MTREEONLY | LFS3_T_CKMETA) => 0;
for (lfs3_block_t i = 0;; i++) { for (lfs3_block_t i = 0;; i++) {
// a bit hacky, but this catches infinite loops // a bit hacky, but this catches infinite loops
LFS3_ASSERT(i < 2*BLOCK_COUNT); LFS3_ASSERT(i < 2*BLOCK_COUNT);
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(!err assert(!err
|| err == LFS3_ERR_NOENT || err == LFS3_ERR_NOENT
|| err == LFS3_ERR_CORRUPT); || err == LFS3_ERR_CORRUPT);
@@ -3584,11 +3584,11 @@ code = '''
break; break;
} }
if (err == LFS3_ERR_CORRUPT) { if (err == LFS3_ERR_CORRUPT) {
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
goto corrupt_open; goto corrupt_open;
} }
} }
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
} }
} }
@@ -3851,15 +3851,15 @@ code = '''
// run ckmeta mtreeonly? // run ckmeta mtreeonly?
} else if (CKMETA && MTREEONLY) { } else if (CKMETA && MTREEONLY) {
// need an explicit traversal for this // need an explicit traversal for this
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, lfs3_trv_open(&lfs3, &trv,
LFS3_T_RDONLY | LFS3_T_MTREEONLY | LFS3_T_CKMETA) => 0; LFS3_T_RDONLY | LFS3_T_MTREEONLY | LFS3_T_CKMETA) => 0;
for (lfs3_block_t i = 0;; i++) { for (lfs3_block_t i = 0;; i++) {
// a bit hacky, but this catches infinite loops // a bit hacky, but this catches infinite loops
LFS3_ASSERT(i < 2*BLOCK_COUNT); LFS3_ASSERT(i < 2*BLOCK_COUNT);
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(!err assert(!err
|| err == LFS3_ERR_NOENT || err == LFS3_ERR_NOENT
|| err == LFS3_ERR_CORRUPT); || err == LFS3_ERR_CORRUPT);
@@ -3867,11 +3867,11 @@ code = '''
break; break;
} }
if (err == LFS3_ERR_CORRUPT) { if (err == LFS3_ERR_CORRUPT) {
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
goto corrupt_mounted; goto corrupt_mounted;
} }
} }
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
} }
} }
@@ -4451,15 +4451,15 @@ code = '''
// run ckmeta mtreeonly? // run ckmeta mtreeonly?
} else if (CKMETA && MTREEONLY) { } else if (CKMETA && MTREEONLY) {
// need an explicit traversal for this // need an explicit traversal for this
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, lfs3_trv_open(&lfs3, &trv,
LFS3_T_RDONLY | LFS3_T_MTREEONLY | LFS3_T_CKMETA) => 0; LFS3_T_RDONLY | LFS3_T_MTREEONLY | LFS3_T_CKMETA) => 0;
for (lfs3_block_t i = 0;; i++) { for (lfs3_block_t i = 0;; i++) {
// a bit hacky, but this catches infinite loops // a bit hacky, but this catches infinite loops
LFS3_ASSERT(i < 2*BLOCK_COUNT); LFS3_ASSERT(i < 2*BLOCK_COUNT);
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(!err assert(!err
|| err == LFS3_ERR_NOENT || err == LFS3_ERR_NOENT
|| err == LFS3_ERR_CORRUPT); || err == LFS3_ERR_CORRUPT);
@@ -4467,11 +4467,11 @@ code = '''
break; break;
} }
if (err == LFS3_ERR_CORRUPT) { if (err == LFS3_ERR_CORRUPT) {
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
goto corrupt_mounted; goto corrupt_mounted;
} }
} }
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
} }
} }
+30 -30
View File
@@ -183,8 +183,8 @@ code = '''
lfs3_size_t fragments = 0; lfs3_size_t fragments = 0;
lfs3_file_open(&lfs3, &file, "hello", LFS3_O_RDONLY) => 0; lfs3_file_open(&lfs3, &file, "hello", LFS3_O_RDONLY) => 0;
lfs3_btraversal_t bt; lfs3_btrv_t btrv;
lfs3_btraversal_init(&bt); lfs3_btrv_init(&btrv);
for (lfs3_block_t i = 0;; i++) { for (lfs3_block_t i = 0;; i++) {
// a bit hacky, but this catches infinite loops // a bit hacky, but this catches infinite loops
assert(i < 2*BLOCK_COUNT); assert(i < 2*BLOCK_COUNT);
@@ -193,7 +193,7 @@ code = '''
lfs3_stag_t tag; lfs3_stag_t tag;
lfs3_bid_t weight; lfs3_bid_t weight;
lfs3_data_t data; lfs3_data_t data;
tag = lfs3_bshrub_traverse(&lfs3, &file.b, &bt, tag = lfs3_bshrub_traverse(&lfs3, &file.b, &btrv,
&bid, &weight, &data); &bid, &weight, &data);
assert(tag >= 0 || tag == LFS3_ERR_NOENT); assert(tag >= 0 || tag == LFS3_ERR_NOENT);
if (tag == LFS3_ERR_NOENT) { if (tag == LFS3_ERR_NOENT) {
@@ -331,8 +331,8 @@ code = '''
lfs3_block_t blocks = 0; lfs3_block_t blocks = 0;
lfs3_file_open(&lfs3, &file, "hello", LFS3_O_RDONLY) => 0; lfs3_file_open(&lfs3, &file, "hello", LFS3_O_RDONLY) => 0;
lfs3_btraversal_t bt; lfs3_btrv_t btrv;
lfs3_btraversal_init(&bt); lfs3_btrv_init(&btrv);
for (lfs3_block_t i = 0;; i++) { for (lfs3_block_t i = 0;; i++) {
// a bit hacky, but this catches infinite loops // a bit hacky, but this catches infinite loops
assert(i < 2*BLOCK_COUNT); assert(i < 2*BLOCK_COUNT);
@@ -341,7 +341,7 @@ code = '''
lfs3_stag_t tag; lfs3_stag_t tag;
lfs3_bid_t weight; lfs3_bid_t weight;
lfs3_data_t data; lfs3_data_t data;
tag = lfs3_bshrub_traverse(&lfs3, &file.b, &bt, tag = lfs3_bshrub_traverse(&lfs3, &file.b, &btrv,
&bid, &weight, &data); &bid, &weight, &data);
assert(tag >= 0 || tag == LFS3_ERR_NOENT); assert(tag >= 0 || tag == LFS3_ERR_NOENT);
if (tag == LFS3_ERR_NOENT) { if (tag == LFS3_ERR_NOENT) {
@@ -597,8 +597,8 @@ code = '''
lfs3_size_t fragments = 0; lfs3_size_t fragments = 0;
lfs3_file_open(&lfs3, &file, "hello", LFS3_O_RDONLY) => 0; lfs3_file_open(&lfs3, &file, "hello", LFS3_O_RDONLY) => 0;
lfs3_btraversal_t bt; lfs3_btrv_t btrv;
lfs3_btraversal_init(&bt); lfs3_btrv_init(&btrv);
for (lfs3_block_t i = 0;; i++) { for (lfs3_block_t i = 0;; i++) {
// a bit hacky, but this catches infinite loops // a bit hacky, but this catches infinite loops
assert(i < 2*BLOCK_COUNT); assert(i < 2*BLOCK_COUNT);
@@ -607,7 +607,7 @@ code = '''
lfs3_stag_t tag; lfs3_stag_t tag;
lfs3_bid_t weight; lfs3_bid_t weight;
lfs3_data_t data; lfs3_data_t data;
tag = lfs3_bshrub_traverse(&lfs3, &file.b, &bt, tag = lfs3_bshrub_traverse(&lfs3, &file.b, &btrv,
&bid, &weight, &data); &bid, &weight, &data);
assert(tag >= 0 || tag == LFS3_ERR_NOENT); assert(tag >= 0 || tag == LFS3_ERR_NOENT);
if (tag == LFS3_ERR_NOENT) { if (tag == LFS3_ERR_NOENT) {
@@ -760,8 +760,8 @@ code = '''
lfs3_block_t blocks = 0; lfs3_block_t blocks = 0;
lfs3_file_open(&lfs3, &file, "hello", LFS3_O_RDONLY) => 0; lfs3_file_open(&lfs3, &file, "hello", LFS3_O_RDONLY) => 0;
lfs3_btraversal_t bt; lfs3_btrv_t btrv;
lfs3_btraversal_init(&bt); lfs3_btrv_init(&btrv);
for (lfs3_block_t i = 0;; i++) { for (lfs3_block_t i = 0;; i++) {
// a bit hacky, but this catches infinite loops // a bit hacky, but this catches infinite loops
assert(i < 2*BLOCK_COUNT); assert(i < 2*BLOCK_COUNT);
@@ -770,7 +770,7 @@ code = '''
lfs3_stag_t tag; lfs3_stag_t tag;
lfs3_bid_t weight; lfs3_bid_t weight;
lfs3_data_t data; lfs3_data_t data;
tag = lfs3_bshrub_traverse(&lfs3, &file.b, &bt, tag = lfs3_bshrub_traverse(&lfs3, &file.b, &btrv,
&bid, &weight, &data); &bid, &weight, &data);
assert(tag >= 0 || tag == LFS3_ERR_NOENT); assert(tag >= 0 || tag == LFS3_ERR_NOENT);
if (tag == LFS3_ERR_NOENT) { if (tag == LFS3_ERR_NOENT) {
@@ -2088,8 +2088,8 @@ code = '''
lfs3_size_t fragments = 0; lfs3_size_t fragments = 0;
lfs3_file_open(&lfs3, &file, "hello", LFS3_O_RDONLY) => 0; lfs3_file_open(&lfs3, &file, "hello", LFS3_O_RDONLY) => 0;
lfs3_btraversal_t bt; lfs3_btrv_t btrv;
lfs3_btraversal_init(&bt); lfs3_btrv_init(&btrv);
for (lfs3_block_t i = 0;; i++) { for (lfs3_block_t i = 0;; i++) {
// a bit hacky, but this catches infinite loops // a bit hacky, but this catches infinite loops
assert(i < 2*BLOCK_COUNT); assert(i < 2*BLOCK_COUNT);
@@ -2098,7 +2098,7 @@ code = '''
lfs3_stag_t tag; lfs3_stag_t tag;
lfs3_bid_t weight; lfs3_bid_t weight;
lfs3_data_t data; lfs3_data_t data;
tag = lfs3_bshrub_traverse(&lfs3, &file.b, &bt, tag = lfs3_bshrub_traverse(&lfs3, &file.b, &btrv,
&bid, &weight, &data); &bid, &weight, &data);
assert(tag >= 0 || tag == LFS3_ERR_NOENT); assert(tag >= 0 || tag == LFS3_ERR_NOENT);
if (tag == LFS3_ERR_NOENT) { if (tag == LFS3_ERR_NOENT) {
@@ -2240,8 +2240,8 @@ code = '''
lfs3_size_t fragments = 0; lfs3_size_t fragments = 0;
lfs3_file_open(&lfs3, &file, "hello", LFS3_O_RDONLY) => 0; lfs3_file_open(&lfs3, &file, "hello", LFS3_O_RDONLY) => 0;
lfs3_btraversal_t bt; lfs3_btrv_t btrv;
lfs3_btraversal_init(&bt); lfs3_btrv_init(&btrv);
for (lfs3_block_t i = 0;; i++) { for (lfs3_block_t i = 0;; i++) {
// a bit hacky, but this catches infinite loops // a bit hacky, but this catches infinite loops
assert(i < 2*BLOCK_COUNT); assert(i < 2*BLOCK_COUNT);
@@ -2250,7 +2250,7 @@ code = '''
lfs3_stag_t tag; lfs3_stag_t tag;
lfs3_bid_t weight; lfs3_bid_t weight;
lfs3_data_t data; lfs3_data_t data;
tag = lfs3_bshrub_traverse(&lfs3, &file.b, &bt, tag = lfs3_bshrub_traverse(&lfs3, &file.b, &btrv,
&bid, &weight, &data); &bid, &weight, &data);
assert(tag >= 0 || tag == LFS3_ERR_NOENT); assert(tag >= 0 || tag == LFS3_ERR_NOENT);
if (tag == LFS3_ERR_NOENT) { if (tag == LFS3_ERR_NOENT) {
@@ -2539,8 +2539,8 @@ code = '''
lfs3_size_t fragments = 0; lfs3_size_t fragments = 0;
lfs3_file_open(&lfs3, &file, "hello", LFS3_O_RDONLY) => 0; lfs3_file_open(&lfs3, &file, "hello", LFS3_O_RDONLY) => 0;
lfs3_btraversal_t bt; lfs3_btrv_t btrv;
lfs3_btraversal_init(&bt); lfs3_btrv_init(&btrv);
for (lfs3_block_t i = 0;; i++) { for (lfs3_block_t i = 0;; i++) {
// a bit hacky, but this catches infinite loops // a bit hacky, but this catches infinite loops
assert(i < 2*BLOCK_COUNT); assert(i < 2*BLOCK_COUNT);
@@ -2549,7 +2549,7 @@ code = '''
lfs3_stag_t tag; lfs3_stag_t tag;
lfs3_bid_t weight; lfs3_bid_t weight;
lfs3_data_t data; lfs3_data_t data;
tag = lfs3_bshrub_traverse(&lfs3, &file.b, &bt, tag = lfs3_bshrub_traverse(&lfs3, &file.b, &btrv,
&bid, &weight, &data); &bid, &weight, &data);
assert(tag >= 0 || tag == LFS3_ERR_NOENT); assert(tag >= 0 || tag == LFS3_ERR_NOENT);
if (tag == LFS3_ERR_NOENT) { if (tag == LFS3_ERR_NOENT) {
@@ -2706,8 +2706,8 @@ code = '''
lfs3_block_t blocks = 0; lfs3_block_t blocks = 0;
lfs3_file_open(&lfs3, &file, "hello", LFS3_O_RDONLY) => 0; lfs3_file_open(&lfs3, &file, "hello", LFS3_O_RDONLY) => 0;
lfs3_btraversal_t bt; lfs3_btrv_t btrv;
lfs3_btraversal_init(&bt); lfs3_btrv_init(&btrv);
for (lfs3_block_t i = 0;; i++) { for (lfs3_block_t i = 0;; i++) {
// a bit hacky, but this catches infinite loops // a bit hacky, but this catches infinite loops
assert(i < 2*BLOCK_COUNT); assert(i < 2*BLOCK_COUNT);
@@ -2716,7 +2716,7 @@ code = '''
lfs3_stag_t tag; lfs3_stag_t tag;
lfs3_bid_t weight; lfs3_bid_t weight;
lfs3_data_t data; lfs3_data_t data;
tag = lfs3_bshrub_traverse(&lfs3, &file.b, &bt, tag = lfs3_bshrub_traverse(&lfs3, &file.b, &btrv,
&bid, &weight, &data); &bid, &weight, &data);
assert(tag >= 0 || tag == LFS3_ERR_NOENT); assert(tag >= 0 || tag == LFS3_ERR_NOENT);
if (tag == LFS3_ERR_NOENT) { if (tag == LFS3_ERR_NOENT) {
@@ -2999,8 +2999,8 @@ code = '''
lfs3_size_t fragments = 0; lfs3_size_t fragments = 0;
lfs3_file_open(&lfs3, &file, "hello", LFS3_O_RDONLY) => 0; lfs3_file_open(&lfs3, &file, "hello", LFS3_O_RDONLY) => 0;
lfs3_btraversal_t bt; lfs3_btrv_t btrv;
lfs3_btraversal_init(&bt); lfs3_btrv_init(&btrv);
for (lfs3_block_t i = 0;; i++) { for (lfs3_block_t i = 0;; i++) {
// a bit hacky, but this catches infinite loops // a bit hacky, but this catches infinite loops
assert(i < 2*BLOCK_COUNT); assert(i < 2*BLOCK_COUNT);
@@ -3009,7 +3009,7 @@ code = '''
lfs3_stag_t tag; lfs3_stag_t tag;
lfs3_bid_t weight; lfs3_bid_t weight;
lfs3_data_t data; lfs3_data_t data;
tag = lfs3_bshrub_traverse(&lfs3, &file.b, &bt, tag = lfs3_bshrub_traverse(&lfs3, &file.b, &btrv,
&bid, &weight, &data); &bid, &weight, &data);
assert(tag >= 0 || tag == LFS3_ERR_NOENT); assert(tag >= 0 || tag == LFS3_ERR_NOENT);
if (tag == LFS3_ERR_NOENT) { if (tag == LFS3_ERR_NOENT) {
@@ -3170,8 +3170,8 @@ code = '''
lfs3_block_t blocks = 0; lfs3_block_t blocks = 0;
lfs3_file_open(&lfs3, &file, "hello", LFS3_O_RDONLY) => 0; lfs3_file_open(&lfs3, &file, "hello", LFS3_O_RDONLY) => 0;
lfs3_btraversal_t bt; lfs3_btrv_t btrv;
lfs3_btraversal_init(&bt); lfs3_btrv_init(&btrv);
for (lfs3_block_t i = 0;; i++) { for (lfs3_block_t i = 0;; i++) {
// a bit hacky, but this catches infinite loops // a bit hacky, but this catches infinite loops
assert(i < 2*BLOCK_COUNT); assert(i < 2*BLOCK_COUNT);
@@ -3180,7 +3180,7 @@ code = '''
lfs3_stag_t tag; lfs3_stag_t tag;
lfs3_bid_t weight; lfs3_bid_t weight;
lfs3_data_t data; lfs3_data_t data;
tag = lfs3_bshrub_traverse(&lfs3, &file.b, &bt, tag = lfs3_bshrub_traverse(&lfs3, &file.b, &btrv,
&bid, &weight, &data); &bid, &weight, &data);
assert(tag >= 0 || tag == LFS3_ERR_NOENT); assert(tag >= 0 || tag == LFS3_ERR_NOENT);
if (tag == LFS3_ERR_NOENT) { if (tag == LFS3_ERR_NOENT) {
+99 -99
View File
@@ -1,8 +1,8 @@
# Test GC things # Test GC things
# most of the GC logic is tested in test_traversal, we just test # most of the GC logic is tested in test_trvs, we just test
# GC-API specific things here # GC-API specific things here
after = ['test_traversal'] after = ['test_trvs']
# test that lookahead can make progress in isolation # test that lookahead can make progress in isolation
[cases.test_gc_lookahead_progress] [cases.test_gc_lookahead_progress]
@@ -45,7 +45,7 @@ code = '''
struct lfs3_fsinfo fsinfo; struct lfs3_fsinfo fsinfo;
lfs3_fs_stat(&lfs3, &fsinfo) => 0; lfs3_fs_stat(&lfs3, &fsinfo) => 0;
assert(fsinfo.flags & LFS3_I_LOOKAHEAD); assert(fsinfo.flags & LFS3_I_LOOKAHEAD);
assert(lfs3.handles != &lfs3.gc.t.b.h); assert(lfs3.handles != &lfs3.gc.trv.b.h);
// run GC until we make progress // run GC until we make progress
for (lfs3_block_t i = 0;; i++) { for (lfs3_block_t i = 0;; i++) {
@@ -112,11 +112,11 @@ code = '''
struct lfs3_fsinfo fsinfo; struct lfs3_fsinfo fsinfo;
lfs3_fs_stat(&lfs3, &fsinfo) => 0; lfs3_fs_stat(&lfs3, &fsinfo) => 0;
assert(fsinfo.flags & LFS3_I_LOOKAHEAD); assert(fsinfo.flags & LFS3_I_LOOKAHEAD);
assert(lfs3.handles != &lfs3.gc.t.b.h); assert(lfs3.handles != &lfs3.gc.trv.b.h);
// run GC one step // run GC one step
lfs3_fs_gc(&lfs3) => 0; lfs3_fs_gc(&lfs3) => 0;
assert(lfs3.handles == &lfs3.gc.t.b.h); assert(lfs3.handles == &lfs3.gc.trv.b.h);
// mutate the filesystem // mutate the filesystem
lfs3_file_open(&lfs3, &file, "spider", lfs3_file_open(&lfs3, &file, "spider",
@@ -128,7 +128,7 @@ code = '''
lfs3_file_close(&lfs3, &file) => 0; lfs3_file_close(&lfs3, &file) => 0;
// run GC until our traversal is done // run GC until our traversal is done
while (lfs3.handles == &lfs3.gc.t.b.h) { while (lfs3.handles == &lfs3.gc.trv.b.h) {
lfs3_fs_gc(&lfs3) => 0; lfs3_fs_gc(&lfs3) => 0;
} }
@@ -197,7 +197,7 @@ code = '''
struct lfs3_fsinfo fsinfo; struct lfs3_fsinfo fsinfo;
lfs3_fs_stat(&lfs3, &fsinfo) => 0; lfs3_fs_stat(&lfs3, &fsinfo) => 0;
assert(fsinfo.flags & LFS3_I_COMPACT); assert(fsinfo.flags & LFS3_I_COMPACT);
assert(lfs3.handles != &lfs3.gc.t.b.h); assert(lfs3.handles != &lfs3.gc.trv.b.h);
// run GC until we make progress // run GC until we make progress
for (lfs3_block_t i = 0;; i++) { for (lfs3_block_t i = 0;; i++) {
@@ -286,19 +286,19 @@ code = '''
struct lfs3_fsinfo fsinfo; struct lfs3_fsinfo fsinfo;
lfs3_fs_stat(&lfs3, &fsinfo) => 0; lfs3_fs_stat(&lfs3, &fsinfo) => 0;
assert(fsinfo.flags & LFS3_I_COMPACT); assert(fsinfo.flags & LFS3_I_COMPACT);
assert(lfs3.handles != &lfs3.gc.t.b.h); assert(lfs3.handles != &lfs3.gc.trv.b.h);
// run GC one traversal + one step // run GC one traversal + one step
while (true) { while (true) {
lfs3_fs_gc(&lfs3) => 0; lfs3_fs_gc(&lfs3) => 0;
// internal traversal done? // internal traversal done?
if (lfs3.handles != &lfs3.gc.t.b.h) { if (lfs3.handles != &lfs3.gc.trv.b.h) {
break; break;
} }
} }
lfs3_fs_gc(&lfs3) => 0; lfs3_fs_gc(&lfs3) => 0;
assert(lfs3.handles == &lfs3.gc.t.b.h); assert(lfs3.handles == &lfs3.gc.trv.b.h);
// mutate the filesystem // mutate the filesystem
lfs3_file_rewind(&lfs3, &file) => 0; lfs3_file_rewind(&lfs3, &file) => 0;
@@ -309,7 +309,7 @@ code = '''
lfs3_file_sync(&lfs3, &file) => 0; lfs3_file_sync(&lfs3, &file) => 0;
// run GC until our traversal is done (twice for compact) // run GC until our traversal is done (twice for compact)
while (lfs3.handles == &lfs3.gc.t.b.h) { while (lfs3.handles == &lfs3.gc.trv.b.h) {
lfs3_fs_gc(&lfs3) => 0; lfs3_fs_gc(&lfs3) => 0;
} }
@@ -410,7 +410,7 @@ code = '''
struct lfs3_fsinfo fsinfo; struct lfs3_fsinfo fsinfo;
lfs3_fs_stat(&lfs3, &fsinfo) => 0; lfs3_fs_stat(&lfs3, &fsinfo) => 0;
assert(fsinfo.flags & LFS3_I_MKCONSISTENT); assert(fsinfo.flags & LFS3_I_MKCONSISTENT);
assert(lfs3.handles != &lfs3.gc.t.b.h); assert(lfs3.handles != &lfs3.gc.trv.b.h);
// run GC until we make progress // run GC until we make progress
for (lfs3_block_t i = 0;; i++) { for (lfs3_block_t i = 0;; i++) {
@@ -513,7 +513,7 @@ code = '''
lfs3_fs_stat(&lfs3, &fsinfo) => 0; lfs3_fs_stat(&lfs3, &fsinfo) => 0;
assert(fsinfo.flags & LFS3_I_MKCONSISTENT); assert(fsinfo.flags & LFS3_I_MKCONSISTENT);
#ifdef LFS3_GC #ifdef LFS3_GC
assert(lfs3.handles != &lfs3.gc.t.b.h); assert(lfs3.handles != &lfs3.gc.trv.b.h);
#endif #endif
// call lfs3_fs_mkconsistent // call lfs3_fs_mkconsistent
@@ -614,9 +614,9 @@ code = '''
} }
// run GC one step // run GC one step
assert(lfs3.handles != &lfs3.gc.t.b.h); assert(lfs3.handles != &lfs3.gc.trv.b.h);
lfs3_fs_gc(&lfs3) => 0; lfs3_fs_gc(&lfs3) => 0;
assert(lfs3.handles == &lfs3.gc.t.b.h); assert(lfs3.handles == &lfs3.gc.trv.b.h);
// create the rest of the orphans after GC has started // create the rest of the orphans after GC has started
for (lfs3_size_t i = 0; i < ORPHANS; i++) { for (lfs3_size_t i = 0; i < ORPHANS; i++) {
@@ -638,7 +638,7 @@ code = '''
assert(fsinfo.flags & LFS3_I_MKCONSISTENT); assert(fsinfo.flags & LFS3_I_MKCONSISTENT);
// run GC until our traversal is done // run GC until our traversal is done
while (lfs3.handles == &lfs3.gc.t.b.h) { while (lfs3.handles == &lfs3.gc.trv.b.h) {
lfs3_fs_gc(&lfs3) => 0; lfs3_fs_gc(&lfs3) => 0;
} }
@@ -721,17 +721,17 @@ code = '''
} }
// traverse to find blocks // traverse to find blocks
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, LFS3_T_RDONLY) => 0; lfs3_trv_open(&lfs3, &trv, LFS3_T_RDONLY) => 0;
lfs3_block_t k = 0; lfs3_block_t k = 0;
for (lfs3_block_t j = 0;; j++) { for (lfs3_block_t j = 0;; j++) {
assert(j < 2*BLOCK_COUNT); assert(j < 2*BLOCK_COUNT);
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(!err || err == LFS3_ERR_NOENT); assert(!err || err == LFS3_ERR_NOENT);
if (err == LFS3_ERR_NOENT) { if (err == LFS3_ERR_NOENT) {
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
lfs3_unmount(&lfs3) => 0; lfs3_unmount(&lfs3) => 0;
goto done; goto done;
} }
@@ -750,7 +750,7 @@ code = '''
clobber_buf, BLOCK_SIZE) => 0; clobber_buf, BLOCK_SIZE) => 0;
if (tinfo.btype != LFS3_BTYPE_MDIR || k == i+1) { if (tinfo.btype != LFS3_BTYPE_MDIR || k == i+1) {
i += (tinfo.btype == LFS3_BTYPE_MDIR) ? 2 : 1; i += (tinfo.btype == LFS3_BTYPE_MDIR) ? 2 : 1;
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
goto clobbered; goto clobbered;
} }
} }
@@ -821,17 +821,17 @@ code = '''
} }
// traverse to find blocks // traverse to find blocks
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, LFS3_T_RDONLY) => 0; lfs3_trv_open(&lfs3, &trv, LFS3_T_RDONLY) => 0;
lfs3_block_t k = 0; lfs3_block_t k = 0;
for (lfs3_block_t j = 0;; j++) { for (lfs3_block_t j = 0;; j++) {
assert(j < 2*BLOCK_COUNT); assert(j < 2*BLOCK_COUNT);
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(!err || err == LFS3_ERR_NOENT); assert(!err || err == LFS3_ERR_NOENT);
if (err == LFS3_ERR_NOENT) { if (err == LFS3_ERR_NOENT) {
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
lfs3_unmount(&lfs3) => 0; lfs3_unmount(&lfs3) => 0;
goto done; goto done;
} }
@@ -851,7 +851,7 @@ code = '''
clobber_buf, BLOCK_SIZE) => 0; clobber_buf, BLOCK_SIZE) => 0;
if (tinfo.btype != LFS3_BTYPE_MDIR || k == i+1) { if (tinfo.btype != LFS3_BTYPE_MDIR || k == i+1) {
i += (tinfo.btype == LFS3_BTYPE_MDIR) ? 2 : 1; i += (tinfo.btype == LFS3_BTYPE_MDIR) ? 2 : 1;
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
goto clobbered; goto clobbered;
} }
} }
@@ -923,17 +923,17 @@ code = '''
} }
// traverse to find blocks // traverse to find blocks
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, LFS3_T_RDONLY) => 0; lfs3_trv_open(&lfs3, &trv, LFS3_T_RDONLY) => 0;
lfs3_block_t k = 0; lfs3_block_t k = 0;
for (lfs3_block_t j = 0;; j++) { for (lfs3_block_t j = 0;; j++) {
assert(j < 2*BLOCK_COUNT); assert(j < 2*BLOCK_COUNT);
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(!err || err == LFS3_ERR_NOENT); assert(!err || err == LFS3_ERR_NOENT);
if (err == LFS3_ERR_NOENT) { if (err == LFS3_ERR_NOENT) {
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
lfs3_unmount(&lfs3) => 0; lfs3_unmount(&lfs3) => 0;
goto done; goto done;
} }
@@ -952,7 +952,7 @@ code = '''
clobber_buf, BLOCK_SIZE) => 0; clobber_buf, BLOCK_SIZE) => 0;
if (tinfo.btype != LFS3_BTYPE_MDIR || k == i+1) { if (tinfo.btype != LFS3_BTYPE_MDIR || k == i+1) {
i += (tinfo.btype == LFS3_BTYPE_MDIR) ? 2 : 1; i += (tinfo.btype == LFS3_BTYPE_MDIR) ? 2 : 1;
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
goto clobbered; goto clobbered;
} }
} }
@@ -1010,17 +1010,17 @@ code = '''
} }
// traverse to find blocks // traverse to find blocks
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, LFS3_T_RDONLY) => 0; lfs3_trv_open(&lfs3, &trv, LFS3_T_RDONLY) => 0;
lfs3_block_t k = 0; lfs3_block_t k = 0;
for (lfs3_block_t j = 0;; j++) { for (lfs3_block_t j = 0;; j++) {
assert(j < 2*BLOCK_COUNT); assert(j < 2*BLOCK_COUNT);
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(!err || err == LFS3_ERR_NOENT); assert(!err || err == LFS3_ERR_NOENT);
if (err == LFS3_ERR_NOENT) { if (err == LFS3_ERR_NOENT) {
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
lfs3_unmount(&lfs3) => 0; lfs3_unmount(&lfs3) => 0;
goto done; goto done;
} }
@@ -1040,7 +1040,7 @@ code = '''
clobber_buf, BLOCK_SIZE) => 0; clobber_buf, BLOCK_SIZE) => 0;
if (tinfo.btype != LFS3_BTYPE_MDIR || k == i+1) { if (tinfo.btype != LFS3_BTYPE_MDIR || k == i+1) {
i += (tinfo.btype == LFS3_BTYPE_MDIR) ? 2 : 1; i += (tinfo.btype == LFS3_BTYPE_MDIR) ? 2 : 1;
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
goto clobbered; goto clobbered;
} }
} }
@@ -1062,7 +1062,7 @@ done:;
[cases.test_gc_ckmeta_unck] [cases.test_gc_ckmeta_unck]
# AFTER=0 => after running lfs3_fs_gc once # AFTER=0 => after running lfs3_fs_gc once
# AFTER=1 => after running lfs3_fs_gc to completion # AFTER=1 => after running lfs3_fs_gc to completion
# AFTER=2 => after running lfs3_traversal_t # AFTER=2 => after running lfs3_trv_t
# AFTER=3 => after lfs3_fs_ckmeta # AFTER=3 => after lfs3_fs_ckmeta
# AFTER=4 => after remounting with LFS3_M_CKMETA # AFTER=4 => after remounting with LFS3_M_CKMETA
defines.AFTER = [0, 1, 2, 3, 4] defines.AFTER = [0, 1, 2, 3, 4]
@@ -1127,19 +1127,19 @@ code = '''
lfs3_fs_gc(&lfs3) => 0; lfs3_fs_gc(&lfs3) => 0;
} }
// run lfs3_traversal_t // run lfs3_trv_t
} else if (AFTER == 2) { } else if (AFTER == 2) {
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, LFS3_T_RDWR | GC_FLAGS) => 0; lfs3_trv_open(&lfs3, &trv, LFS3_T_RDWR | GC_FLAGS) => 0;
while (true) { while (true) {
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(err == 0 || err == LFS3_ERR_NOENT); assert(err == 0 || err == LFS3_ERR_NOENT);
if (err == LFS3_ERR_NOENT) { if (err == LFS3_ERR_NOENT) {
break; break;
} }
} }
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
// run lfs3_fs_ckmeta // run lfs3_fs_ckmeta
} else if (AFTER == 3) { } else if (AFTER == 3) {
@@ -1163,17 +1163,17 @@ code = '''
} }
// traverse to find blocks // traverse to find blocks
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, LFS3_T_RDONLY) => 0; lfs3_trv_open(&lfs3, &trv, LFS3_T_RDONLY) => 0;
lfs3_block_t k = 0; lfs3_block_t k = 0;
for (lfs3_block_t j = 0;; j++) { for (lfs3_block_t j = 0;; j++) {
assert(j < 2*BLOCK_COUNT); assert(j < 2*BLOCK_COUNT);
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(!err || err == LFS3_ERR_NOENT); assert(!err || err == LFS3_ERR_NOENT);
if (err == LFS3_ERR_NOENT) { if (err == LFS3_ERR_NOENT) {
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
lfs3_unmount(&lfs3) => 0; lfs3_unmount(&lfs3) => 0;
goto done; goto done;
} }
@@ -1192,7 +1192,7 @@ code = '''
clobber_buf, BLOCK_SIZE) => 0; clobber_buf, BLOCK_SIZE) => 0;
if (tinfo.btype != LFS3_BTYPE_MDIR || k == i+1) { if (tinfo.btype != LFS3_BTYPE_MDIR || k == i+1) {
i += (tinfo.btype == LFS3_BTYPE_MDIR) ? 2 : 1; i += (tinfo.btype == LFS3_BTYPE_MDIR) ? 2 : 1;
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
goto clobbered; goto clobbered;
} }
} }
@@ -1225,7 +1225,7 @@ done:;
[cases.test_gc_ckdata_unck] [cases.test_gc_ckdata_unck]
# AFTER=0 => after running lfs3_fs_gc once # AFTER=0 => after running lfs3_fs_gc once
# AFTER=1 => after running lfs3_fs_gc to completion # AFTER=1 => after running lfs3_fs_gc to completion
# AFTER=2 => after running lfs3_traversal_t # AFTER=2 => after running lfs3_trv_t
# AFTER=3 => after lfs3_fs_ckdata # AFTER=3 => after lfs3_fs_ckdata
# AFTER=4 => after remounting with LFS3_M_CKDATA # AFTER=4 => after remounting with LFS3_M_CKDATA
defines.AFTER = [0, 1, 2, 3, 4] defines.AFTER = [0, 1, 2, 3, 4]
@@ -1290,19 +1290,19 @@ code = '''
lfs3_fs_gc(&lfs3) => 0; lfs3_fs_gc(&lfs3) => 0;
} }
// run lfs3_traversal_t // run lfs3_trv_t
} else if (AFTER == 2) { } else if (AFTER == 2) {
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, LFS3_T_RDWR | GC_FLAGS) => 0; lfs3_trv_open(&lfs3, &trv, LFS3_T_RDWR | GC_FLAGS) => 0;
while (true) { while (true) {
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(err == 0 || err == LFS3_ERR_NOENT); assert(err == 0 || err == LFS3_ERR_NOENT);
if (err == LFS3_ERR_NOENT) { if (err == LFS3_ERR_NOENT) {
break; break;
} }
} }
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
// run lfs3_fs_ckdata // run lfs3_fs_ckdata
} else if (AFTER == 3) { } else if (AFTER == 3) {
@@ -1326,17 +1326,17 @@ code = '''
} }
// traverse to find blocks // traverse to find blocks
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, LFS3_T_RDONLY) => 0; lfs3_trv_open(&lfs3, &trv, LFS3_T_RDONLY) => 0;
lfs3_block_t k = 0; lfs3_block_t k = 0;
for (lfs3_block_t j = 0;; j++) { for (lfs3_block_t j = 0;; j++) {
assert(j < 2*BLOCK_COUNT); assert(j < 2*BLOCK_COUNT);
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(!err || err == LFS3_ERR_NOENT); assert(!err || err == LFS3_ERR_NOENT);
if (err == LFS3_ERR_NOENT) { if (err == LFS3_ERR_NOENT) {
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
lfs3_unmount(&lfs3) => 0; lfs3_unmount(&lfs3) => 0;
goto done; goto done;
} }
@@ -1356,7 +1356,7 @@ code = '''
clobber_buf, BLOCK_SIZE) => 0; clobber_buf, BLOCK_SIZE) => 0;
if (tinfo.btype != LFS3_BTYPE_MDIR || k == i+1) { if (tinfo.btype != LFS3_BTYPE_MDIR || k == i+1) {
i += (tinfo.btype == LFS3_BTYPE_MDIR) ? 2 : 1; i += (tinfo.btype == LFS3_BTYPE_MDIR) ? 2 : 1;
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
goto clobbered; goto clobbered;
} }
} }
@@ -1392,7 +1392,7 @@ done:;
# test that gc work clears flags in lfs3_fs_stat # test that gc work clears flags in lfs3_fs_stat
[cases.test_gc_iflags] [cases.test_gc_iflags]
# AFTER=0 => after running lfs3_fs_gc # AFTER=0 => after running lfs3_fs_gc
# AFTER=1 => after running lfs3_traversal_t # AFTER=1 => after running lfs3_trv_t
# AFTER=2 => after explicit operations # AFTER=2 => after explicit operations
# AFTER=3 => after remounting # AFTER=3 => after remounting
defines.AFTER = [0, 1, 2, 3] defines.AFTER = [0, 1, 2, 3]
@@ -1468,7 +1468,7 @@ code = '''
assert(false); assert(false);
#endif #endif
// run lfs3_traversal_t // run lfs3_trv_t
} else if (AFTER == 1) { } else if (AFTER == 1) {
while (true) { while (true) {
// it may take multiple traversals to do all pending work // it may take multiple traversals to do all pending work
@@ -1482,17 +1482,17 @@ code = '''
break; break;
} }
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, LFS3_T_RDWR | GC_FLAGS) => 0; lfs3_trv_open(&lfs3, &trv, LFS3_T_RDWR | GC_FLAGS) => 0;
while (true) { while (true) {
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(err == 0 || err == LFS3_ERR_NOENT); assert(err == 0 || err == LFS3_ERR_NOENT);
if (err == LFS3_ERR_NOENT) { if (err == LFS3_ERR_NOENT) {
break; break;
} }
} }
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
} }
// run explicit operations // run explicit operations
@@ -1517,34 +1517,34 @@ code = '''
if (LOOKAHEAD) { if (LOOKAHEAD) {
// we need an explicit traversal for this // we need an explicit traversal for this
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, lfs3_trv_open(&lfs3, &trv,
LFS3_T_RDWR | LFS3_T_LOOKAHEAD) => 0; LFS3_T_RDWR | LFS3_T_LOOKAHEAD) => 0;
while (true) { while (true) {
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(err == 0 || err == LFS3_ERR_NOENT); assert(err == 0 || err == LFS3_ERR_NOENT);
if (err == LFS3_ERR_NOENT) { if (err == LFS3_ERR_NOENT) {
break; break;
} }
} }
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
} }
if (COMPACT) { if (COMPACT) {
// we need an explicit traversal for this // we need an explicit traversal for this
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, lfs3_trv_open(&lfs3, &trv,
LFS3_T_RDWR | LFS3_T_COMPACT) => 0; LFS3_T_RDWR | LFS3_T_COMPACT) => 0;
while (true) { while (true) {
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(err == 0 || err == LFS3_ERR_NOENT); assert(err == 0 || err == LFS3_ERR_NOENT);
if (err == LFS3_ERR_NOENT) { if (err == LFS3_ERR_NOENT) {
break; break;
} }
} }
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
} }
if (CKMETA) { if (CKMETA) {
@@ -1581,7 +1581,7 @@ code = '''
# test that gc work clears flags in lfs3_fs_stat after lfs3_fs_unck # test that gc work clears flags in lfs3_fs_stat after lfs3_fs_unck
[cases.test_gc_iflags_unck] [cases.test_gc_iflags_unck]
# AFTER=0 => after running lfs3_fs_gc # AFTER=0 => after running lfs3_fs_gc
# AFTER=1 => after running lfs3_traversal_t # AFTER=1 => after running lfs3_trv_t
# AFTER=2 => after explicit operations # AFTER=2 => after explicit operations
# AFTER=3 => after remounting # AFTER=3 => after remounting
defines.AFTER = [0, 1, 2, 3] defines.AFTER = [0, 1, 2, 3]
@@ -1657,7 +1657,7 @@ code = '''
assert(false); assert(false);
#endif #endif
// run lfs3_traversal_t // run lfs3_trv_t
} else if (AFTER == 1) { } else if (AFTER == 1) {
while (true) { while (true) {
// it may take multiple traversals to do all pending work // it may take multiple traversals to do all pending work
@@ -1671,17 +1671,17 @@ code = '''
break; break;
} }
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, LFS3_T_RDWR | GC_FLAGS) => 0; lfs3_trv_open(&lfs3, &trv, LFS3_T_RDWR | GC_FLAGS) => 0;
while (true) { while (true) {
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(err == 0 || err == LFS3_ERR_NOENT); assert(err == 0 || err == LFS3_ERR_NOENT);
if (err == LFS3_ERR_NOENT) { if (err == LFS3_ERR_NOENT) {
break; break;
} }
} }
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
} }
// run explicit operations // run explicit operations
@@ -1706,34 +1706,34 @@ code = '''
if (LOOKAHEAD) { if (LOOKAHEAD) {
// we need an explicit traversal for this // we need an explicit traversal for this
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, lfs3_trv_open(&lfs3, &trv,
LFS3_T_RDWR | LFS3_T_LOOKAHEAD) => 0; LFS3_T_RDWR | LFS3_T_LOOKAHEAD) => 0;
while (true) { while (true) {
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(err == 0 || err == LFS3_ERR_NOENT); assert(err == 0 || err == LFS3_ERR_NOENT);
if (err == LFS3_ERR_NOENT) { if (err == LFS3_ERR_NOENT) {
break; break;
} }
} }
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
} }
if (COMPACT) { if (COMPACT) {
// we need an explicit traversal for this // we need an explicit traversal for this
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, lfs3_trv_open(&lfs3, &trv,
LFS3_T_RDWR | LFS3_T_COMPACT) => 0; LFS3_T_RDWR | LFS3_T_COMPACT) => 0;
while (true) { while (true) {
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(err == 0 || err == LFS3_ERR_NOENT); assert(err == 0 || err == LFS3_ERR_NOENT);
if (err == LFS3_ERR_NOENT) { if (err == LFS3_ERR_NOENT) {
break; break;
} }
} }
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
} }
if (CKMETA) { if (CKMETA) {
@@ -1786,7 +1786,7 @@ code = '''
assert(false); assert(false);
#endif #endif
// run lfs3_traversal_t // run lfs3_trv_t
} else if (AFTER == 1) { } else if (AFTER == 1) {
while (true) { while (true) {
// it may take multiple traversals to do all pending work // it may take multiple traversals to do all pending work
@@ -1800,17 +1800,17 @@ code = '''
break; break;
} }
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, LFS3_T_RDWR | GC_FLAGS) => 0; lfs3_trv_open(&lfs3, &trv, LFS3_T_RDWR | GC_FLAGS) => 0;
while (true) { while (true) {
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(err == 0 || err == LFS3_ERR_NOENT); assert(err == 0 || err == LFS3_ERR_NOENT);
if (err == LFS3_ERR_NOENT) { if (err == LFS3_ERR_NOENT) {
break; break;
} }
} }
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
} }
// run explicit operations // run explicit operations
@@ -1835,34 +1835,34 @@ code = '''
if (LOOKAHEAD) { if (LOOKAHEAD) {
// we need an explicit traversal for this // we need an explicit traversal for this
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, lfs3_trv_open(&lfs3, &trv,
LFS3_T_RDWR | LFS3_T_LOOKAHEAD) => 0; LFS3_T_RDWR | LFS3_T_LOOKAHEAD) => 0;
while (true) { while (true) {
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(err == 0 || err == LFS3_ERR_NOENT); assert(err == 0 || err == LFS3_ERR_NOENT);
if (err == LFS3_ERR_NOENT) { if (err == LFS3_ERR_NOENT) {
break; break;
} }
} }
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
} }
if (COMPACT) { if (COMPACT) {
// we need an explicit traversal for this // we need an explicit traversal for this
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, lfs3_trv_open(&lfs3, &trv,
LFS3_T_RDWR | LFS3_T_COMPACT) => 0; LFS3_T_RDWR | LFS3_T_COMPACT) => 0;
while (true) { while (true) {
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(err == 0 || err == LFS3_ERR_NOENT); assert(err == 0 || err == LFS3_ERR_NOENT);
if (err == LFS3_ERR_NOENT) { if (err == LFS3_ERR_NOENT) {
break; break;
} }
} }
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
} }
if (CKMETA) { if (CKMETA) {
+11 -11
View File
@@ -1,5 +1,5 @@
# Advanced mount tests # Advanced mount tests
after = ['test_mtree', 'test_traversal'] after = ['test_mtree', 'test_trvs']
# test we can mount # test we can mount
@@ -405,17 +405,17 @@ code = '''
} }
// traverse to find blocks // traverse to find blocks
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, LFS3_T_RDONLY) => 0; lfs3_trv_open(&lfs3, &trv, LFS3_T_RDONLY) => 0;
lfs3_block_t k = 0; lfs3_block_t k = 0;
for (lfs3_block_t j = 0;; j++) { for (lfs3_block_t j = 0;; j++) {
assert(j < 2*BLOCK_COUNT); assert(j < 2*BLOCK_COUNT);
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(!err || err == LFS3_ERR_NOENT); assert(!err || err == LFS3_ERR_NOENT);
if (err == LFS3_ERR_NOENT) { if (err == LFS3_ERR_NOENT) {
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
lfs3_unmount(&lfs3) => 0; lfs3_unmount(&lfs3) => 0;
goto done; goto done;
} }
@@ -434,7 +434,7 @@ code = '''
clobber_buf, BLOCK_SIZE) => 0; clobber_buf, BLOCK_SIZE) => 0;
if (tinfo.btype != LFS3_BTYPE_MDIR || k == i+1) { if (tinfo.btype != LFS3_BTYPE_MDIR || k == i+1) {
i += (tinfo.btype == LFS3_BTYPE_MDIR) ? 2 : 1; i += (tinfo.btype == LFS3_BTYPE_MDIR) ? 2 : 1;
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
lfs3_unmount(&lfs3) => 0; lfs3_unmount(&lfs3) => 0;
goto clobbered; goto clobbered;
} }
@@ -494,17 +494,17 @@ code = '''
} }
// traverse to find blocks // traverse to find blocks
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_open(&lfs3, &t, LFS3_T_RDONLY) => 0; lfs3_trv_open(&lfs3, &trv, LFS3_T_RDONLY) => 0;
lfs3_block_t k = 0; lfs3_block_t k = 0;
for (lfs3_block_t j = 0;; j++) { for (lfs3_block_t j = 0;; j++) {
assert(j < 2*BLOCK_COUNT); assert(j < 2*BLOCK_COUNT);
struct lfs3_tinfo tinfo; struct lfs3_tinfo tinfo;
int err = lfs3_traversal_read(&lfs3, &t, &tinfo); int err = lfs3_trv_read(&lfs3, &trv, &tinfo);
assert(!err || err == LFS3_ERR_NOENT); assert(!err || err == LFS3_ERR_NOENT);
if (err == LFS3_ERR_NOENT) { if (err == LFS3_ERR_NOENT) {
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
lfs3_unmount(&lfs3) => 0; lfs3_unmount(&lfs3) => 0;
goto done; goto done;
} }
@@ -524,7 +524,7 @@ code = '''
clobber_buf, BLOCK_SIZE) => 0; clobber_buf, BLOCK_SIZE) => 0;
if (tinfo.btype != LFS3_BTYPE_MDIR || k == i+1) { if (tinfo.btype != LFS3_BTYPE_MDIR || k == i+1) {
i += (tinfo.btype == LFS3_BTYPE_MDIR) ? 2 : 1; i += (tinfo.btype == LFS3_BTYPE_MDIR) ? 2 : 1;
lfs3_traversal_close(&lfs3, &t) => 0; lfs3_trv_close(&lfs3, &trv) => 0;
lfs3_unmount(&lfs3) => 0; lfs3_unmount(&lfs3) => 0;
goto clobbered; goto clobbered;
} }
+24 -24
View File
@@ -3665,8 +3665,8 @@ code = '''
uint8_t *seen = malloc((BLOCK_COUNT+7)/8); uint8_t *seen = malloc((BLOCK_COUNT+7)/8);
memset(seen, 0, (BLOCK_COUNT+7)/8); memset(seen, 0, (BLOCK_COUNT+7)/8);
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_init(&t, lfs3_trv_init(&trv,
LFS3_T_RDONLY LFS3_T_RDONLY
| LFS3_T_MTREEONLY | LFS3_T_MTREEONLY
| ((CKMETA) ? LFS3_T_CKMETA : 0)); | ((CKMETA) ? LFS3_T_CKMETA : 0));
@@ -3676,7 +3676,7 @@ code = '''
lfs3_stag_t tag; lfs3_stag_t tag;
lfs3_bptr_t bptr; lfs3_bptr_t bptr;
tag = lfs3_mtree_traverse(&lfs3, &t, tag = lfs3_mtree_traverse(&lfs3, &trv,
&bptr); &bptr);
assert(tag >= 0 || tag == LFS3_ERR_NOENT); assert(tag >= 0 || tag == LFS3_ERR_NOENT);
if (tag == LFS3_ERR_NOENT) { if (tag == LFS3_ERR_NOENT) {
@@ -3787,8 +3787,8 @@ code = '''
uint8_t *seen = malloc((BLOCK_COUNT+7)/8); uint8_t *seen = malloc((BLOCK_COUNT+7)/8);
memset(seen, 0, (BLOCK_COUNT+7)/8); memset(seen, 0, (BLOCK_COUNT+7)/8);
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_init(&t, lfs3_trv_init(&trv,
LFS3_T_RDONLY LFS3_T_RDONLY
| LFS3_T_MTREEONLY | LFS3_T_MTREEONLY
| ((CKMETA) ? LFS3_T_CKMETA : 0)); | ((CKMETA) ? LFS3_T_CKMETA : 0));
@@ -3798,7 +3798,7 @@ code = '''
lfs3_stag_t tag; lfs3_stag_t tag;
lfs3_bptr_t bptr; lfs3_bptr_t bptr;
tag = lfs3_mtree_traverse(&lfs3, &t, tag = lfs3_mtree_traverse(&lfs3, &trv,
&bptr); &bptr);
assert(tag >= 0 || tag == LFS3_ERR_NOENT); assert(tag >= 0 || tag == LFS3_ERR_NOENT);
if (tag == LFS3_ERR_NOENT) { if (tag == LFS3_ERR_NOENT) {
@@ -3935,8 +3935,8 @@ code = '''
uint8_t *seen = malloc((BLOCK_COUNT+7)/8); uint8_t *seen = malloc((BLOCK_COUNT+7)/8);
memset(seen, 0, (BLOCK_COUNT+7)/8); memset(seen, 0, (BLOCK_COUNT+7)/8);
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_init(&t, lfs3_trv_init(&trv,
LFS3_T_RDONLY LFS3_T_RDONLY
| LFS3_T_MTREEONLY | LFS3_T_MTREEONLY
| ((CKMETA) ? LFS3_T_CKMETA : 0)); | ((CKMETA) ? LFS3_T_CKMETA : 0));
@@ -3946,7 +3946,7 @@ code = '''
lfs3_stag_t tag; lfs3_stag_t tag;
lfs3_bptr_t bptr; lfs3_bptr_t bptr;
tag = lfs3_mtree_traverse(&lfs3, &t, tag = lfs3_mtree_traverse(&lfs3, &trv,
&bptr); &bptr);
assert(tag >= 0 || tag == LFS3_ERR_NOENT); assert(tag >= 0 || tag == LFS3_ERR_NOENT);
if (tag == LFS3_ERR_NOENT) { if (tag == LFS3_ERR_NOENT) {
@@ -4106,8 +4106,8 @@ code = '''
uint8_t *seen = malloc((BLOCK_COUNT+7)/8); uint8_t *seen = malloc((BLOCK_COUNT+7)/8);
memset(seen, 0, (BLOCK_COUNT+7)/8); memset(seen, 0, (BLOCK_COUNT+7)/8);
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_init(&t, lfs3_trv_init(&trv,
LFS3_T_RDONLY LFS3_T_RDONLY
| LFS3_T_MTREEONLY | LFS3_T_MTREEONLY
| ((CKMETA) ? LFS3_T_CKMETA : 0)); | ((CKMETA) ? LFS3_T_CKMETA : 0));
@@ -4117,7 +4117,7 @@ code = '''
lfs3_stag_t tag; lfs3_stag_t tag;
lfs3_bptr_t bptr; lfs3_bptr_t bptr;
tag = lfs3_mtree_traverse(&lfs3, &t, tag = lfs3_mtree_traverse(&lfs3, &trv,
&bptr); &bptr);
assert(tag >= 0 || tag == LFS3_ERR_NOENT); assert(tag >= 0 || tag == LFS3_ERR_NOENT);
if (tag == LFS3_ERR_NOENT) { if (tag == LFS3_ERR_NOENT) {
@@ -4257,8 +4257,8 @@ code = '''
uint8_t *seen = malloc((BLOCK_COUNT+7)/8); uint8_t *seen = malloc((BLOCK_COUNT+7)/8);
memset(seen, 0, (BLOCK_COUNT+7)/8); memset(seen, 0, (BLOCK_COUNT+7)/8);
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_init(&t, lfs3_trv_init(&trv,
LFS3_T_RDONLY LFS3_T_RDONLY
| LFS3_T_MTREEONLY | LFS3_T_MTREEONLY
| ((CKMETA) ? LFS3_T_CKMETA : 0)); | ((CKMETA) ? LFS3_T_CKMETA : 0));
@@ -4268,7 +4268,7 @@ code = '''
lfs3_stag_t tag; lfs3_stag_t tag;
lfs3_bptr_t bptr; lfs3_bptr_t bptr;
tag = lfs3_mtree_traverse(&lfs3, &t, tag = lfs3_mtree_traverse(&lfs3, &trv,
&bptr); &bptr);
assert(tag >= 0 || tag == LFS3_ERR_NOENT); assert(tag >= 0 || tag == LFS3_ERR_NOENT);
if (tag == LFS3_ERR_NOENT) { if (tag == LFS3_ERR_NOENT) {
@@ -4383,8 +4383,8 @@ code = '''
uint8_t *seen = malloc((BLOCK_COUNT+7)/8); uint8_t *seen = malloc((BLOCK_COUNT+7)/8);
memset(seen, 0, (BLOCK_COUNT+7)/8); memset(seen, 0, (BLOCK_COUNT+7)/8);
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_init(&t, lfs3_trv_init(&trv,
LFS3_T_RDONLY LFS3_T_RDONLY
| LFS3_T_MTREEONLY | LFS3_T_MTREEONLY
| ((CKMETA) ? LFS3_T_CKMETA : 0)); | ((CKMETA) ? LFS3_T_CKMETA : 0));
@@ -4394,7 +4394,7 @@ code = '''
lfs3_stag_t tag; lfs3_stag_t tag;
lfs3_bptr_t bptr; lfs3_bptr_t bptr;
tag = lfs3_mtree_traverse(&lfs3, &t, tag = lfs3_mtree_traverse(&lfs3, &trv,
&bptr); &bptr);
assert(tag >= 0 || tag == LFS3_ERR_NOENT); assert(tag >= 0 || tag == LFS3_ERR_NOENT);
if (tag == LFS3_ERR_NOENT) { if (tag == LFS3_ERR_NOENT) {
@@ -4553,8 +4553,8 @@ code = '''
uint8_t *seen = malloc((BLOCK_COUNT+7)/8); uint8_t *seen = malloc((BLOCK_COUNT+7)/8);
memset(seen, 0, (BLOCK_COUNT+7)/8); memset(seen, 0, (BLOCK_COUNT+7)/8);
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_init(&t, lfs3_trv_init(&trv,
LFS3_T_RDONLY LFS3_T_RDONLY
| LFS3_T_MTREEONLY | LFS3_T_MTREEONLY
| ((CKMETA) ? LFS3_T_CKMETA : 0)); | ((CKMETA) ? LFS3_T_CKMETA : 0));
@@ -4564,7 +4564,7 @@ code = '''
lfs3_stag_t tag; lfs3_stag_t tag;
lfs3_bptr_t bptr; lfs3_bptr_t bptr;
tag = lfs3_mtree_traverse(&lfs3, &t, tag = lfs3_mtree_traverse(&lfs3, &trv,
&bptr); &bptr);
assert(tag >= 0 || tag == LFS3_ERR_NOENT); assert(tag >= 0 || tag == LFS3_ERR_NOENT);
if (tag == LFS3_ERR_NOENT) { if (tag == LFS3_ERR_NOENT) {
@@ -4686,8 +4686,8 @@ code = '''
LFS3_MPTR_MROOTANCHOR()))) => 0; LFS3_MPTR_MROOTANCHOR()))) => 0;
// technically, cycle detection only needs to work when we're validating // technically, cycle detection only needs to work when we're validating
lfs3_traversal_t t; lfs3_trv_t trv;
lfs3_traversal_init(&t, lfs3_trv_init(&trv,
LFS3_T_RDONLY | LFS3_T_MTREEONLY | LFS3_T_CKMETA); LFS3_T_RDONLY | LFS3_T_MTREEONLY | LFS3_T_CKMETA);
for (lfs3_block_t i = 0;; i++) { for (lfs3_block_t i = 0;; i++) {
// assert that we detect the cycle in a reasonable number of iterations // assert that we detect the cycle in a reasonable number of iterations
@@ -4695,7 +4695,7 @@ code = '''
lfs3_stag_t tag; lfs3_stag_t tag;
lfs3_bptr_t bptr; lfs3_bptr_t bptr;
tag = lfs3_mtree_traverse(&lfs3, &t, tag = lfs3_mtree_traverse(&lfs3, &trv,
&bptr); &bptr);
assert(tag >= 0 || tag == LFS3_ERR_CORRUPT); assert(tag >= 0 || tag == LFS3_ERR_CORRUPT);
if (tag == LFS3_ERR_CORRUPT) { if (tag == LFS3_ERR_CORRUPT) {
+1 -1
View File
@@ -8,7 +8,7 @@ after = [
'test_dirs', 'test_dirs',
'test_files', 'test_files',
'test_stickynotes', 'test_stickynotes',
'test_traversal', 'test_trvs',
'test_gc', 'test_gc',
'test_mount', 'test_mount',
'test_ck', 'test_ck',
File diff suppressed because it is too large Load Diff