/* SPDX-License-Identifier: LGPL-2.1+ */
-/***
- This file is part of systemd.
-
- Copyright 2016 Lennart Poettering
-
- systemd is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
#include <fcntl.h>
#include <stdio.h>
#include "loop-util.h"
#include "string-util.h"
#include "strv.h"
+#include "user-util.h"
#include "util.h"
static enum {
r = unhexmem(optarg, strlen(optarg), &p, &l);
if (r < 0)
- return log_error_errno(r, "Failed to parse root hash: %s", optarg);
+ return log_error_errno(r, "Failed to parse root hash '%s': %m", optarg);
if (l < sizeof(sd_id128_t)) {
log_error("Root hash must be at least 128bit long: %s", optarg);
free(p);
}
}
- 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;
- }
- if (r == -EADDRNOTAVAIL) {
- 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);
+ r = dissect_image_and_warn(d->fd, arg_image, arg_root_hash, arg_root_hash_size, arg_flags, &m);
+ if (r < 0)
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;
- }
switch (arg_action) {
if (r < 0)
goto finish;
- r = dissected_image_mount(m, arg_path, arg_flags);
+ r = dissected_image_mount(m, arg_path, UID_INVALID, arg_flags);
if (r < 0) {
log_error_errno(r, "Failed to mount image: %m");
goto finish;