Commit b93b6763 authored by Ondrej Kozina's avatar Ondrej Kozina Committed by Milan Broz

Move blkid scan after device context initialization.

Fixes bug with misleading error message when target device
does not exist.
parent 1c6d66fc
......@@ -987,20 +987,6 @@ static int action_luksFormat(void)
header_device = opt_header_device ?: action_argv[0];
/* Print all present signatures in read-only mode */
r = tools_detect_signatures(header_device, 0, &signatures);
if (r < 0)
return r;
r = asprintf(&msg, _("This will overwrite data on %s irrevocably."), header_device);
if (r == -1)
return -ENOMEM;
r = yesDialog(msg, _("Operation aborted.\n")) ? 0 : -EINVAL;
free(msg);
if (r < 0)
return r;
r = crypt_parse_name_and_mode(opt_cipher ?: DEFAULT_CIPHER(LUKS1),
cipher, NULL, cipher_mode);
if (r < 0) {
......@@ -1028,6 +1014,22 @@ static int action_luksFormat(void)
return r;
}
/* Print all present signatures in read-only mode */
r = tools_detect_signatures(header_device, 0, &signatures);
if (r < 0)
goto out;
r = asprintf(&msg, _("This will overwrite data on %s irrevocably."), header_device);
if (r == -1) {
r = -ENOMEM;
goto out;
}
r = yesDialog(msg, _("Operation aborted.\n")) ? 0 : -EINVAL;
free(msg);
if (r < 0)
goto out;
keysize = (opt_key_size ?: DEFAULT_LUKS1_KEYBITS) / 8 + integrity_keysize;
if (opt_random)
......
......@@ -209,24 +209,26 @@ static int action_format(int arg)
params.journal_crypt = journal_crypt;
}
r = tools_detect_signatures(action_argv[0], 0, &signatures);
r = _read_keys(&integrity_key, &params);
if (r)
goto out;
r = crypt_init(&cd, action_argv[0]);
if (r < 0)
return r;
goto out;
r = asprintf(&msg, _("This will overwrite data on %s irrevocably."), action_argv[0]);
if (r == -1)
return -ENOMEM;
if (r == -1) {
r = -ENOMEM;
goto out;
}
r = yesDialog(msg, _("Operation aborted.\n")) ? 0 : -EINVAL;
free(msg);
if (r < 0)
return r;
r = _read_keys(&integrity_key, &params);
if (r)
goto out;
r = crypt_init(&cd, action_argv[0]);
r = tools_detect_signatures(action_argv[0], 0, &signatures);
if (r < 0)
goto out;
......
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