Commit afd526a8 authored by Milan Broz's avatar Milan Broz

Fix size argument for create command. (regression in 1.2.0)

git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@518 36d66b0a-2a48-0410-832c-cd162a569da5
parent 35d69147
2011-05-03 Milan Broz <mbroz@redhat.com>
* Do not ignore size argument for create command (1.2.0).
2011-04-18 Milan Broz <mbroz@redhat.com>
* Fix error paths in blockwise code and lseek_write call.
* Add Nettle crypto backend support.
......
......@@ -399,6 +399,10 @@ static int create_device_helper(struct crypt_device *cd,
r = dm_create_device(name, cd->device, dm_cipher ?: cipher, cd->type, uuid, size, skip, offset,
key_size, processed_key, read_only, reload);
if (isPLAIN(cd->type) && !uuid)
(void)dm_query_device(name, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, &cd->plain_uuid);
out:
free(dm_cipher);
crypt_safe_free(processed_key);
......@@ -1406,6 +1410,8 @@ int crypt_resize(struct crypt_device *cd, const char *name, uint64_t new_size)
if (!cd->type || !crypt_get_uuid(cd))
return -EINVAL;
log_dbg("Resizing device %s to %" PRIu64 " sectors.", name, new_size);
r = dm_query_device(name, &device, &size, &skip, &offset,
&cipher, &key_size, &key, &read_only, NULL, &uuid);
if (r < 0) {
......@@ -1429,8 +1435,6 @@ int crypt_resize(struct crypt_device *cd, const char *name, uint64_t new_size)
goto out;
}
log_dbg("Resizing device %s to %" PRIu64 " sectors.", name, new_size);
r = dm_create_device(name, device, cipher, cd->type,
crypt_get_uuid(cd), new_size, skip, offset,
key_size, key, read_only, 1);
......
......@@ -14,7 +14,7 @@ For basic (plain) dm-crypt mappings, there are four operations.
creates a mapping with <name> backed by device <device>.
\fB<options>\fR can be [\-\-hash, \-\-cipher, \-\-verify-passphrase,
\-\-key-file, \-\-key-size, \-\-offset, \-\-skip, \-\-readonly]
\-\-key-file, \-\-key-size, \-\-offset, \-\-skip, \-\-size, \-\-readonly]
.PP
\fIremove\fR <name>
.IP
......
......@@ -279,6 +279,14 @@ static int action_create(int arg __attribute__((unused)))
CRYPT_ANY_SLOT, password, passwordLen,
opt_readonly ? CRYPT_ACTIVATE_READONLY : 0);
}
/* FIXME: workaround, new api missing format parameter for size.
* Properly fix it after bumping library version,
* add start_offset and size into "PLAIN" format specifiers.
*/
if (r >= 0 && opt_size)
r = crypt_resize(cd, action_argv[0], opt_size);
out:
crypt_free(cd);
crypt_safe_free(password);
......
......@@ -259,6 +259,9 @@ echo "key0" | $CRYPTSETUP create $DEV_NAME --hash sha1 $LOOPDEV || fail
$CRYPTSETUP -q remove $DEV_NAME || fail
echo "key0" | $CRYPTSETUP -q create $DEV_NAME --hash sha1 $LOOPDEV || fail
$CRYPTSETUP -q remove $DEV_NAME || fail
echo "key0" | $CRYPTSETUP -q create $DEV_NAME --hash sha1 --size 100 $LOOPDEV || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "100 sectors" || fail
$CRYPTSETUP -q remove $DEV_NAME || fail
# verify is ignored on non-tty input
echo "key0" | $CRYPTSETUP create $DEV_NAME $LOOPDEV --hash sha1 --verify-passphrase || fail
$CRYPTSETUP -q remove $DEV_NAME || fail
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment