mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-14 12:20:00 +01:00
Remove device even if underlying device disappeared.
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@240 36d66b0a-2a48-0410-832c-cd162a569da5
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
2010-05-27 Milan Broz <mbroz@redhat.com>
|
2010-05-27 Milan Broz <mbroz@redhat.com>
|
||||||
* Fix luksFormat/luksOpen reading passphrase from stdin and "-" keyfile.
|
* Fix luksFormat/luksOpen reading passphrase from stdin and "-" keyfile.
|
||||||
* Add verbose log level and move unlocking message there.
|
* Add verbose log level and move unlocking message there.
|
||||||
|
* Remove device even if underlying device disappeared.
|
||||||
|
|
||||||
2010-05-23 Milan Broz <mbroz@redhat.com>
|
2010-05-23 Milan Broz <mbroz@redhat.com>
|
||||||
* Fix luksClose operation for stacked DM devices.
|
* Fix luksClose operation for stacked DM devices.
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ static char *lookup_dev(const char *dev_id)
|
|||||||
{
|
{
|
||||||
uint32_t major, minor;
|
uint32_t major, minor;
|
||||||
dev_t dev;
|
dev_t dev;
|
||||||
char *result, buf[PATH_MAX + 1];
|
char *result = NULL, buf[PATH_MAX + 1];
|
||||||
|
|
||||||
if (sscanf(dev_id, "%" PRIu32 ":%" PRIu32, &major, &minor) != 2)
|
if (sscanf(dev_id, "%" PRIu32 ":%" PRIu32, &major, &minor) != 2)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -220,8 +220,8 @@ static char *lookup_dev(const char *dev_id)
|
|||||||
strncpy(buf, DEVICE_DIR, PATH_MAX);
|
strncpy(buf, DEVICE_DIR, PATH_MAX);
|
||||||
result = __lookup_dev(buf, dev, 0, 4);
|
result = __lookup_dev(buf, dev, 0, 4);
|
||||||
|
|
||||||
/* If not found, return major:minor */
|
/* If not found, return NULL */
|
||||||
return result ?: strdup(dev_id);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _dev_read_ahead(const char *dev, uint32_t *read_ahead)
|
static int _dev_read_ahead(const char *dev, uint32_t *read_ahead)
|
||||||
|
|||||||
14
lib/setup.c
14
lib/setup.c
@@ -741,10 +741,8 @@ int crypt_remove_device(struct crypt_options *options)
|
|||||||
int r;
|
int r;
|
||||||
|
|
||||||
r = crypt_init_by_name(&cd, options->name);
|
r = crypt_init_by_name(&cd, options->name);
|
||||||
if (r)
|
if (r == 0)
|
||||||
return r;
|
r = crypt_deactivate(cd, options->name);
|
||||||
|
|
||||||
r = crypt_deactivate(cd, options->name);
|
|
||||||
|
|
||||||
crypt_free(cd);
|
crypt_free(cd);
|
||||||
return r;
|
return r;
|
||||||
@@ -759,7 +757,7 @@ int crypt_luksFormat(struct crypt_options *options)
|
|||||||
char cipherMode[LUKS_CIPHERMODE_L];
|
char cipherMode[LUKS_CIPHERMODE_L];
|
||||||
char *password=NULL;
|
char *password=NULL;
|
||||||
unsigned int passwordLen;
|
unsigned int passwordLen;
|
||||||
struct crypt_device *cd;
|
struct crypt_device *cd = NULL;
|
||||||
struct crypt_params_luks1 cp = {
|
struct crypt_params_luks1 cp = {
|
||||||
.hash = options->hash,
|
.hash = options->hash,
|
||||||
.data_alignment = options->align_payload
|
.data_alignment = options->align_payload
|
||||||
@@ -1049,6 +1047,12 @@ int crypt_init_by_name(struct crypt_device **cd, const char *name)
|
|||||||
|
|
||||||
r = dm_query_device(name, &device, NULL, NULL, NULL,
|
r = dm_query_device(name, &device, NULL, NULL, NULL,
|
||||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
NULL, NULL, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
/* Underlying device disappeared but mapping still active */
|
||||||
|
if (r >= 0 && !device)
|
||||||
|
log_verbose(NULL, _("Underlying device for crypt device %s disappeared.\n"),
|
||||||
|
name);
|
||||||
|
|
||||||
if (r >= 0)
|
if (r >= 0)
|
||||||
r = crypt_init(cd, device);
|
r = crypt_init(cd, device);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user