# cryptsetup status /dev/nonexistent
Device /dev/nonexistent not found
Device /dev/nonexistent not found
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@330
36d66b0a-2a48-0410-832c-
cd162a569da5
* Rewrite file differ test to C (and fix it to really work).
* Switch to 1MiB default alignment of data.
For more info see https://bugzilla.redhat.com/show_bug.cgi?id=621684
+ * Do not query non-existent device twice (cryptsetup status /dev/nonexistent).
2010-07-28 Arno Wagner <arno@wagner.name>
* Add FAQ (Frequently Asked Questions) file to distribution.
int r = -EINVAL;
if (!(dmt = dm_task_create(DM_DEVICE_STATUS)))
- return -EINVAL;
+ goto out;
- if (!dm_task_set_name(dmt, name)) {
- r = -EINVAL;
+ if (!dm_task_set_name(dmt, name))
goto out;
- }
- if (!dm_task_run(dmt)) {
- r = -EINVAL;
+ if (!dm_task_run(dmt))
goto out;
- }
- if (!dm_task_get_info(dmt, &dmi)) {
- r = -EINVAL;
+ if (!dm_task_get_info(dmt, &dmi))
goto out;
- }
if (!dmi.exists) {
r = -ENODEV;
return -ENOSYS;
r = dm_status_device(options->name);
- if (r == -ENODEV) {
- dm_exit();
- return 0;
- }
+ if (r < 0)
+ goto out;
r = dm_query_device(options->name, (char **)&options->device, &options->size,
&options->skip, &options->offset, (char **)&options->cipher,
&options->key_size, NULL, &read_only, NULL, NULL);
+ if (r >= 0) {
+ if (read_only)
+ options->flags |= CRYPT_FLAG_READONLY;
- dm_exit();
- if (r < 0)
- return r;
-
- if (read_only)
- options->flags |= CRYPT_FLAG_READONLY;
+ options->flags |= CRYPT_FLAG_FREE_DEVICE;
+ options->flags |= CRYPT_FLAG_FREE_CIPHER;
- options->flags |= CRYPT_FLAG_FREE_DEVICE;
- options->flags |= CRYPT_FLAG_FREE_CIPHER;
+ r = 1;
+ }
+out:
+ if (r == -ENODEV)
+ r = 0;
- return 1;
+ dm_exit();
+ return r;
}
/* OPTIONS: name, icb */
static void query_device(void)
{
- struct crypt_options co = {. icb = &cmd_icb };
+ struct crypt_options co = {.icb = &cmd_icb };
co.name = CDEVICE_WRONG;
EQ_(crypt_query_device(&co), 0);
static void remove_device(void)
{
int fd;
- struct crypt_options co = {. icb = &cmd_icb };
+ struct crypt_options co = {.icb = &cmd_icb };
co.name = CDEVICE_WRONG;
EQ_(crypt_remove_device(&co), -ENODEV);