From 0f01320ec735946a608440a884dc04837b0d945a Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 9 Nov 2022 11:37:19 +0100 Subject: [PATCH 1/3] dissect: remove unused variable --- src/dissect/dissect.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/dissect/dissect.c b/src/dissect/dissect.c index 668534a663..7e70ecf7a8 100644 --- a/src/dissect/dissect.c +++ b/src/dissect/dissect.c @@ -889,7 +889,6 @@ static int action_list_or_copy(DissectedImage *m, LoopDevice *d) { } else { _cleanup_close_ int dfd = -1; - _cleanup_strv_free_ char **list_dir = NULL; assert(arg_action == ACTION_LIST); @@ -897,7 +896,7 @@ static int action_list_or_copy(DissectedImage *m, LoopDevice *d) { if (dfd < 0) return log_error_errno(errno, "Failed to open mount directory: %m"); - r = recurse_dir(dfd, NULL, 0, UINT_MAX, RECURSE_DIR_SORT|RECURSE_DIR_ENSURE_TYPE|RECURSE_DIR_SAME_MOUNT, list_print_item, &list_dir); + r = recurse_dir(dfd, NULL, 0, UINT_MAX, RECURSE_DIR_SORT|RECURSE_DIR_ENSURE_TYPE|RECURSE_DIR_SAME_MOUNT, list_print_item, NULL); if (r < 0) return log_error_errno(r, "Failed to list image: %m"); } From a245225e2d3f1193389c7dc35d2da02543fd8ac8 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 9 Nov 2022 11:37:42 +0100 Subject: [PATCH 2/3] dissect: simplify flags for recurse_dir() We are not interested in the struct dirent data, hence there's no point in passing RECURSE_DIR_ENSURE_TYPE. Let's drop it, and thus avoid some extrac work on file systems where readdir() does not report .d_type. Also drop RECURSE_DIR_SAME_MOUNT, because DDIs after all may contain multiple partitions, and we mount them all together. The --list command really should report the full set of files in an image. --- src/dissect/dissect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dissect/dissect.c b/src/dissect/dissect.c index 7e70ecf7a8..dafd474a30 100644 --- a/src/dissect/dissect.c +++ b/src/dissect/dissect.c @@ -896,7 +896,7 @@ static int action_list_or_copy(DissectedImage *m, LoopDevice *d) { if (dfd < 0) return log_error_errno(errno, "Failed to open mount directory: %m"); - r = recurse_dir(dfd, NULL, 0, UINT_MAX, RECURSE_DIR_SORT|RECURSE_DIR_ENSURE_TYPE|RECURSE_DIR_SAME_MOUNT, list_print_item, NULL); + r = recurse_dir(dfd, NULL, 0, UINT_MAX, RECURSE_DIR_SORT, list_print_item, NULL); if (r < 0) return log_error_errno(r, "Failed to list image: %m"); } From 2e1f76f6ea714c7db9f6acecda733493281ca47c Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 9 Nov 2022 11:52:50 +0100 Subject: [PATCH 3/3] dissect: open pager in --list mode, output might be long --- src/dissect/dissect.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/dissect/dissect.c b/src/dissect/dissect.c index dafd474a30..f2851e25f8 100644 --- a/src/dissect/dissect.c +++ b/src/dissect/dissect.c @@ -896,6 +896,8 @@ static int action_list_or_copy(DissectedImage *m, LoopDevice *d) { if (dfd < 0) return log_error_errno(errno, "Failed to open mount directory: %m"); + pager_open(arg_pager_flags); + r = recurse_dir(dfd, NULL, 0, UINT_MAX, RECURSE_DIR_SORT, list_print_item, NULL); if (r < 0) return log_error_errno(r, "Failed to list image: %m");