diff --git a/ChangeLog b/ChangeLog index 876ea8d0..84767881 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2011-05-03 Milan Broz + * Do not ignore size argument for create command (1.2.0). + 2011-04-18 Milan Broz * Fix error paths in blockwise code and lseek_write call. * Add Nettle crypto backend support. diff --git a/lib/setup.c b/lib/setup.c index 8cdcdf67..6d4b554c 100644 --- a/lib/setup.c +++ b/lib/setup.c @@ -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); diff --git a/man/cryptsetup.8 b/man/cryptsetup.8 index 3fd512ee..d9a96939 100644 --- a/man/cryptsetup.8 +++ b/man/cryptsetup.8 @@ -14,7 +14,7 @@ For basic (plain) dm-crypt mappings, there are four operations. creates a mapping with backed by device . \fB\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 .IP diff --git a/src/cryptsetup.c b/src/cryptsetup.c index b2377e01..ff38c723 100644 --- a/src/cryptsetup.c +++ b/src/cryptsetup.c @@ -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); diff --git a/tests/compat-test b/tests/compat-test index 7d02d999..43bb6397 100755 --- a/tests/compat-test +++ b/tests/compat-test @@ -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