diff options
author | Lennart Poettering <lennart@poettering.net> | 2022-10-16 23:25:04 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2023-01-17 09:42:16 +0100 |
commit | 04959faa632272a8fc9cdac3121b2e4af721c1b6 (patch) | |
tree | 71b689e13950e8464c66653d67970aa178567db1 /src/shared | |
parent | units: rework growfs units to be just a regular unit that is instantiated (diff) | |
download | systemd-04959faa632272a8fc9cdac3121b2e4af721c1b6.tar.xz systemd-04959faa632272a8fc9cdac3121b2e4af721c1b6.zip |
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')
-rw-r--r-- | src/shared/generator.c | 37 | ||||
-rw-r--r-- | src/shared/generator.h | 4 |
2 files changed, 41 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", diff --git a/src/shared/generator.h b/src/shared/generator.h index a4049dbd8f..111900fd45 100644 --- a/src/shared/generator.h +++ b/src/shared/generator.h @@ -81,6 +81,10 @@ int generator_hook_up_growfs( const char *dir, const char *where, const char *target); +int generator_hook_up_pcrfs( + const char *dir, + const char *where, + const char *target); int generator_enable_remount_fs_service(const char *dir); |