mirror of
https://github.com/systemd/systemd.git
synced 2025-03-31 14:50:15 +03:00
pid1: use initrd.target in the initramfs by default
This makes the code do what the documentation says. The code had no inkling about initrd.target, so I think this change is fairly risky. As a fallback, default.target will be loaded, so initramfses which relied on current behaviour will still work, as along as they don't have a different initrd.target. In an initramfs created with recent dracut: $ ls -l usr/lib/systemd/system/{default.target,initrd.target} lrwxrwxrwx. usr/lib/systemd/system/default.target -> initrd.target -rw-r--r--. usr/lib/systemd/system/initrd.target So at least for dracut, there should be no difference. Also avoid a pointless allocation.
This commit is contained in:
parent
6e86b24db3
commit
8755dbad5b
@ -2,6 +2,7 @@
|
||||
#pragma once
|
||||
|
||||
#define SPECIAL_DEFAULT_TARGET "default.target"
|
||||
#define SPECIAL_INITRD_TARGET "initrd.target"
|
||||
|
||||
/* Shutdown targets */
|
||||
#define SPECIAL_UMOUNT_TARGET "umount.target"
|
||||
|
@ -1967,20 +1967,36 @@ static int do_queue_default_job(
|
||||
const char **ret_error_message) {
|
||||
|
||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
const char* default_unit;
|
||||
Job *default_unit_job;
|
||||
Unit *target = NULL;
|
||||
int r;
|
||||
|
||||
log_debug("Activating default unit: %s", arg_default_unit);
|
||||
if (arg_default_unit)
|
||||
default_unit = arg_default_unit;
|
||||
else if (in_initrd())
|
||||
default_unit = SPECIAL_INITRD_TARGET;
|
||||
else
|
||||
default_unit = SPECIAL_DEFAULT_TARGET;
|
||||
|
||||
r = manager_load_startable_unit_or_warn(m, arg_default_unit, NULL, &target);
|
||||
log_debug("Activating default unit: %s", default_unit);
|
||||
|
||||
r = manager_load_startable_unit_or_warn(m, default_unit, NULL, &target);
|
||||
if (r < 0 && in_initrd() && !arg_default_unit) {
|
||||
/* Fall back to default.target, which we used to always use by default. Only do this if no
|
||||
* explicit configuration was given. */
|
||||
|
||||
log_info("Falling back to " SPECIAL_DEFAULT_TARGET ".");
|
||||
|
||||
r = manager_load_startable_unit_or_warn(m, SPECIAL_DEFAULT_TARGET, NULL, &target);
|
||||
}
|
||||
if (r < 0) {
|
||||
log_info("Falling back to rescue target: " SPECIAL_RESCUE_TARGET);
|
||||
log_info("Falling back to " SPECIAL_RESCUE_TARGET ".");
|
||||
|
||||
r = manager_load_startable_unit_or_warn(m, SPECIAL_RESCUE_TARGET, NULL, &target);
|
||||
if (r < 0) {
|
||||
*ret_error_message = r == -ERFKILL ? "Rescue target masked"
|
||||
: "Failed to load rescue target";
|
||||
*ret_error_message = r == -ERFKILL ? SPECIAL_RESCUE_TARGET " masked"
|
||||
: "Failed to load " SPECIAL_RESCUE_TARGET;
|
||||
return r;
|
||||
}
|
||||
}
|
||||
@ -2192,15 +2208,6 @@ static int load_configuration(
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Initialize default unit */
|
||||
if (!arg_default_unit) {
|
||||
arg_default_unit = strdup(SPECIAL_DEFAULT_TARGET);
|
||||
if (!arg_default_unit) {
|
||||
*ret_error_message = "Failed to set default unit";
|
||||
return log_oom();
|
||||
}
|
||||
}
|
||||
|
||||
/* Initialize the show status setting if it hasn't been set explicitly yet */
|
||||
if (arg_show_status == _SHOW_STATUS_INVALID)
|
||||
arg_show_status = SHOW_STATUS_YES;
|
||||
|
Loading…
x
Reference in New Issue
Block a user