summaryrefslogtreecommitdiff
path: root/src/shared/generator.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2022-10-16 23:25:04 +0200
committerLennart Poettering <lennart@poettering.net>2023-01-17 09:42:16 +0100
commit04959faa632272a8fc9cdac3121b2e4af721c1b6 (patch)
tree71b689e13950e8464c66653d67970aa178567db1 /src/shared/generator.c
parent50072ccf1bfee8a53563a083a3a52b26f0d5678f (diff)
downloadsystemd-04959faa632272a8fc9cdac3121b2e4af721c1b6.tar.gz
generators: optionally, measure file systems at boot
If we use gpt-auto-generator, automatically measure root fs and /var. Otherwise, add x-systemd.measure option to request this.
Diffstat (limited to 'src/shared/generator.c')
-rw-r--r--src/shared/generator.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/shared/generator.c b/src/shared/generator.c
index 6c82d0f0ef..64f4a2741c 100644
--- a/src/shared/generator.c
+++ b/src/shared/generator.c
@@ -650,6 +650,43 @@ int generator_hook_up_growfs(
return generator_add_symlink_full(dir, where_unit, "wants", growfs_unit_path, instance);
}
+int generator_hook_up_pcrfs(
+ const char *dir,
+ const char *where,
+ const char *target) {
+
+ const char *pcrfs_unit, *pcrfs_unit_path;
+ _cleanup_free_ char *where_unit = NULL, *instance = NULL;
+ int r;
+
+ assert(dir);
+ assert(where);
+
+ r = unit_name_from_path(where, ".mount", &where_unit);
+ if (r < 0)
+ return log_error_errno(r, "Failed to make unit name from path '%s': %m", where);
+
+ if (empty_or_root(where)) {
+ pcrfs_unit = SPECIAL_PCRFS_ROOT_SERVICE;
+ pcrfs_unit_path = SYSTEM_DATA_UNIT_DIR "/" SPECIAL_PCRFS_ROOT_SERVICE;
+ } else {
+ pcrfs_unit = SPECIAL_PCRFS_SERVICE;
+ pcrfs_unit_path = SYSTEM_DATA_UNIT_DIR "/" SPECIAL_PCRFS_SERVICE;
+
+ r = unit_name_path_escape(where, &instance);
+ if (r < 0)
+ return log_error_errno(r, "Failed to escape path '%s': %m", where);
+ }
+
+ if (target) {
+ r = generator_add_ordering(dir, target, "After", pcrfs_unit, instance);
+ if (r < 0)
+ return r;
+ }
+
+ return generator_add_symlink_full(dir, where_unit, "wants", pcrfs_unit_path, instance);
+}
+
int generator_enable_remount_fs_service(const char *dir) {
/* Pull in systemd-remount-fs.service */
return generator_add_symlink(dir, SPECIAL_LOCAL_FS_TARGET, "wants",