*
* Copyright (C) 2004, Christophe Saout <christophe@saout.de>
* Copyright (C) 2004-2007, Clemens Fruhwirth <clemens@endorphin.org>
- * Copyright (C) 2009-2011, Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2009-2012, Red Hat, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <stdio.h>
static char *get_params(struct crypt_dm_active_device *dmd)
{
- int r, max_size;
- char *params, *hexkey, *features = "";
+ int r, max_size, null_cipher = 0;
+ char *params, *hexkey;
+ const char *features = "";
if (dmd->flags & CRYPT_ACTIVATE_ALLOW_DISCARDS) {
if (dm_flags() & DM_DISCARDS_SUPPORTED) {
- features =" 1 allow_discards";
+ features = " 1 allow_discards";
log_dbg("Discard/TRIM is allowed.");
} else
log_dbg("Discard/TRIM is not supported by the kernel.");
}
- hexkey = crypt_safe_alloc(dmd->vk->keylength * 2 + 1);
+ if (!strncmp(dmd->cipher, "cipher_null-", 12))
+ null_cipher = 1;
+
+ hexkey = crypt_safe_alloc(null_cipher ? 2 : (dmd->vk->keylength * 2 + 1));
if (!hexkey)
return NULL;
- hex_key(hexkey, dmd->vk->keylength, dmd->vk->key);
+ if (null_cipher)
+ strncpy(hexkey, "-", 2);
+ else
+ hex_key(hexkey, dmd->vk->keylength, dmd->vk->key);
max_size = strlen(hexkey) + strlen(dmd->cipher) +
strlen(dmd->device) + strlen(features) + 64;
if (name && !dm_task_set_name(dmt, name))
goto out;
+#if HAVE_DECL_DM_TASK_RETRY_REMOVE
+ /* Used only in DM_DEVICE_REMOVE */
+ if (name && !dm_task_retry_remove(dmt))
+ goto out;
+#endif
if (udev_wait && !_dm_task_set_cookie(dmt, &cookie, 0))
goto out;
struct dm_task *dmt = NULL;
struct dm_info dmi;
char *params = NULL;
- char *error = NULL;
char dev_uuid[DM_UUID_LEN] = {0};
int r = -EINVAL;
uint32_t read_ahead = 0;
if (!params)
goto out_no_removal;
- if (type && !strncmp(type, "TEMP", 4))
+ if (dmd->flags & CRYPT_ACTIVATE_PRIVATE)
udev_flags = CRYPT_TEMP_UDEV_FLAGS;
/* All devices must have DM_UUID, only resize on old device is exception */
cookie = 0;
}
- if (r < 0 && !reload) {
- if (get_error())
- error = strdup(get_error());
-
+ if (r < 0 && !reload)
dm_remove_device(name, 0, 0);
- if (error) {
- set_error(error);
- free(error);
- }
- }
-
out_no_removal:
if (cookie && _dm_use_udev())
(void)_dm_udev_wait(cookie);