Systemd/src/shared
Zbigniew Jędrzejewski-Szmek 581fef8d56 core: stop removing non-existent and duplicate lookup paths
When we would iterate over the lookup paths for each unit, making the list as
short as possible was important for performance. With the current cache, it
doesn't matter much. Two classes of paths were being removed:
- paths which don't exist in the filesystem
- paths which symlink to a path earlier in the search list
Both of those points cause problems with the caching code:
- if a user creates a directory that didn't exist before and puts units there,
  now we will notice the new mtime an properly load the unit. When the path
  was removed from list, we wouldn't.
- we now properly detect whether a unit path is on the path or not.
  Before, if e.g. /lib/systemd/system, /usr/lib/systemd/systemd were both on
  the path, and /lib was a symlink to /usr/lib, the second directory would be
  pruned from the path. Then, the code would think that a symlink
  /etc/systemd/system/foo.service→/lib/systemd/system/foo.service is an alias,
  but /etc/systemd/system/foo.service→/usr/lib/systemd/system/foo.service would
  be considered a link (in the systemctl link sense).

Removing the pruning has a slight negative performance impact in case of
usr-merge systems which have systemd compiled with non-usr-merge paths.
Non-usr-merge systems are deprecated, and this impact should be very small, so
I think it's OK. If it turns out to be an issue, the loop in function that
builds the cache could be improved to skip over "duplicate" directories with
same logic that the cache pruning did before. I didn't want to add this,
becuase it complicates the code to improve a corner case.

Fixes #13272.
2019-08-27 18:12:20 +02:00
..
linux linux: make UBSAN quiet 2019-06-25 11:44:08 +09:00
acl-util.c headers: remove unneeded includes from util.h 2019-03-27 11:53:12 +01:00
acl-util.h tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
acpi-fpdt.c tree-wide: drop copyright headers from frequent contributors 2018-06-20 11:58:53 +02:00
acpi-fpdt.h tree-wide: drop double newline 2018-06-29 11:02:17 +09:00
apparmor-util.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
apparmor-util.h tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
ask-password-api.c shared/ask-password-api: backspace all chars at once 2019-07-12 00:35:05 +02:00
ask-password-api.h ask-password: make ask_password_keyring() static 2018-12-30 21:09:41 +09:00
barrier.c tree-wide: use SWAP_TWO a bit more 2018-11-26 22:17:34 +01:00
barrier.h Move various files that don't need to be in basic/ to shared/ 2018-11-20 07:27:37 +01:00
base-filesystem.c shared: be friendly to EROFS images 2019-04-03 17:27:20 +02:00
base-filesystem.h tree-wide: drop double newline 2018-06-29 11:02:17 +09:00
bitmap.c shared/exit-status: use Bitmap instead of Sets 2019-07-29 15:54:53 +02:00
bitmap.h shared/exit-status: use Bitmap instead of Sets 2019-07-29 15:54:53 +02:00
blkid-util.h shared/blkid-util: do not include util.h needlessly 2018-12-07 02:49:03 +01:00
boot-timestamps.c tree-wide: drop copyright headers from frequent contributors 2018-06-20 11:58:53 +02:00
boot-timestamps.h tree-wide: drop double newline 2018-06-29 11:02:17 +09:00
bootspec.c codespell: fix spelling errors 2019-04-29 16:47:18 +02:00
bootspec.h bootspec: fix build when EFI support is disabled 2019-04-17 11:20:04 +02:00
bpf-program.c bpf-firewall: custom BPF programs through IP(Ingress|Egress)FilterPath= 2019-06-25 09:56:16 +02:00
bpf-program.h bpf-firewall: custom BPF programs through IP(Ingress|Egress)FilterPath= 2019-06-25 09:56:16 +02:00
bus-unit-procs.c shared: no need to check result of strndupa() 2019-07-16 12:40:22 +02:00
bus-unit-procs.h bus-unit-util: split out code that shows a unit's process tree 2019-03-13 17:41:41 +01:00
bus-unit-util.c pid1,systemctl: allow symbolic exit code names 2019-07-29 15:54:53 +02:00
bus-unit-util.h bus-unit-util: split out code that shows a unit's process tree 2019-03-13 17:41:41 +01:00
bus-util.c bus-util: convert bus_log_{parse,create}_error into defines 2019-07-29 15:54:53 +02:00
bus-util.h bus-util: convert bus_log_{parse,create}_error into defines 2019-07-29 15:54:53 +02:00
bus-wait-for-jobs.c shared: add some minor comments 2019-04-02 05:34:53 +09:00
bus-wait-for-jobs.h shared: split out code to wait for jobs to complet into its own source file 2019-03-13 17:39:24 +01:00
bus-wait-for-units.c shared: fix assert call 2019-07-17 11:35:04 +02:00
bus-wait-for-units.h shared: add generic logic for waiting for a unit to enter some state 2019-07-11 12:18:51 +02:00
calendarspec.c shared/calendarspec: make output arg optional 2019-05-17 10:09:32 +02:00
calendarspec.h Move various files that don't need to be in basic/ to shared/ 2018-11-20 07:27:37 +01:00
cgroup-show.c tree-wide: get rid of strappend() 2019-07-12 14:31:12 +09:00
cgroup-show.h Rework cmdline printing to use unicode 2019-05-22 10:08:17 +02:00
clean-ipc.c Move LONG_LINE_MAX definition to fileio.h 2018-11-14 16:25:32 +01:00
clean-ipc.h tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
clock-util.c util: split out errno related stuff 2019-03-14 13:25:51 +01:00
clock-util.h Move various files that don't need to be in basic/ to shared/ 2018-11-20 07:27:37 +01:00
condition.c tree-wide: use PROJECT_FILE instead of __FILE__ 2019-07-04 10:36:00 +02:00
condition.h Merge pull request #12030 from poettering/condition-memory 2019-04-02 08:01:42 +09:00
conf-parser.c Revert "shared/conf-parser,networkd: EXTRACT_UNQUOTE|EXTRACT_RETAIN_ESCAPE → EXTRACT_UNQUOTE" 2019-08-19 09:54:06 +02:00
conf-parser.h service: handle abort stops with dedicated timeout 2019-04-12 17:32:52 +02:00
cpu-set-util.c Rename EXTRACT_QUOTES to EXTRACT_UNQUOTE 2019-06-28 11:35:05 +02:00
cpu-set-util.h core: introduce NUMAPolicy and NUMAMask options 2019-06-24 16:58:54 +02:00
crypt-util.c Move various files that don't need to be in basic/ to shared/ 2018-11-20 07:27:37 +01:00
crypt-util.h cryptsetup: add same-cpu-crypt and submit-from-crypt-cpus options 2019-03-13 09:48:50 +01:00
daemon-util.h sd-daemon: add notify_start() and notify_on_cleanup() helper function 2018-12-08 18:09:25 +09:00
dev-setup.c path-util: get rid of prefix_root() 2019-06-21 08:42:55 +09:00
dev-setup.h dev-setup: generalize logic we use to create "inaccessible" device nodes 2018-11-29 20:21:40 +01:00
dissect-image.c tree-wide: make use of errno_or_else() everywhere 2019-07-11 23:20:31 +02:00
dissect-image.h codespell: fix spelling errors 2019-04-29 16:47:18 +02:00
dm-util.c shared/dm-util: use strncpy_exact() to silence gcc 2019-07-10 10:32:39 +02:00
dm-util.h dissect: split out DM deferred remove into src/shared/dm-util.c 2019-07-05 02:19:24 +09:00
dns-domain.c tree-wide: code improvements suggested by Coccinelle 2019-04-30 09:39:07 +02:00
dns-domain.h resolve: reject host names with leading or trailing dashes in /etc/hosts 2018-12-10 09:56:56 +01:00
dropin.c shared/dropin: rename function for clarity 2019-07-19 16:51:14 +02:00
dropin.h basic/set: constify operations which don't modify Set 2019-07-19 16:51:14 +02:00
efivars.c efivars: modernize efi_get_variable() a bit 2019-07-25 17:10:51 +02:00
efivars.h boot,shared: share the definitions of EFI_LOADER_FEATURE macros 2019-07-10 14:59:48 +02:00
enable-mempool.c mempool: only enable mempool use when linked to libsystemd-shared.so 2018-10-11 11:10:37 +02:00
env-file-label.c util-lib: split out env file parsing code into env-file.c 2018-12-02 13:22:29 +01:00
env-file-label.h util-lib: split out env file parsing code into env-file.c 2018-12-02 13:22:29 +01:00
ethtool-util.c tree-wide: some more [static] related fixes 2019-07-12 16:40:10 +02:00
ethtool-util.h ethtool: add missing link mode 2019-06-25 11:55:04 +09:00
exec-util.c core: add ExecStartXYZEx= with dbus support for executable prefixes 2019-05-30 20:41:42 -07:00
exec-util.h core: add ExecStartXYZEx= with dbus support for executable prefixes 2019-05-30 20:41:42 -07:00
exit-status.c shared/exit-status: fix off-by-one in comment 2019-08-05 16:38:20 +02:00
exit-status.h exit-status: rename EXIT_STATUS_GLIBC → EXIT_STATUS_LIBC 2019-07-29 19:05:25 +02:00
fdset.c nspawn: don't free "fds" twice 2019-03-22 18:11:27 +01:00
fdset.h nspawn: don't free "fds" twice 2019-03-22 18:11:27 +01:00
fileio-label.c util-lib: split out env file parsing code into env-file.c 2018-12-02 13:22:29 +01:00
fileio-label.h util-lib: split out env file parsing code into env-file.c 2018-12-02 13:22:29 +01:00
firewall-util.c firewall-util: use fixed size array for chain name 2019-07-05 02:45:00 +09:00
firewall-util.h tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
format-table.c Merge pull request #13216 from poettering/busctl-format-table 2019-07-29 20:44:54 +02:00
format-table.h Merge pull request #13216 from poettering/busctl-format-table 2019-07-29 20:44:54 +02:00
fsck-util.h fsck: split out fsck return code definitions into a header file of its own 2019-07-05 02:31:12 +09:00
fstab-util.c codespell: fix spelling errors 2019-04-29 16:47:18 +02:00
fstab-util.h Remove variable only used for an assert 2019-03-28 09:03:06 +01:00
generate-ip-protocol-list.sh scripts: use 4 space indentation 2019-04-12 08:30:31 +02:00
generator.c generator: downgrade Requires= → Wants= of fsck from /usr mount unit 2019-07-10 16:19:31 +02:00
generator.h Pull in systemd-remount-fs.service only when required 2019-01-03 15:30:28 +01:00
gpt.h gpt: add definition for boot loader spec partition 2019-03-01 12:41:32 +01:00
id128-print.c tree-wide: use SD_ID128_UUID_FORMAT_STR as appropriate 2019-04-05 13:48:38 +02:00
id128-print.h systemd-id128: a new tool to print machine/boot/invocation/app-specific ids 2018-10-02 15:15:10 +02:00
ima-util.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
ima-util.h tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
import-util.c util: split out nulstr related stuff to nulstr-util.[ch] 2019-03-14 13:25:52 +01:00
import-util.h tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
initreq.h tree-wide: use '#pragma once' for header guard 2018-08-30 06:10:43 +03:00
install-printf.c Mark *data and *userdata params to specifier_printf() as const 2018-12-12 16:45:33 +01:00
install-printf.h Mark *data and *userdata params to specifier_printf() as const 2018-12-12 16:45:33 +01:00
install.c shared/install: typo 2019-07-29 20:28:49 +02:00
install.h Create src/shared/unit-file.[ch] for unit-file related ops 2019-07-19 16:51:14 +02:00
ip-protocol-list.c ip-protocol-list: sort headers 2018-12-04 09:18:21 +01:00
ip-protocol-list.h util: introduce parse_ip_protocol() 2018-12-02 06:13:41 +01:00
ip-protocol-to-name.awk util: rename socket_protocol_{from,to}_name() to ip_protocol_{from,to}_name() 2018-12-02 05:48:27 +01:00
journal-importer.c tree-wide: drop duplicated blank lines 2019-07-15 18:41:27 +02:00
journal-importer.h journal-import: extract helpers for handling arrays of iovec and make them available for others 2019-06-27 19:14:23 +02:00
journal-util.c codespell: fix spelling errors 2019-04-29 16:47:18 +02:00
journal-util.h tree-wide: add multiple inclusion guard 2018-06-25 13:04:59 +09:00
json-internal.h Move various files that don't need to be in basic/ to shared/ 2018-11-20 07:27:37 +01:00
json.c json: always allocate at least sizeof(JsonVariant) bytes 2019-07-11 15:10:33 +02:00
json.h Drop trailing slash from assert_cc() definition 2019-07-17 12:57:20 +02:00
libmount-util.h shared/mount-util: make sure utab is ignored in umount_recursive() 2019-04-23 23:52:15 +02:00
libshared.sym tree-wide: tabs suck (#8527) 2018-03-23 15:21:35 +01:00
local-addresses.c local-addresses: filter out any routing tables but the main one 2019-07-24 09:07:30 +02:00
local-addresses.h netlink: move local-addresses.[ch] to src/shared 2019-07-24 09:06:50 +02:00
lockfile-util.c lockfile-util.c: fix build without F_OFD_SETLK 2019-01-11 17:37:36 +01:00
lockfile-util.h lockfile: drop unnecessary headers from lockfile-util.h 2018-12-06 13:31:16 +01:00
log-link.h tree-wide: use PROJECT_FILE instead of __FILE__ 2019-07-04 10:36:00 +02:00
logs-show.c tree-wide: drop duplicated blank lines 2019-07-15 18:41:27 +02:00
logs-show.h logs-show: make highlight parameter const (#10311) 2018-10-09 16:43:47 +09:00
loop-util.c loop-util: invoke LOOP_CTL_GET_FREE in a loop 2019-05-22 13:04:26 +02:00
loop-util.h tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
machine-image.c shared: allow LOCK_SH locks on the host root in OS images 2019-07-29 09:56:50 +02:00
machine-image.h machine-image: introduce image_hash_ops and use it 2018-12-02 12:18:54 +01:00
machine-pool.c import: drop logic of setting up /var/lib/machines as btrfs loopback mount 2018-11-26 18:09:01 +01:00
machine-pool.h import: drop logic of setting up /var/lib/machines as btrfs loopback mount 2018-11-26 18:09:01 +01:00
main-func.h codespell: fix spelling errors 2019-04-29 16:47:18 +02:00
meson.build meson: reorder alphabetically 2019-07-24 09:07:33 +02:00
module-util.c shared/module-util: fix preexisting mixup with errno sign 2018-07-19 18:28:21 +02:00
module-util.h udev-builtin-kmod: use the generic module_load() function 2018-07-19 18:28:21 +02:00
mount-util.c mount-util: bind_remount: avoid calling statvfs 2019-07-17 11:37:09 +02:00
mount-util.h mount-util: beef up bind_remount_recursive() to be able to toggle more than MS_RDONLY 2019-03-25 19:33:55 +01:00
nscd-flush.c codespell: fix spelling errors 2019-04-29 16:47:18 +02:00
nscd-flush.h shared: add helper for flushing nscd caches 2018-12-15 12:10:19 +01:00
nsflags.c util: drop missing.h from socket-util.h 2018-12-06 13:31:16 +01:00
nsflags.h nsflsgs: drop missing.h and use missing_sched.h 2018-12-06 13:31:16 +01:00
os-util.c codespell: fix spelling errors 2019-04-29 16:47:18 +02:00
os-util.h Move various files that don't need to be in basic/ to shared/ 2018-11-20 07:27:37 +01:00
output-mode.c output-mode: add generic helper to pick right JsonFormatFlags for given OutputMode 2018-12-03 22:42:38 +01:00
output-mode.h output-mode: add new helper OUTPUT_MODE_IS_JSON() 2018-12-03 22:42:38 +01:00
pager.c pager: Fix deadlock when using built-in pager 2019-05-30 09:54:54 +02:00
pager.h Split out pretty-print.c and move pager.c and main-func.h to shared/ 2018-11-20 18:40:02 +01:00
path-lookup.c core: stop removing non-existent and duplicate lookup paths 2019-08-27 18:12:20 +02:00
path-lookup.h core: stop removing non-existent and duplicate lookup paths 2019-08-27 18:12:20 +02:00
pe-header.h bootspec: also look for boot loader spec type 2 entries (i.e. unified kernel images) 2019-03-01 12:41:32 +01:00
pretty-print.c analyze: make cat-config work with relabel-extra.d 2019-08-19 10:20:01 +02:00
pretty-print.h terminal-util: split out file:// generation from terminal_urlify_path() 2018-11-30 16:46:10 +01:00
ptyfwd.c ptyfwd: optionally override terminal width/height 2018-11-29 20:21:39 +01:00
ptyfwd.h tree-wide: add whitespace between type and variable name 2018-12-04 09:29:54 +01:00
reboot-util.c logind: Add support for RebootParameter 2019-03-22 20:30:33 +02:00
reboot-util.h logind: Add support for RebootParameter 2019-03-22 20:30:33 +02:00
resolve-util.c resolved: switch cache option to a tri-state option (systemd#5552). 2019-07-17 10:42:53 -04:00
resolve-util.h resolved: switch cache option to a tri-state option (systemd#5552). 2019-07-17 10:42:53 -04:00
seccomp-util.c shared/seccomp: add sync_file_range2 2019-08-19 11:10:40 +02:00
seccomp-util.h seccomp: add scmp_act_kill_process() helper that returns SCMP_ACT_KILL_PROCESS if supported 2019-05-24 10:48:28 +02:00
securebits-util.c Rename EXTRACT_QUOTES to EXTRACT_UNQUOTE 2019-06-28 11:35:05 +02:00
securebits-util.h missing: rename securebits.h to missing_securebits.h 2018-12-04 07:49:24 +01:00
serialize.c util: drop missing.h from util.h 2018-12-04 10:00:34 +01:00
serialize.h headers: remove unneeded includes from util.h 2019-03-27 11:53:12 +01:00
sleep-config.c Merge pull request #13212 from poettering/sleep-conf-default 2019-07-29 16:03:54 +02:00
sleep-config.h systemd-sleep: use swaps in priority order 2019-07-29 12:59:17 +02:00
spawn-ask-password-agent.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
spawn-ask-password-agent.h tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
spawn-polkit-agent.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
spawn-polkit-agent.h tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
specifier.c headers: remove unneeded includes from util.h 2019-03-27 11:53:12 +01:00
specifier.h Mark *data and *userdata params to specifier_printf() as const 2018-12-12 16:45:33 +01:00
switch-root.c switch-root: modernize rm_rf_children() invocation a bit 2019-04-29 16:17:29 +02:00
switch-root.h tree-wide: drop double newline 2018-06-29 11:02:17 +09:00
sysctl-util.c sysctl: add sysctl_writef() helper 2019-07-13 11:05:07 +02:00
sysctl-util.h sysctl: add sysctl_writef() helper 2019-07-13 11:05:07 +02:00
test-tables.h Drop my copyright headers 2018-06-14 13:03:20 +02:00
tests.c util-lib: split out env file parsing code into env-file.c 2018-12-02 13:22:29 +01:00
tests.h tests: add helper call have_namespaces() to test whether Linux namespaces are available 2018-10-24 19:40:24 +02:00
tmpfile-util-label.c util-lib: split out all temporary file related calls into tmpfiles-util.c 2018-12-02 13:22:29 +01:00
tmpfile-util-label.h util-lib: split out all temporary file related calls into tmpfiles-util.c 2018-12-02 13:22:29 +01:00
tomoyo-util.c tree-wide: drop copyright headers from frequent contributors 2018-06-20 11:58:53 +02:00
tomoyo-util.h tree-wide: drop double newline 2018-06-29 11:02:17 +09:00
udev-util.c udev: warn when we fail to parse udev.conf 2019-07-04 10:36:19 +02:00
udev-util.h util: make device_wait_for_initialization() optionally takes timeout value 2019-06-04 01:19:43 +09:00
uid-range.c util: split out sorting related calls to new sort-util.[ch] 2019-03-13 12:16:43 +01:00
uid-range.h tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
unit-file.c unit-file: downgrade accidentaly high-prio debug log message 2019-08-16 07:44:20 +09:00
unit-file.h pid1: drop unit caches only based on mtime 2019-07-30 14:01:46 +02:00
utmp-wtmp.c shared/utmp-wtmp: silence gcc warning about strncpy truncation 2019-05-07 21:05:26 +02:00
utmp-wtmp.h tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
varlink.c tree-wide: drop duplicated blank lines 2019-07-15 18:41:27 +02:00
varlink.h shared: add minimal varlink implementation 2019-05-09 14:14:20 -04:00
verbs.c shared/verbs: drop now-unused VERB_MUST_BE_ROOT 2019-05-08 11:51:51 +02:00
verbs.h shared/verbs: drop now-unused VERB_MUST_BE_ROOT 2019-05-08 11:51:51 +02:00
vlan-util.c network: re-implement parse_vid_range() 2019-07-05 16:35:06 +09:00
vlan-util.h network: re-implement parse_vid_range() 2019-07-05 16:35:06 +09:00
volatile-util.c volatile-util: tweak query_volatile_mode() a bit 2019-03-01 14:11:07 +01:00
volatile-util.h nspawn: add --volatile=overlay support 2019-03-01 14:11:06 +01:00
watchdog.c shared/watchdog: close watchdog device when done with it 2019-08-20 21:15:13 +02:00
watchdog.h tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
web-util.c tree-wide: port various places over to STARTSWITH_SET() 2018-11-26 14:08:46 +01:00
web-util.h Move various files that don't need to be in basic/ to shared/ 2018-11-20 07:27:37 +01:00
xml.c tree-wide: use '"' instead of '\"' 2019-01-17 16:46:29 +00:00
xml.h Move various files that don't need to be in basic/ to shared/ 2018-11-20 07:27:37 +01:00