Print error message if device exists but as other subsystem.

This commit is contained in:
Milan Broz
2017-07-26 10:53:29 +02:00
parent 6f2ff93519
commit 962bf58f8f

View File

@@ -2047,9 +2047,10 @@ int crypt_activate_by_passphrase(struct crypt_device *cd,
if (name) { if (name) {
ci = crypt_status(NULL, 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; return -EINVAL;
else if (ci >= CRYPT_ACTIVE) { } else if (ci >= CRYPT_ACTIVE) {
log_err(cd, _("Device %s already exists.\n"), name); log_err(cd, _("Device %s already exists.\n"), name);
return -EEXIST; return -EEXIST;
} }
@@ -2104,9 +2105,10 @@ int crypt_activate_by_keyfile_offset(struct crypt_device *cd,
if (name) { if (name) {
ci = crypt_status(NULL, 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; return -EINVAL;
else if (ci >= CRYPT_ACTIVE) { } else if (ci >= CRYPT_ACTIVE) {
log_err(cd, _("Device %s already exists.\n"), name); log_err(cd, _("Device %s already exists.\n"), name);
return -EEXIST; return -EEXIST;
} }
@@ -2198,9 +2200,10 @@ int crypt_activate_by_volume_key(struct crypt_device *cd,
if (name) { if (name) {
ci = crypt_status(NULL, 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; return -EINVAL;
else if (ci >= CRYPT_ACTIVE) { } else if (ci >= CRYPT_ACTIVE) {
log_err(cd, _("Device %s already exists.\n"), name); log_err(cd, _("Device %s already exists.\n"), name);
return -EEXIST; return -EEXIST;
} }