From: Luca Boccassi Date: Thu, 24 Mar 2022 14:47:00 +0000 (+0000) Subject: portable: clarify error when detach fails to match to existing unit X-Git-Tag: v251-rc1~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6b72105a780c0b88c81f979ce6d5651c5dee9b86;p=thirdparty%2Fsystemd.git portable: clarify error when detach fails to match to existing unit Clarify that it's looking at attached units, not at units inside the referenced image. Also take into account extensions. --- diff --git a/src/portable/portable.c b/src/portable/portable.c index 691aad5238d..3051760d0b9 100644 --- a/src/portable/portable.c +++ b/src/portable/portable.c @@ -1520,6 +1520,7 @@ int portable_detach( _cleanup_(lookup_paths_free) LookupPaths paths = {}; _cleanup_set_free_ Set *unit_files = NULL, *markers = NULL; + _cleanup_free_ char *extensions = NULL; _cleanup_closedir_ DIR *d = NULL; const char *where, *item; int ret = 0; @@ -1674,8 +1675,17 @@ int portable_detach( return ret; not_found: - log_debug("No unit files associated with '%s' found. Image not attached?", name_or_path); - return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT, "No unit files associated with '%s' found. Image not attached?", name_or_path); + extensions = strv_join(extension_image_paths, ", "); + if (!extensions) + return -ENOMEM; + + r = sd_bus_error_setf(error, + BUS_ERROR_NO_SUCH_UNIT, + "No unit files associated with '%s%s%s' found attached to the system. Image not attached?", + name_or_path, + isempty(extensions) ? "" : "' or any of its extensions '", + isempty(extensions) ? "" : extensions); + return log_debug_errno(r, "%s", error->message); } static int portable_get_state_internal(