From 962bf58f8f560f0cc20ec4a22ea63f556cc2c2cd Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Wed, 26 Jul 2017 10:53:29 +0200 Subject: [PATCH] Print error message if device exists but as other subsystem. --- lib/setup.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/setup.c b/lib/setup.c index 61920e13..b3cff2e5 100644 --- a/lib/setup.c +++ b/lib/setup.c @@ -2047,9 +2047,10 @@ int crypt_activate_by_passphrase(struct crypt_device *cd, if (name) { ci = crypt_status(NULL, name); - if (ci == CRYPT_INVALID) + if (ci == CRYPT_INVALID) { + log_err(cd, _("Cannot use device %s, name is invalid or still in use.\n"), name); return -EINVAL; - else if (ci >= CRYPT_ACTIVE) { + } else if (ci >= CRYPT_ACTIVE) { log_err(cd, _("Device %s already exists.\n"), name); return -EEXIST; } @@ -2104,9 +2105,10 @@ int crypt_activate_by_keyfile_offset(struct crypt_device *cd, if (name) { ci = crypt_status(NULL, name); - if (ci == CRYPT_INVALID) + if (ci == CRYPT_INVALID) { + log_err(cd, _("Cannot use device %s, name is invalid or still in use.\n"), name); return -EINVAL; - else if (ci >= CRYPT_ACTIVE) { + } else if (ci >= CRYPT_ACTIVE) { log_err(cd, _("Device %s already exists.\n"), name); return -EEXIST; } @@ -2198,9 +2200,10 @@ int crypt_activate_by_volume_key(struct crypt_device *cd, if (name) { ci = crypt_status(NULL, name); - if (ci == CRYPT_INVALID) + if (ci == CRYPT_INVALID) { + log_err(cd, _("Cannot use device %s, name is invalid or still in use.\n"), name); return -EINVAL; - else if (ci >= CRYPT_ACTIVE) { + } else if (ci >= CRYPT_ACTIVE) { log_err(cd, _("Device %s already exists.\n"), name); return -EEXIST; }