diff options
| author | Karel Zak <kzak@redhat.com> | 2023-08-01 14:49:48 +0200 |
|---|---|---|
| committer | Karel Zak <kzak@redhat.com> | 2023-08-01 14:49:48 +0200 |
| commit | b42e4e2350a26b13a6165b78990e8814535ceb80 (patch) | |
| tree | 04395c114c1c15a5bef7c069500e8cb9560152b6 /libmount/src/hooks.c | |
| parent | e3a1b5e6d0db08acaf3fbd72d5680c945d68f10d (diff) | |
| download | util-linux-b42e4e2350a26b13a6165b78990e8814535ceb80.tar.gz | |
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 <kzak@redhat.com>
Diffstat (limited to 'libmount/src/hooks.c')
| -rw-r--r-- | libmount/src/hooks.c | 12 |
1 files changed, 10 insertions, 2 deletions
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) |
