shared/install: rename UnitFileChange to InstallChange

It's shorter and more generic. The struct can contain info about changes to
unit files, but also symlinks and errors.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2022-10-13 19:44:47 +02:00
parent 0f87041f94
commit cd44ec5a92
15 changed files with 226 additions and 227 deletions
+26 -26
View File
@@ -2122,12 +2122,12 @@ static int send_unit_files_changed(sd_bus *bus, void *userdata) {
* if possible, and fall back to generating an error from error code c.
* The error message only describes the first error.
*
* Coordinate with unit_file_dump_changes() in install.c.
* Coordinate with install_changes_dump() in install.c.
*/
static int install_error(
sd_bus_error *error,
int c,
UnitFileChange *changes,
InstallChange *changes,
size_t n_changes) {
int r;
@@ -2186,15 +2186,15 @@ static int install_error(
r = c < 0 ? c : -EINVAL;
found:
unit_file_changes_free(changes, n_changes);
install_changes_free(changes, n_changes);
return r;
}
static int reply_unit_file_changes_and_free(
static int reply_install_changes_and_free(
Manager *m,
sd_bus_message *message,
int carries_install_info,
UnitFileChange *changes,
InstallChange *changes,
size_t n_changes,
sd_bus_error *error) {
@@ -2202,7 +2202,7 @@ static int reply_unit_file_changes_and_free(
bool bad = false, good = false;
int r;
if (unit_file_changes_have_modification(changes, n_changes)) {
if (install_changes_have_modification(changes, n_changes)) {
r = bus_foreach_bus(m, NULL, send_unit_files_changed, NULL);
if (r < 0)
log_debug_errno(r, "Failed to send UnitFilesChanged signal: %m");
@@ -2249,23 +2249,23 @@ static int reply_unit_file_changes_and_free(
if (r < 0)
goto fail;
unit_file_changes_free(changes, n_changes);
install_changes_free(changes, n_changes);
return sd_bus_send(NULL, reply, NULL);
fail:
unit_file_changes_free(changes, n_changes);
install_changes_free(changes, n_changes);
return r;
}
static int method_enable_unit_files_generic(
sd_bus_message *message,
Manager *m,
int (*call)(LookupScope scope, UnitFileFlags flags, const char *root_dir, char *files[], UnitFileChange **changes, size_t *n_changes),
int (*call)(LookupScope scope, UnitFileFlags flags, const char *root_dir, char *files[], InstallChange **changes, size_t *n_changes),
bool carries_install_info,
sd_bus_error *error) {
_cleanup_strv_free_ char **l = NULL;
UnitFileChange *changes = NULL;
InstallChange *changes = NULL;
size_t n_changes = 0;
UnitFileFlags flags;
int r;
@@ -2305,7 +2305,7 @@ static int method_enable_unit_files_generic(
if (r < 0)
return install_error(error, r, changes, n_changes);
return reply_unit_file_changes_and_free(m, message, carries_install_info ? r : -1, changes, n_changes, error);
return reply_install_changes_and_free(m, message, carries_install_info ? r : -1, changes, n_changes, error);
}
static int method_enable_unit_files_with_flags(sd_bus_message *message, void *userdata, sd_bus_error *error) {
@@ -2324,7 +2324,7 @@ static int method_link_unit_files(sd_bus_message *message, void *userdata, sd_bu
return method_enable_unit_files_generic(message, userdata, unit_file_link, false, error);
}
static int unit_file_preset_without_mode(LookupScope scope, UnitFileFlags flags, const char *root_dir, char **files, UnitFileChange **changes, size_t *n_changes) {
static int unit_file_preset_without_mode(LookupScope scope, UnitFileFlags flags, const char *root_dir, char **files, InstallChange **changes, size_t *n_changes) {
return unit_file_preset(scope, flags, root_dir, files, UNIT_FILE_PRESET_FULL, changes, n_changes);
}
@@ -2339,7 +2339,7 @@ static int method_mask_unit_files(sd_bus_message *message, void *userdata, sd_bu
static int method_preset_unit_files_with_mode(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_strv_free_ char **l = NULL;
UnitFileChange *changes = NULL;
InstallChange *changes = NULL;
size_t n_changes = 0;
Manager *m = ASSERT_PTR(userdata);
UnitFilePresetMode preset_mode;
@@ -2377,17 +2377,17 @@ static int method_preset_unit_files_with_mode(sd_bus_message *message, void *use
if (r < 0)
return install_error(error, r, changes, n_changes);
return reply_unit_file_changes_and_free(m, message, r, changes, n_changes, error);
return reply_install_changes_and_free(m, message, r, changes, n_changes, error);
}
static int method_disable_unit_files_generic(
sd_bus_message *message,
Manager *m,
int (*call)(LookupScope scope, UnitFileFlags flags, const char *root_dir, char *files[], UnitFileChange **changes, size_t *n_changes),
int (*call)(LookupScope scope, UnitFileFlags flags, const char *root_dir, char *files[], InstallChange **changes, size_t *n_changes),
sd_bus_error *error) {
_cleanup_strv_free_ char **l = NULL;
UnitFileChange *changes = NULL;
InstallChange *changes = NULL;
UnitFileFlags flags;
size_t n_changes = 0;
int r;
@@ -2428,7 +2428,7 @@ static int method_disable_unit_files_generic(
if (r < 0)
return install_error(error, r, changes, n_changes);
return reply_unit_file_changes_and_free(m, message, -1, changes, n_changes, error);
return reply_install_changes_and_free(m, message, -1, changes, n_changes, error);
}
static int method_disable_unit_files_with_flags(sd_bus_message *message, void *userdata, sd_bus_error *error) {
@@ -2445,7 +2445,7 @@ static int method_unmask_unit_files(sd_bus_message *message, void *userdata, sd_
static int method_revert_unit_files(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_strv_free_ char **l = NULL;
UnitFileChange *changes = NULL;
InstallChange *changes = NULL;
size_t n_changes = 0;
Manager *m = ASSERT_PTR(userdata);
int r;
@@ -2466,11 +2466,11 @@ static int method_revert_unit_files(sd_bus_message *message, void *userdata, sd_
if (r < 0)
return install_error(error, r, changes, n_changes);
return reply_unit_file_changes_and_free(m, message, -1, changes, n_changes, error);
return reply_install_changes_and_free(m, message, -1, changes, n_changes, error);
}
static int method_set_default_target(sd_bus_message *message, void *userdata, sd_bus_error *error) {
UnitFileChange *changes = NULL;
InstallChange *changes = NULL;
size_t n_changes = 0;
Manager *m = ASSERT_PTR(userdata);
const char *name;
@@ -2496,11 +2496,11 @@ static int method_set_default_target(sd_bus_message *message, void *userdata, sd
if (r < 0)
return install_error(error, r, changes, n_changes);
return reply_unit_file_changes_and_free(m, message, -1, changes, n_changes, error);
return reply_install_changes_and_free(m, message, -1, changes, n_changes, error);
}
static int method_preset_all_unit_files(sd_bus_message *message, void *userdata, sd_bus_error *error) {
UnitFileChange *changes = NULL;
InstallChange *changes = NULL;
size_t n_changes = 0;
Manager *m = ASSERT_PTR(userdata);
UnitFilePresetMode preset_mode;
@@ -2538,13 +2538,13 @@ static int method_preset_all_unit_files(sd_bus_message *message, void *userdata,
if (r < 0)
return install_error(error, r, changes, n_changes);
return reply_unit_file_changes_and_free(m, message, -1, changes, n_changes, error);
return reply_install_changes_and_free(m, message, -1, changes, n_changes, error);
}
static int method_add_dependency_unit_files(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_strv_free_ char **l = NULL;
Manager *m = ASSERT_PTR(userdata);
UnitFileChange *changes = NULL;
InstallChange *changes = NULL;
size_t n_changes = 0;
int runtime, force, r;
char *target, *type;
@@ -2577,12 +2577,12 @@ static int method_add_dependency_unit_files(sd_bus_message *message, void *userd
if (r < 0)
return install_error(error, r, changes, n_changes);
return reply_unit_file_changes_and_free(m, message, -1, changes, n_changes, error);
return reply_install_changes_and_free(m, message, -1, changes, n_changes, error);
}
static int method_get_unit_file_links(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
UnitFileChange *changes = NULL;
InstallChange *changes = NULL;
size_t n_changes = 0, i;
UnitFileFlags flags;
const char *name;