From b42e4e2350a26b13a6165b78990e8814535ceb80 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 1 Aug 2023 14:49:48 +0200 Subject: libmount: cleanup --fake mode It was originally designed to play nasty games with /etc/mtab (mount when /etc is read-only and update later when it's write-able). The --fake is completely useless with the new API due to complexity where we cannot skip any step, because the next stuff depends on it. So, it makes more sense skip all functionality where libmount does anything significant. This commit add --fake check to hooks logic to skip all hooks as the hooks are place where libmount implements mount related invasive operations (create mountpoint, namespaces, create superblock, move, mount, etc.). Frankly, --fake without mtab is useless. Fixes: https://github.com/util-linux/util-linux/issues/2395 Signed-off-by: Karel Zak --- libmount/src/hooks.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'libmount/src/hooks.c') diff --git a/libmount/src/hooks.c b/libmount/src/hooks.c index 88cf68d611..2d79162605 100644 --- a/libmount/src/hooks.c +++ b/libmount/src/hooks.c @@ -313,7 +313,12 @@ int mnt_context_has_hook(struct libmnt_context *cxt, static int call_hook(struct libmnt_context *cxt, struct hookset_hook *hook) { - int rc = hook->func(cxt, hook->hookset, hook->data); + int rc = 0; + + if (mnt_context_is_fake(cxt)) + DBG(CXT, ul_debugobj(cxt, " FAKE call")); + else + rc = hook->func(cxt, hook->hookset, hook->data); hook->executed = 1; if (!rc) @@ -359,7 +364,10 @@ int mnt_context_call_hooks(struct libmnt_context *cxt, int stage) DBG(CXT, ul_debugobj(cxt, "calling %s [first]", hs->name)); - rc = hs->firstcall(cxt, hs, NULL); + if (mnt_context_is_fake(cxt)) + DBG(CXT, ul_debugobj(cxt, " FAKE call")); + else + rc = hs->firstcall(cxt, hs, NULL); if (!rc) rc = call_depend_hooks(cxt, hs->name, stage); if (rc < 0) -- cgit 1.2.3-korg