core/dbus-unit: add an explicit bus error when unit is frozen by parent

While at it, use more accurate errno (EDEADLK) instead of ECHILD.
This commit is contained in:
Mike Yuan
2024-07-17 18:14:32 +02:00
parent e1ac52594d
commit 6798fa11d2
4 changed files with 5 additions and 3 deletions
+2 -2
View File
@@ -755,8 +755,8 @@ static int bus_unit_method_freezer_generic(sd_bus_message *message, void *userda
return sd_bus_error_set(error, BUS_ERROR_UNIT_INACTIVE, "Unit is not active");
if (r == -EALREADY)
return sd_bus_error_set(error, BUS_ERROR_UNIT_BUSY, "Previously requested freezer operation for unit is still in progress");
if (r == -ECHILD)
return sd_bus_error_set(error, SD_BUS_ERROR_FAILED, "Unit is frozen by a parent slice");
if (r == -EDEADLK)
return sd_bus_error_set(error, BUS_ERROR_FROZEN_BY_PARENT, "Unit is frozen by a parent slice");
if (r < 0)
return r;
+1 -1
View File
@@ -6308,7 +6308,7 @@ int unit_freezer_action(Unit *u, FreezerAction action) {
if (action == FREEZER_THAW && u->freezer_state == FREEZER_THAWING)
return -EALREADY;
if (action == FREEZER_THAW && IN_SET(u->freezer_state, FREEZER_FREEZING_BY_PARENT, FREEZER_FROZEN_BY_PARENT))
return -ECHILD;
return -EDEADLK;
r = UNIT_VTABLE(u)->freezer_action(u, action);
if (r <= 0)
@@ -34,6 +34,7 @@ BUS_ERROR_MAP_ELF_REGISTER const sd_bus_error_map bus_common_errors[] = {
SD_BUS_ERROR_MAP(BUS_ERROR_DISK_FULL, ENOSPC),
SD_BUS_ERROR_MAP(BUS_ERROR_FILE_DESCRIPTOR_STORE_DISABLED,
EHOSTDOWN),
SD_BUS_ERROR_MAP(BUS_ERROR_FROZEN_BY_PARENT, EDEADLK),
SD_BUS_ERROR_MAP(BUS_ERROR_NO_SUCH_MACHINE, ENXIO),
SD_BUS_ERROR_MAP(BUS_ERROR_NO_SUCH_IMAGE, ENOENT),
@@ -34,6 +34,7 @@
#define BUS_ERROR_FREEZE_CANCELLED "org.freedesktop.systemd1.FreezeCancelled"
#define BUS_ERROR_FILE_DESCRIPTOR_STORE_DISABLED \
"org.freedesktop.systemd1.FileDescriptorStoreDisabled"
#define BUS_ERROR_FROZEN_BY_PARENT "org.freedesktop.systemd1.FrozenByParent"
#define BUS_ERROR_NO_SUCH_MACHINE "org.freedesktop.machine1.NoSuchMachine"
#define BUS_ERROR_NO_SUCH_IMAGE "org.freedesktop.machine1.NoSuchImage"