From: Karel Zak Date: Fri, 10 Jun 2022 08:01:24 +0000 (+0200) Subject: libmount: add MNT_STAGE_PREP X-Git-Tag: v2.39-rc1~331 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5e69b21b21d1493a4483332f93a1aaf5bbe46344;p=thirdparty%2Futil-linux.git libmount: add MNT_STAGE_PREP It's better to introduce a new stage to call hooks when all is prepared rather than use MNT_STAGE_PREP_OPTIONS for all cases. Signed-off-by: Karel Zak --- diff --git a/libmount/src/context_mount.c b/libmount/src/context_mount.c index 56cfb281a1..3931af9730 100644 --- a/libmount/src/context_mount.c +++ b/libmount/src/context_mount.c @@ -872,6 +872,10 @@ int mnt_context_prepare_mount(struct libmnt_context *cxt) goto end; } } + + if (!rc) + rc = mnt_context_call_hooks(cxt, MNT_STAGE_PREP); + if (rc) { DBG(CXT, ul_debugobj(cxt, "mount: preparing failed")); goto end; diff --git a/libmount/src/hook_mount_legacy.c b/libmount/src/hook_mount_legacy.c index a477738562..63c0262a73 100644 --- a/libmount/src/hook_mount_legacy.c +++ b/libmount/src/hook_mount_legacy.c @@ -259,7 +259,7 @@ static int hook_prepare(struct libmnt_context *cxt, assert(hs == &hookset_mount_legacy); #ifdef UL_HAVE_MOUNT_API - /* do nothing when __builtin-mount succesfully registred */ + /* do nothing when __mount succesfully registred */ if (mnt_context_has_hook(cxt, &hookset_mount, 0, NULL)) return 0; #endif @@ -291,7 +291,7 @@ const struct libmnt_hookset hookset_mount_legacy = { .name = "__legacy-mount", - .firststage = MNT_STAGE_PREP_OPTIONS, + .firststage = MNT_STAGE_PREP, .firstcall = hook_prepare, .deinit = hookset_deinit diff --git a/libmount/src/hooks.c b/libmount/src/hooks.c index cea6c25b3a..d6d8d89415 100644 --- a/libmount/src/hooks.c +++ b/libmount/src/hooks.c @@ -59,10 +59,13 @@ static const char *stagenames[] = { [MNT_STAGE_PREP_SOURCE] = "prep-source", [MNT_STAGE_PREP_TARGET] = "prep-target", [MNT_STAGE_PREP_OPTIONS] = "prep-options", + [MNT_STAGE_PREP] = "prep", + /* mount */ [MNT_STAGE_MOUNT_PRE] = "pre-mount", [MNT_STAGE_MOUNT] = "mount", [MNT_STAGE_MOUNT_POST] = "post-mount", + /* post */ [MNT_STAGE_POST] = "post", }; diff --git a/libmount/src/mountP.h b/libmount/src/mountP.h index d25442e42f..0fc972753a 100644 --- a/libmount/src/mountP.h +++ b/libmount/src/mountP.h @@ -282,15 +282,16 @@ enum { * stuff like veritydev.c. */ enum { - MNT_STAGE_PREP_SOURCE = 1, - MNT_STAGE_PREP_TARGET, - MNT_STAGE_PREP_OPTIONS, + MNT_STAGE_PREP_SOURCE = 1, /* mount source preparation */ + MNT_STAGE_PREP_TARGET, /* mount target preparation */ + MNT_STAGE_PREP_OPTIONS, /* mount options preparation */ + MNT_STAGE_PREP, /* all prepared */ - MNT_STAGE_MOUNT_PRE = 100, - MNT_STAGE_MOUNT, - MNT_STAGE_MOUNT_POST, + MNT_STAGE_MOUNT_PRE = 100, /* before mount */ + MNT_STAGE_MOUNT, /* mount(2) or fsmount(2) or tree-clone */ + MNT_STAGE_MOUNT_POST, /* after mount */ - MNT_STAGE_POST = 200 + MNT_STAGE_POST = 200 /* all is done */ }; struct libmnt_hookset {