1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-22 17:35:35 +03:00

core: automatically add udev dependency for units using RootImage=

We use udev to wait for /dev/loopX devices to be fully proped hence we
need an implicit ordering dependency on it, for RootImage= to work
reliably in early boot, too.

Fixes: #14972
This commit is contained in:
Lennart Poettering 2020-04-21 13:04:39 +02:00
parent 91b75f1f2f
commit 33b58dfb41
3 changed files with 13 additions and 0 deletions

View File

@ -139,6 +139,9 @@
<varname>PrivateDevices=</varname> below, as it may change the setting of
<varname>DevicePolicy=</varname>.</para>
<para>Units making use of <varname>RootImage=</varname> automatically gain an
<varname>After=</varname> dependency on <filename>systemd-udevd.service</filename>.</para>
<xi:include href="system-only.xml" xpointer="singular"/></listitem>
</varlistentry>

View File

@ -82,6 +82,7 @@
#define SPECIAL_QUOTAON_SERVICE "quotaon.service"
#define SPECIAL_REMOUNT_FS_SERVICE "systemd-remount-fs.service"
#define SPECIAL_VOLATILE_ROOT_SERVICE "systemd-volatile-root.service"
#define SPECIAL_UDEVD_SERVICE "systemd-udevd.service"
/* Services systemd relies on */
#define SPECIAL_DBUS_SERVICE "dbus.service"

View File

@ -1079,6 +1079,15 @@ int unit_add_exec_dependencies(Unit *u, ExecContext *c) {
return r;
}
if (c->root_image) {
/* We need to wait for /dev/loopX to appear when doing RootImage=, hence let's add an
* implicit dependency on udev */
r = unit_add_dependency_by_name(u, UNIT_AFTER, SPECIAL_UDEVD_SERVICE, true, UNIT_DEPENDENCY_FILE);
if (r < 0)
return r;
}
if (!IN_SET(c->std_output,
EXEC_OUTPUT_JOURNAL, EXEC_OUTPUT_JOURNAL_AND_CONSOLE,
EXEC_OUTPUT_KMSG, EXEC_OUTPUT_KMSG_AND_CONSOLE,