summaryrefslogtreecommitdiff
path: root/src/dissect
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2020-08-11 15:59:44 +0200
committerLennart Poettering <lennart@poettering.net>2020-08-11 22:29:50 +0200
commitaf8219d5620e53e867a371641dd07185e90f2e18 (patch)
tree3e753e4df3b166f41be93662052c494ace172913 /src/dissect
parentaf187ab237827788c8361170e851ef02d9a3b1bd (diff)
downloadsystemd-af8219d5620e53e867a371641dd07185e90f2e18.tar.gz
dissect: show proper error strings for more errors
Also, make inability to decrypt and EBUSY a non-fatal issue, since we still are able to display the mount table then.
Diffstat (limited to 'src/dissect')
-rw-r--r--src/dissect/dissect.c59
1 files changed, 34 insertions, 25 deletions
diff --git a/src/dissect/dissect.c b/src/dissect/dissect.c
index f575e1b28b..d6b6303ee1 100644
--- a/src/dissect/dissect.c
+++ b/src/dissect/dissect.c
@@ -323,14 +323,6 @@ static int action_dissect(DissectedImage *m, LoopDevice *d) {
assert(m);
assert(d);
- r = dissected_image_acquire_metadata(m);
- if (r == -EMEDIUMTYPE)
- return log_error_errno(r, "Not a valid OS image, no os-release file included.");
- if (r == -ENXIO)
- return log_error_errno(r, "No root partition discovered.");
- if (r < 0)
- return log_error_errno(r, "Failed to acquire image metadata: %m");
-
printf(" Name: %s\n", basename(arg_image));
if (ioctl(d->fd, BLKGETSIZE64, &size) < 0)
@@ -340,28 +332,45 @@ static int action_dissect(DissectedImage *m, LoopDevice *d) {
printf(" Size: %s\n", format_bytes(s, sizeof(s), size));
}
- if (m->hostname)
- printf(" Hostname: %s\n", m->hostname);
+ putc('\n', stdout);
+
+ r = dissected_image_acquire_metadata(m);
+ if (r == -ENXIO)
+ return log_error_errno(r, "No root partition discovered.");
+ if (r == -EMEDIUMTYPE)
+ return log_error_errno(r, "Not a valid OS image, no os-release file included.");
+ if (r == -EUCLEAN)
+ return log_error_errno(r, "File system check of image failed.");
+ if (r == -EUNATCH)
+ log_warning_errno(r, "OS image is encrypted, proceeding without showing OS image metadata.");
+ else if (r == -EBUSY)
+ log_warning_errno(r, "OS image is currently in use, proceeding without showing OS image metadata.");
+ else if (r < 0)
+ return log_error_errno(r, "Failed to acquire image metadata: %m");
+ else {
+ if (m->hostname)
+ printf(" Hostname: %s\n", m->hostname);
- if (!sd_id128_is_null(m->machine_id))
- printf("Machine ID: " SD_ID128_FORMAT_STR "\n", SD_ID128_FORMAT_VAL(m->machine_id));
+ if (!sd_id128_is_null(m->machine_id))
+ printf("Machine ID: " SD_ID128_FORMAT_STR "\n", SD_ID128_FORMAT_VAL(m->machine_id));
- if (!strv_isempty(m->machine_info)) {
- char **p, **q;
+ if (!strv_isempty(m->machine_info)) {
+ char **p, **q;
- STRV_FOREACH_PAIR(p, q, m->machine_info)
- printf("%s %s=%s\n",
- p == m->machine_info ? "Mach. Info:" : " ",
- *p, *q);
- }
+ STRV_FOREACH_PAIR(p, q, m->machine_info)
+ printf("%s %s=%s\n",
+ p == m->machine_info ? "Mach. Info:" : " ",
+ *p, *q);
+ }
- if (!strv_isempty(m->os_release)) {
- char **p, **q;
+ if (!strv_isempty(m->os_release)) {
+ char **p, **q;
- STRV_FOREACH_PAIR(p, q, m->os_release)
- printf("%s %s=%s\n",
- p == m->os_release ? "OS Release:" : " ",
- *p, *q);
+ STRV_FOREACH_PAIR(p, q, m->os_release)
+ printf("%s %s=%s\n",
+ p == m->os_release ? "OS Release:" : " ",
+ *p, *q);
+ }
}
putc('\n', stdout);