unsigned i;
int r;
- if (n_changes > 0) {
- r = bus_foreach_bus(m, NULL, send_unit_files_changed, NULL);
- if (r < 0)
- log_debug_errno(r, "Failed to send UnitFilesChanged signal: %m");
- }
+ for (i = 0; i < n_changes; i++)
+ if (unit_file_change_is_modification(changes[i].type)) {
+ r = bus_foreach_bus(m, NULL, send_unit_files_changed, NULL);
+ if (r < 0)
+ log_debug_errno(r, "Failed to send UnitFilesChanged signal: %m");
+ break;
+ }
r = sd_bus_message_new_method_return(message, &reply);
if (r < 0)
if (!quiet) {
if (streq(type, "symlink"))
log_info("Created symlink from %s to %s.", path, source);
- else
+ else if (streq(type, "unlink"))
log_info("Removed symlink %s.", path);
+ else if (streq(type, "masked"))
+ log_info("Unit %s is masked, ignoring.", path);
+ else
+ log_notice("Manager reported unknown change type \"%s\" for %s.", type, path);
}
- r = unit_file_changes_add(changes, n_changes, streq(type, "symlink") ? UNIT_FILE_SYMLINK : UNIT_FILE_UNLINK, path, source);
+ r = unit_file_changes_add(changes, n_changes,
+ unit_file_change_type_from_string(type),
+ path, source);
if (r < 0)
return r;
}
continue;
r = preset_prepare_one(scope, &plus, &minus, &paths, mode, de->d_name);
+ if (r == -ERFKILL)
+ r = unit_file_changes_add(changes, n_changes,
+ UNIT_FILE_IS_MASKED, de->d_name, NULL);
if (r < 0)
return r;
}
static const char* const unit_file_change_type_table[_UNIT_FILE_CHANGE_TYPE_MAX] = {
[UNIT_FILE_SYMLINK] = "symlink",
[UNIT_FILE_UNLINK] = "unlink",
+ [UNIT_FILE_IS_MASKED] = "masked",
};
DEFINE_STRING_TABLE_LOOKUP(unit_file_change_type, UnitFileChangeType);
enum UnitFileChangeType {
UNIT_FILE_SYMLINK,
UNIT_FILE_UNLINK,
+ UNIT_FILE_IS_MASKED,
_UNIT_FILE_CHANGE_TYPE_MAX,
_UNIT_FILE_CHANGE_TYPE_INVALID = -1
};
+static inline bool unit_file_change_is_modification(UnitFileChangeType type) {
+ return IN_SET(type, UNIT_FILE_SYMLINK, UNIT_FILE_UNLINK);
+}
+
struct UnitFileChange {
UnitFileChangeType type;
char *path;
assert(changes || n_changes == 0);
- for (i = 0; i < n_changes; i++) {
- if (changes[i].type == UNIT_FILE_SYMLINK)
+ for (i = 0; i < n_changes; i++)
+ switch(changes[i].type) {
+ case UNIT_FILE_SYMLINK:
log_info("Created symlink %s, pointing to %s.", changes[i].path, changes[i].source);
- else
+ break;
+ case UNIT_FILE_UNLINK:
log_info("Removed %s.", changes[i].path);
- }
+ break;
+ case UNIT_FILE_IS_MASKED:
+ log_info("Unit %s is masked, ignoring.", changes[i].path);
+ break;
+ default:
+ assert_not_reached("bad change type");
+ }
}
static int set_default(int argc, char *argv[], void *userdata) {