summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-03-01 16:09:57 +0100
committerLennart Poettering <lennart@poettering.net>2023-03-01 17:08:28 +0100
commit2348043f17aba9354b32d0182e00370241afc9c7 (patch)
treebbecb4a56013adc9e89a7a8ac7c26b3ec1328a02 /src
parent1016c8ad94976d7b211a2f002aafac19493823c7 (diff)
downloadsystemd-2348043f17aba9354b32d0182e00370241afc9c7.tar.gz
dissect: show intended architecture of a disk image
We already determine the architecture of disk images and make a choice, and store it per partition. Let's make this accessible globally.
Diffstat (limited to 'src')
-rw-r--r--src/dissect/dissect.c3
-rw-r--r--src/shared/dissect-image.c14
-rw-r--r--src/shared/dissect-image.h2
3 files changed, 19 insertions, 0 deletions
diff --git a/src/dissect/dissect.c b/src/dissect/dissect.c
index a6a5b9e210..f08e745a55 100644
--- a/src/dissect/dissect.c
+++ b/src/dissect/dissect.c
@@ -603,6 +603,9 @@ static int action_dissect(DissectedImage *m, LoopDevice *d) {
printf(" Sec. Size: %" PRIu32 "\n", m->sector_size);
+ printf(" Arch.: %s\n",
+ strna(architecture_to_string(dissected_image_architecture(m))));
+
if (arg_json_format_flags & JSON_FORMAT_OFF)
putc('\n', stdout);
diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c
index b20e21cce2..9636fd8d48 100644
--- a/src/shared/dissect-image.c
+++ b/src/shared/dissect-image.c
@@ -3156,6 +3156,20 @@ finish:
return r;
}
+Architecture dissected_image_architecture(DissectedImage *img) {
+ assert(img);
+
+ if (img->partitions[PARTITION_ROOT].found &&
+ img->partitions[PARTITION_ROOT].architecture >= 0)
+ return img->partitions[PARTITION_ROOT].architecture;
+
+ if (img->partitions[PARTITION_USR].found &&
+ img->partitions[PARTITION_USR].architecture >= 0)
+ return img->partitions[PARTITION_USR].architecture;
+
+ return _ARCHITECTURE_INVALID;
+}
+
int dissect_loop_device(
LoopDevice *loop,
const VeritySettings *verity,
diff --git a/src/shared/dissect-image.h b/src/shared/dissect-image.h
index 3efe784ee9..6b90895216 100644
--- a/src/shared/dissect-image.h
+++ b/src/shared/dissect-image.h
@@ -160,6 +160,8 @@ int dissected_image_mount_and_warn(DissectedImage *m, const char *where, uid_t u
int dissected_image_acquire_metadata(DissectedImage *m, DissectImageFlags extra_flags);
+Architecture dissected_image_architecture(DissectedImage *m);
+
DecryptedImage* decrypted_image_ref(DecryptedImage *p);
DecryptedImage* decrypted_image_unref(DecryptedImage *p);
DEFINE_TRIVIAL_CLEANUP_FUNC(DecryptedImage*, decrypted_image_unref);