]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: add MNT_STAGE_PREP
authorKarel Zak <kzak@redhat.com>
Fri, 10 Jun 2022 08:01:24 +0000 (10:01 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 3 Jan 2023 11:53:12 +0000 (12:53 +0100)
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 <kzak@redhat.com>
libmount/src/context_mount.c
libmount/src/hook_mount_legacy.c
libmount/src/hooks.c
libmount/src/mountP.h

index 56cfb281a10a863b6ea93361685537e992dbc519..3931af973086203fd5deeaaa259066ce3862f181 100644 (file)
@@ -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;
index a477738562a73cf2dcecbc3ad9b0e0802e47379b..63c0262a732ba8da574b7d2a6c076fdf32d588d9 100644 (file)
@@ -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
index cea6c25b3a7282bcef018d530f2b9557e5dacbe6..d6d8d89415170648e829263a4353a0181ace6610 100644 (file)
@@ -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",
 };
index d25442e42f9b21c751b162c059c88dd9a57c2e49..0fc972753aa1029600c2fd9a2502397086afa7f4 100644 (file)
@@ -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 {