From 4fb8f1e88322b94b0fa051d3c6fd19cac0227aaa Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 29 Mar 2023 22:10:01 +0200 Subject: service: allow freeing the fdstore via cleaning Now that we have a potentially pinned fdstore let's add a concept for cleaning it explicitly on user requested. Let's expose this via "systemctl clean", i.e. the same way as user directories are cleaned. --- src/core/dbus-unit.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/core/dbus-unit.c') diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c index 3f083a8174..c01f41cb44 100644 --- a/src/core/dbus-unit.c +++ b/src/core/dbus-unit.c @@ -90,6 +90,12 @@ static int property_get_can_clean( return r; } + if (FLAGS_SET(mask, EXEC_CLEAN_FDSTORE)) { + r = sd_bus_message_append(reply, "s", "fdstore"); + if (r < 0) + return r; + } + return sd_bus_message_close_container(reply); } @@ -696,6 +702,7 @@ int bus_unit_method_clean(sd_bus_message *message, void *userdata, sd_bus_error return r; for (;;) { + ExecCleanMask m; const char *i; r = sd_bus_message_read(message, "s", &i); @@ -704,17 +711,11 @@ int bus_unit_method_clean(sd_bus_message *message, void *userdata, sd_bus_error if (r == 0) break; - if (streq(i, "all")) - mask |= EXEC_CLEAN_ALL; - else { - ExecDirectoryType t; - - t = exec_resource_type_from_string(i); - if (t < 0) - return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid resource type: %s", i); + m = exec_clean_mask_from_string(i); + if (m < 0) + return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid resource type: %s", i); - mask |= 1U << t; - } + mask |= m; } r = sd_bus_message_exit_container(message); -- cgit v1.2.1