1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-19 22:50:17 +03:00

Merge 01881ff12a6e814add8db46eece20982ba2d66b5 into 104587314ff25a5c35390eeb42308f083e1e0488

This commit is contained in:
Lennart Poettering 2025-03-13 13:55:56 -07:00 committed by GitHub
commit 27a06eece8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -107,7 +107,7 @@ Unit* unit_new(Manager *m, size_t size) {
u->type = _UNIT_TYPE_INVALID;
u->default_dependencies = true;
u->unit_file_state = _UNIT_FILE_STATE_INVALID;
u->unit_file_preset = -1;
u->unit_file_preset = _PRESET_ACTION_INVALID;
u->on_failure_job_mode = JOB_REPLACE;
u->on_success_job_mode = JOB_FAIL;
u->job_timeout = USEC_INFINITY;
@ -4167,15 +4167,21 @@ UnitFileState unit_get_unit_file_state(Unit *u) {
assert(u);
if (u->unit_file_state < 0 && u->fragment_path) {
r = unit_file_get_state(
u->manager->runtime_scope,
NULL,
u->id,
&u->unit_file_state);
if (r < 0)
u->unit_file_state = UNIT_FILE_BAD;
}
if (u->unit_file_state >= 0)
return u->unit_file_state;
/* If we know this is a transient unit no need to ask the unit file state for details. Let's bypass
* the more expensive on-disk check. */
if (u->transient)
return (u->unit_file_state = UNIT_FILE_TRANSIENT);
r = unit_file_get_state(
u->manager->runtime_scope,
/* root_dir= */ NULL,
u->id,
&u->unit_file_state);
if (r < 0)
u->unit_file_state = UNIT_FILE_BAD;
return u->unit_file_state;
}
@ -4185,24 +4191,26 @@ PresetAction unit_get_unit_file_preset(Unit *u) {
assert(u);
if (u->unit_file_preset < 0 && u->fragment_path) {
_cleanup_free_ char *bn = NULL;
if (u->unit_file_preset >= 0)
return u->unit_file_preset;
r = path_extract_filename(u->fragment_path, &bn);
if (r < 0)
return (u->unit_file_preset = r);
/* If this is a transient or perpetual unit file it doesn't make much sense to ask the preset
* database about this, because enabling/disabling makes no sense for either. Hence don't. */
if (!u->fragment_path || u->transient || u->perpetual)
return (u->unit_file_preset = -ENOEXEC);
if (r == O_DIRECTORY)
return (u->unit_file_preset = -EISDIR);
_cleanup_free_ char *bn = NULL;
r = path_extract_filename(u->fragment_path, &bn);
if (r < 0)
return (u->unit_file_preset = r);
if (r == O_DIRECTORY)
return (u->unit_file_preset = -EISDIR);
u->unit_file_preset = unit_file_query_preset(
return (u->unit_file_preset = unit_file_query_preset(
u->manager->runtime_scope,
NULL,
/* root_dir= */ NULL,
bn,
NULL);
}
return u->unit_file_preset;
/* cache= */ NULL));
}
Unit* unit_ref_set(UnitRef *ref, Unit *source, Unit *target) {