+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
} arg_action = ACTION_DISSECT;
static const char *arg_image = NULL;
static const char *arg_path = NULL;
-static DissectImageFlags arg_flags = DISSECT_IMAGE_DISCARD_ON_LOOP;
+static DissectImageFlags arg_flags = DISSECT_IMAGE_REQUIRE_ROOT|DISSECT_IMAGE_DISCARD_ON_LOOP;
static void *arg_root_hash = NULL;
static size_t arg_root_hash_size = 0;
goto finish;
}
- r = dissect_image(d->fd, arg_root_hash, arg_root_hash_size, &m);
+ if (!arg_root_hash) {
+ r = root_hash_load(arg_image, &arg_root_hash, &arg_root_hash_size);
+ if (r < 0) {
+ log_error_errno(r, "Failed to read root hash file for %s: %m", arg_image);
+ goto finish;
+ }
+ }
+
+ r = dissect_image(d->fd, arg_root_hash, arg_root_hash_size, arg_flags, &m);
if (r == -ENOPKG) {
log_error_errno(r, "Couldn't identify a suitable partition table or file system in %s.", arg_image);
goto finish;
log_error_errno(r, "No root partition for specified root hash found in %s.", arg_image);
goto finish;
}
+ if (r == -ENOTUNIQ) {
+ log_error_errno(r, "Multiple suitable root partitions found in image %s.", arg_image);
+ goto finish;
+ }
+ if (r == -ENXIO) {
+ log_error_errno(r, "No suitable root partition found in image %s.", arg_image);
+ goto finish;
+ }
+ if (r == -EPROTONOSUPPORT) {
+ log_error_errno(r, "Device %s is loopback block device with partition scanning turned off, please turn it on.", arg_image);
+ goto finish;
+ }
if (r < 0) {
log_error_errno(r, "Failed to dissect image: %m");
goto finish;
p->rw ? "writable" : "read-only",
partition_designator_to_string(i));
+ if (!sd_id128_is_null(p->uuid))
+ printf(" (UUID " SD_ID128_FORMAT_STR ")", SD_ID128_FORMAT_VAL(p->uuid));
+
if (p->fstype)
printf(" of type %s", p->fstype);