]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dissect: use recognizable error if we are supposed to mount an encrypted fs
authorLennart Poettering <lennart@poettering.net>
Tue, 11 Aug 2020 13:54:16 +0000 (15:54 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 11 Aug 2020 20:26:48 +0000 (22:26 +0200)
Also, document EBUSY

src/shared/dissect-image.c

index 953598f2ff89e62f364ccfed09f3138a770d556c..9a5a463b205cad64afa14b56dec2db66fb658e7f 100644 (file)
@@ -1004,9 +1004,9 @@ static int mount_partition(
         if (!m->found || !node || !fstype)
                 return 0;
 
-        /* Stacked encryption? Yuck */
+        /* We are looking at an encrypted partition? This either means stacked encryption, or the caller didn't call dissected_image_decrypt() beforehand. Let's return a recognizable error for this case. */
         if (streq_ptr(fstype, "crypto_LUKS"))
-                return -ELOOP;
+                return -EUNATCH;
 
         rw = m->rw && !(flags & DISSECT_IMAGE_READ_ONLY);
 
@@ -1067,6 +1067,15 @@ int dissected_image_mount(DissectedImage *m, const char *where, uid_t uid_shift,
         assert(m);
         assert(where);
 
+        /* Returns:
+         *
+         *  -ENXIO        → No root partition found
+         *  -EMEDIUMTYPE  → DISSECT_IMAGE_VALIDATE_OS set but no os-release file found
+         *  -EUNATCH      → Encrypted partition found for which no dm-crypt was set up yet
+         *  -EUCLEAN      → fsck for file system failed
+         *  -EBUSY        → File system already mounted/used elsewhere (kernel)
+         */
+
         if (!m->partitions[PARTITION_ROOT].found)
                 return -ENXIO;