summaryrefslogtreecommitdiff
path: root/src/shared/unit-file.c
AgeCommit message (Collapse)AuthorFilesLines
2020-06-17Revert: Rework unit loading to take into account all aliasesINSUN PYO1-490/+1
Revert below patches due to increasing unit loading time (UnitsLoadFinishTimestamp - UnitsLoadStartTimestamp) Refer: https://github.com/systemd/systemd/pull/13119/commits - test-unit-file: allow printing of information about specific units - pid1: drop unit caches only based on mtime - analyze: add "unit-files" to dump the unit fragment map - core: restore initialization of u->source_mtime - pid1: use a cache for all unit aliases - shared/unit-file: add a function to validate unit alias symlinks - TEST-15-DROPIN: add test for details of unit aliasing Change-Id: I1bff89f5851544cda7522bd3ceb398499dac57d4
2019-10-24basic/fs-util: change CHASE_OPEN flag into a separate output parameterZbigniew Jędrzejewski-Szmek1-1/+1
chase_symlinks() would return negative on error, and either a non-negative status or a non-negative fd when CHASE_OPEN was given. This made the interface quite complicated, because dependning on the flags used, we would get two different "types" of return object. Coverity was always confused by this, and flagged every use of chase_symlinks() without CHASE_OPEN as a resource leak (because it would this that an fd is returned). This patch uses a saparate output parameter, so there is no confusion. (I think it is OK to have functions which return either an error or an fd. It's only returning *either* an fd or a non-fd that is confusing.)
2019-10-03Merge pull request #13246 from keszybz/add-SystemdOptions-efi-variableZbigniew Jędrzejewski-Szmek1-0/+45
Add efi variable to augment /proc/cmdline
2019-09-30Handle d_type == DT_UNKNOWN correctlyMichael Olbrich1-0/+1
As documented in the man-page, readdir() may return a directory entry with d_type == DT_UNKNOWN. This must be handled for regular filesystems. dirent_ensure_type() is available to set d_type if necessary. Use it in some more places. Without this systemd will fail to boot correctly with nfsroot and some other filesystems. Closes #13609
2019-09-16util-lib: move runlevel_to_target() to shared/unit-fileZbigniew Jędrzejewski-Szmek1-0/+45
It if of course related to /proc/cmdline parsing, but is higher-level functionality built on top of it. It should be in shared/ because it is something to be used by pid1 and related utilities, not something for level-level libraries.
2019-08-30shared/unit-files: only put valid unit paths and dropin dirs in the cacheZbigniew Jędrzejewski-Szmek1-1/+10
2019-08-30shared/unit-files: we must not filter out names starting with a dotZbigniew Jędrzejewski-Szmek1-1/+1
Fixes #13380.
2019-08-16unit-file: downgrade accidentaly high-prio debug log messageLennart Poettering1-1/+1
2019-08-14shared/unit-file: fix systemctl cat user@.serviceZbigniew Jędrzejewski-Szmek1-3/+3
I assumed that unit_name_to_instnace() returns NULL if there is no instance. In fact it returns "", so the check for instance was wrong. Also avoid unnecessary call to unit_name_is_valid().
2019-07-31unit-file: fix coverity issueLennart Poettering1-1/+1
Fixes coverity issue 1403820
2019-07-30pid1: drop unit caches only based on mtimeZbigniew Jędrzejewski-Szmek1-1/+56
v2: - do not watch mtime of transient and generated dirs We'd reload the map after every transient unit we created, which we don't need to do, since we create those units ourselves and know their fragment path.
2019-07-30pid1: use a cache for all unit aliasesZbigniew Jędrzejewski-Szmek1-0/+353
This reworks how we load units from disk. Instead of chasing symlinks every time we are asked to load a unit by name, we slurp all symlinks from disk and build two hashmaps: 1. from unit name to either alias target, or fragment on disk (if an alias, we put just the target name in the hashmap, if a fragment we put an absolute path, so we can distinguish both). 2. from a unit name to all aliases Reading all this data can be pretty costly (40 ms) on my machine, so we keep it around for reuse. The advantage is that we can reliably know what all the aliases of a given unit are. This means we can reliably load dropins under all names. This fixes #11972.
2019-07-30shared/unit-file: add a function to validate unit alias symlinksZbigniew Jędrzejewski-Szmek1-0/+73
It turns out most possible symlinks are invalid, because the type has to match, and template units can only be linked to template units. I'm not sure if the existing code made the same checks consistently. At least I don't see the same rules expressed in a single place.
2019-07-19Create src/shared/unit-file.[ch] for unit-file related opsZbigniew Jędrzejewski-Szmek1-0/+23
So far we put such functinos in install.[ch], but that is tied too closely to enable/disable. Let's start moving things to a place with a better name.