mirror of
https://github.com/systemd/systemd.git
synced 2024-11-01 17:51:22 +03:00
generator: exit early when asked to generate fsck unit for / and /usr in initrd
Let's exit early if we are invoked to generate an fsck unit for the rootfs or /usr of the initrd itself. The "systemd-root-fsck.service" and "systemd-usr-fsck.service" units are after all for the host file systems, and the initrd file hierarchy is from an unpacked cpio anyway. Hence, this semantically doesn't really make sense, so quickly exit if we detect this case. This allows us to remove some checks further down the codepath.
This commit is contained in:
parent
b67bbfef14
commit
122860f102
@ -138,6 +138,13 @@ int generator_write_fsck_deps(
|
|||||||
assert(what);
|
assert(what);
|
||||||
assert(where);
|
assert(where);
|
||||||
|
|
||||||
|
/* Let's do an early exit if we are invoked for the root and /usr/ trees in the initrd, to avoid
|
||||||
|
* generating confusing log messages */
|
||||||
|
if (in_initrd() && PATH_IN_SET(where, "/", "/usr")) {
|
||||||
|
log_debug("Skipping fsck for %s in initrd.", where);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!is_device_path(what)) {
|
if (!is_device_path(what)) {
|
||||||
log_warning("Checking was requested for \"%s\", but it is not a device.", what);
|
log_warning("Checking was requested for \"%s\", but it is not a device.", what);
|
||||||
return 0;
|
return 0;
|
||||||
@ -180,7 +187,7 @@ int generator_write_fsck_deps(
|
|||||||
* Requires= from /usr onto a fsck@.service unit and that unit is shut down, then
|
* Requires= from /usr onto a fsck@.service unit and that unit is shut down, then
|
||||||
* we'd have to unmount /usr too. */
|
* we'd have to unmount /usr too. */
|
||||||
|
|
||||||
dep = !in_initrd() && path_equal(where, "/usr") ? "Wants" : "Requires";
|
dep = path_equal(where, "/usr") ? "Wants" : "Requires";
|
||||||
|
|
||||||
r = unit_name_from_path_instance("systemd-fsck", what, ".service", &_fsck);
|
r = unit_name_from_path_instance("systemd-fsck", what, ".service", &_fsck);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user