From: Lennart Poettering Date: Tue, 11 Aug 2020 13:54:16 +0000 (+0200) Subject: dissect: use recognizable error if we are supposed to mount an encrypted fs X-Git-Tag: v247-rc1~431^2~8 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fa45d12c1c601a91bd85533f79158007b49971c1;p=thirdparty%2Fsystemd.git dissect: use recognizable error if we are supposed to mount an encrypted fs Also, document EBUSY --- 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;