From fa45d12c1c601a91bd85533f79158007b49971c1 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 11 Aug 2020 15:54:16 +0200 Subject: [PATCH] dissect: use recognizable error if we are supposed to mount an encrypted fs Also, document EBUSY --- src/shared/dissect-image.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c index 953598f2ff8..9a5a463b205 100644 --- a/src/shared/dissect-image.c +++ b/src/shared/dissect-image.c @@ -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; -- 2.47.3