From: Maanya Goenka Date: Mon, 9 Sep 2024 16:25:32 +0000 (+0000) Subject: src/sysext: Use versioned names when logging extensions used for merge operation X-Git-Tag: v257-rc1~491 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=25d1b968802fa181c4f1a37c69e27090cf6b60ad;p=thirdparty%2Fsystemd.git src/sysext: Use versioned names when logging extensions used for merge operation If this is not done, and there are two images, image_1.raw and image_2.raw under an image.raw.v folder, then the log will say "Using extensions image" instead of using "Using extensions image_2.raw" which is the desired behavior for v-picked extensions. --- diff --git a/src/sysext/sysext.c b/src/sysext/sysext.c index c696daad0dc..b40f5b7b47b 100644 --- a/src/sysext/sysext.c +++ b/src/sysext/sysext.c @@ -1476,8 +1476,8 @@ static int merge_subprocess( Hashmap *images, const char *workspace) { - _cleanup_free_ char *host_os_release_id = NULL, *host_os_release_version_id = NULL, *host_os_release_api_level = NULL, *buf = NULL; - _cleanup_strv_free_ char **extensions = NULL, **paths = NULL; + _cleanup_free_ char *host_os_release_id = NULL, *host_os_release_version_id = NULL, *host_os_release_api_level = NULL, *buf = NULL, *filename = NULL; + _cleanup_strv_free_ char **extensions = NULL, **extensions_v = NULL, **paths = NULL; size_t n_extensions = 0; unsigned n_ignored = 0; Image *img; @@ -1658,6 +1658,17 @@ static int merge_subprocess( if (r < 0) return log_oom(); + /* Also get the absolute file name with version info for logging. */ + r = path_extract_filename(img->path, &filename); + if (r == -ENOMEM) + return log_oom(); + if (r < 0) + return log_error_errno(r, "Failed to extract filename from '%s': %m", img->path); + + r = strv_extend(&extensions_v, filename); + if (r < 0) + return log_oom(); + n_extensions++; } @@ -1672,8 +1683,9 @@ static int merge_subprocess( /* Order by version sort with strverscmp_improved() */ typesafe_qsort(extensions, n_extensions, strverscmp_improvedp); + typesafe_qsort(extensions_v, n_extensions, strverscmp_improvedp); - buf = strv_join(extensions, "', '"); + buf = strv_join(extensions_v, "', '"); if (!buf) return log_oom();