Fix size argument for create command. (regression in 1.2.0)
authorMilan Broz <gmazyland@gmail.com>
Tue, 3 May 2011 13:13:16 +0000 (13:13 +0000)
committerMilan Broz <gmazyland@gmail.com>
Tue, 3 May 2011 13:13:16 +0000 (13:13 +0000)
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@518 36d66b0a-2a48-0410-832c-cd162a569da5

ChangeLog
lib/setup.c
man/cryptsetup.8
src/cryptsetup.c
tests/compat-test

index 876ea8d03da2efff9c8cbf66ded850f74c58a47f..84767881c1c62b1ba7c7da90271c271ff58bd686 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
        * Fix error paths in blockwise code and lseek_write call.
        * Add Nettle crypto backend support.
index 8cdcdf67576a38e34a07e55d5d381f9d5a0cabaf..6d4b554c027a2b05b42dccb3780954e8d7f46cce 100644 (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,
                             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);
index 3fd512ee9de8dc8e1f1401ac5da5f0567b83b9b2..d9a96939577bbb42b696499574d7928f27475748 100644 (file)
@@ -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
index b2377e0192cf7139cc416682391d890270ddbbee..ff38c72348bb94d4d87bf5a591ddbf9961e4d4d8 100644 (file)
@@ -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);
index 7d02d999330d1bd94c4c7ff23605658dc6d7dd04..43bb63978c8bec3ce8fe814b23325be1968d0cad 100755 (executable)
@@ -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