From: Lennart Poettering Date: Mon, 8 Oct 2018 15:58:34 +0000 (+0200) Subject: portabled: generate a more useful error when invalid image types are attempted to... X-Git-Tag: v240~597^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=787dfb82f5228e4d6c955385ed62ea204a675a58;p=thirdparty%2Fsystemd.git portabled: generate a more useful error when invalid image types are attempted to be attached Fixes: #10095 --- diff --git a/man/portablectl.xml b/man/portablectl.xml index 33b14ea0653..3a5517a4ade 100644 --- a/man/portablectl.xml +++ b/man/portablectl.xml @@ -59,7 +59,7 @@ btrfs subvolumes containing OS trees, similar to normal directory trees. Binary "raw" disk images containing MBR or GPT partition tables and Linux file system - partitions. + partitions. (These must be regular files, with the .raw suffix.) diff --git a/src/libsystemd/sd-bus/bus-common-errors.c b/src/libsystemd/sd-bus/bus-common-errors.c index 8d6c5955492..6e5fe00e06b 100644 --- a/src/libsystemd/sd-bus/bus-common-errors.c +++ b/src/libsystemd/sd-bus/bus-common-errors.c @@ -42,6 +42,7 @@ BUS_ERROR_MAP_ELF_REGISTER const sd_bus_error_map bus_common_errors[] = { SD_BUS_ERROR_MAP(BUS_ERROR_NO_SUCH_GROUP_MAPPING, ENXIO), SD_BUS_ERROR_MAP(BUS_ERROR_NO_SUCH_PORTABLE_IMAGE, ENOENT), + SD_BUS_ERROR_MAP(BUS_ERROR_BAD_PORTABLE_IMAGE_TYPE, EMEDIUMTYPE), SD_BUS_ERROR_MAP(BUS_ERROR_NO_SUCH_SESSION, ENXIO), SD_BUS_ERROR_MAP(BUS_ERROR_NO_SESSION_FOR_PID, ENXIO), diff --git a/src/libsystemd/sd-bus/bus-common-errors.h b/src/libsystemd/sd-bus/bus-common-errors.h index a76a93644ca..8339feb7686 100644 --- a/src/libsystemd/sd-bus/bus-common-errors.h +++ b/src/libsystemd/sd-bus/bus-common-errors.h @@ -37,6 +37,7 @@ #define BUS_ERROR_NO_SUCH_GROUP_MAPPING "org.freedesktop.machine1.NoSuchGroupMapping" #define BUS_ERROR_NO_SUCH_PORTABLE_IMAGE "org.freedesktop.portable1.NoSuchImage" +#define BUS_ERROR_BAD_PORTABLE_IMAGE_TYPE "org.freedesktop.portable1.BadImageType" #define BUS_ERROR_NO_SUCH_SESSION "org.freedesktop.login1.NoSuchSession" #define BUS_ERROR_NO_SESSION_FOR_PID "org.freedesktop.login1.NoSessionForPID" diff --git a/src/portable/portabled-image-bus.c b/src/portable/portabled-image-bus.c index 02a2db23524..0e1f7c5e87d 100644 --- a/src/portable/portabled-image-bus.c +++ b/src/portable/portabled-image-bus.c @@ -636,6 +636,10 @@ int bus_image_acquire( r = image_from_path(name_or_path, &loaded); } + if (r == -EMEDIUMTYPE) { + sd_bus_error_setf(error, BUS_ERROR_BAD_PORTABLE_IMAGE_TYPE, "Typ of image '%s' not recognized; supported image types are directories/btrfs subvolumes, block devices, and raw disk image files with suffix '.raw'.", name_or_path); + return r; + } if (r < 0) return r;