aboutsummaryrefslogtreecommitdiffstats
path: root/libmount/src/hooks.c
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2022-05-25 14:01:52 +0200
committerKarel Zak <kzak@redhat.com>2023-01-03 12:53:12 +0100
commitb0a165dc76c024614a930325877a25555d4ff819 (patch)
tree3aeb54c393c16da209ee34f012e63ef6f45403d9 /libmount/src/hooks.c
parent17de67aa1d7dee8cb8ea3040867a989af44a8243 (diff)
downloadutil-linux-b0a165dc76c024614a930325877a25555d4ff819.tar.gz
libmount: reimplement X-mount.subdir= by hooks
* "prepare-target hook" checks for X-mount.subdir= and define pre-mount hook * "mount-pre hook" unshares temporary directory, redirect the next mount(2) to this temporary directory * "mount-post hook" binds subdirectory to the final target, umounts temporary directory Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/hooks.c')
-rw-r--r--libmount/src/hooks.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/libmount/src/hooks.c b/libmount/src/hooks.c
index 5e6327c6e5..13a3185993 100644
--- a/libmount/src/hooks.c
+++ b/libmount/src/hooks.c
@@ -8,12 +8,14 @@
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
- */
-
-/**
- * SECTION: hookset
- * @title: Mount context hooks
- * @short_description: extensions to mount process
+ *
+ *
+ * The "hookset" is set of callbacks (hooks) that implement some functionality.
+ * It supports two kinds of data:
+ *
+ * - global data : accessible for all callbacks, independent on defined hooks
+ *
+ * - per-hook data : usually used by the callback function
*/
#include "mountP.h"
@@ -23,6 +25,7 @@ static const struct libmnt_hookset *hooksets[] =
{
#ifdef __linux__
&hookset_mkdir,
+ &hookset_subdir,
&hookset_mount_legacy
#endif
};
@@ -151,6 +154,7 @@ int mnt_context_set_hookset_data(struct libmnt_context *cxt,
/* deallocate old data */
if (data == NULL) {
if (hd) {
+ DBG(CXT, ul_debugobj(cxt, " free '%s' data", hs->name));
list_del(&hd->datas);
free(hd);
}
@@ -163,7 +167,7 @@ int mnt_context_set_hookset_data(struct libmnt_context *cxt,
if (!hd)
return -ENOMEM;
- DBG(CXT, ul_debugobj(cxt, "alloc '%s' data", hs->name));
+ DBG(CXT, ul_debugobj(cxt, " alloc '%s' data", hs->name));
INIT_LIST_HEAD(&hd->datas);
hd->hookset = hs;
list_add_tail(&hd->datas, &cxt->hooksets_datas);