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
This commit is contained in:
Milan Broz
2011-05-03 13:13:16 +00:00
parent 35d6914779
commit afd526a8c4
5 changed files with 21 additions and 3 deletions

View File

@@ -1,3 +1,6 @@
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> 2011-04-18 Milan Broz <mbroz@redhat.com>
* Fix error paths in blockwise code and lseek_write call. * Fix error paths in blockwise code and lseek_write call.
* Add Nettle crypto backend support. * Add Nettle crypto backend support.

View File

@@ -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, r = dm_create_device(name, cd->device, dm_cipher ?: cipher, cd->type, uuid, size, skip, offset,
key_size, processed_key, read_only, reload); 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: out:
free(dm_cipher); free(dm_cipher);
crypt_safe_free(processed_key); 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)) if (!cd->type || !crypt_get_uuid(cd))
return -EINVAL; return -EINVAL;
log_dbg("Resizing device %s to %" PRIu64 " sectors.", name, new_size);
r = dm_query_device(name, &device, &size, &skip, &offset, r = dm_query_device(name, &device, &size, &skip, &offset,
&cipher, &key_size, &key, &read_only, NULL, &uuid); &cipher, &key_size, &key, &read_only, NULL, &uuid);
if (r < 0) { if (r < 0) {
@@ -1429,8 +1435,6 @@ int crypt_resize(struct crypt_device *cd, const char *name, uint64_t new_size)
goto out; goto out;
} }
log_dbg("Resizing device %s to %" PRIu64 " sectors.", name, new_size);
r = dm_create_device(name, device, cipher, cd->type, r = dm_create_device(name, device, cipher, cd->type,
crypt_get_uuid(cd), new_size, skip, offset, crypt_get_uuid(cd), new_size, skip, offset,
key_size, key, read_only, 1); key_size, key, read_only, 1);

View File

@@ -14,7 +14,7 @@ For basic (plain) dm-crypt mappings, there are four operations.
creates a mapping with <name> backed by device <device>. creates a mapping with <name> backed by device <device>.
\fB<options>\fR can be [\-\-hash, \-\-cipher, \-\-verify-passphrase, \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 .PP
\fIremove\fR <name> \fIremove\fR <name>
.IP .IP

View File

@@ -279,6 +279,14 @@ static int action_create(int arg __attribute__((unused)))
CRYPT_ANY_SLOT, password, passwordLen, CRYPT_ANY_SLOT, password, passwordLen,
opt_readonly ? CRYPT_ACTIVATE_READONLY : 0); 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: out:
crypt_free(cd); crypt_free(cd);
crypt_safe_free(password); crypt_safe_free(password);

View File

@@ -259,6 +259,9 @@ echo "key0" | $CRYPTSETUP create $DEV_NAME --hash sha1 $LOOPDEV || fail
$CRYPTSETUP -q remove $DEV_NAME || fail $CRYPTSETUP -q remove $DEV_NAME || fail
echo "key0" | $CRYPTSETUP -q create $DEV_NAME --hash sha1 $LOOPDEV || fail echo "key0" | $CRYPTSETUP -q create $DEV_NAME --hash sha1 $LOOPDEV || fail
$CRYPTSETUP -q remove $DEV_NAME || 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 # verify is ignored on non-tty input
echo "key0" | $CRYPTSETUP create $DEV_NAME $LOOPDEV --hash sha1 --verify-passphrase || fail echo "key0" | $CRYPTSETUP create $DEV_NAME $LOOPDEV --hash sha1 --verify-passphrase || fail
$CRYPTSETUP -q remove $DEV_NAME || fail $CRYPTSETUP -q remove $DEV_NAME || fail