]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
portabled: generate a more useful error when invalid image types are attempted to...
authorLennart Poettering <lennart@poettering.net>
Mon, 8 Oct 2018 15:58:34 +0000 (17:58 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 8 Oct 2018 16:49:45 +0000 (18:49 +0200)
Fixes: #10095
man/portablectl.xml
src/libsystemd/sd-bus/bus-common-errors.c
src/libsystemd/sd-bus/bus-common-errors.h
src/portable/portabled-image-bus.c

index 33b14ea065364a9074f3e460d9c81e9f6873c550..3a5517a4ade8a0fb508be39a5dd1419ac280b9ad 100644 (file)
@@ -59,7 +59,7 @@
       <listitem><para>btrfs subvolumes containing OS trees, similar to normal directory trees.</para></listitem>
 
       <listitem><para>Binary "raw" disk images containing MBR or GPT partition tables and Linux file system
-      partitions.</para></listitem>
+      partitions. (These must be regular files, with the <filename>.raw</filename> suffix.)</para></listitem>
     </itemizedlist>
 
   </refsect1>
index 8d6c5955492882aa8b22d146fad9ce8957f7d363..6e5fe00e06b03bc06c27f02623e9701cf58ac93c 100644 (file)
@@ -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),
index a76a93644caeccb2de0d5f5545579cc6835330c4..8339feb768618484db6becd64ac6506d0282c311 100644 (file)
@@ -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"
index 02a2db23524dbb50d25f0840cef474941d90da7e..0e1f7c5e87d0a73227e6fb51b324ff3c986a0ae8 100644 (file)
@@ -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;