From 9eaab640e6c69f9f42a5015554cc90287efd4706 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Thu, 5 Jun 2025 16:35:27 -0500 Subject: [PATCH] rdonly: Fixed lfs3_m_isrdonly shortcut leaving traversals dangling We were relying on the previous LFS3_TSTATE_OMDIRS logic implicitly leaving t->ot NULL when it reaches the end of the linked-list. With the lfs3_m_isrdonly shortcut we now need to do this explicitly. Found by test_mount_flags Adds a bit of code to both the default and rdonly builds, but a correct filesystem is usually preferred over a small one: code stack ctx rdonly before: 10676 840 524 rdonly after: 10680 (+0.0%) 840 (+0.0%) 524 (+0.0%) default before: 37320 2280 636 default after: 37324 (+0.0%) 2280 (+0.0%) 636 (+0.0%) --- lfs3.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lfs3.c b/lfs3.c index 31b2ad82..8a7b88d3 100644 --- a/lfs3.c +++ b/lfs3.c @@ -9686,6 +9686,7 @@ static int lfs3_mtree_traverse_(lfs3_t *lfs3, lfs3_traversal_t *t, // note we can skip checking opened files if mounted rdonly, // this saves a bit of code when compiled rdonly if (lfs3_m_isrdonly(lfs3->flags) || !t->ot) { + t->ot = NULL; t->b.o.mdir.mid += 1; lfs3_t_settstate(&t->b.o.flags, LFS3_TSTATE_MDIR); continue;