* [dm-crypt] Question about "An example of using LUKS device through libcryptsetup API"
@ 2015-09-26 1:03 H McCurdy
2015-09-26 6:11 ` Milan Broz
0 siblings, 1 reply; 3+ messages in thread
From: H McCurdy @ 2015-09-26 1:03 UTC (permalink / raw)
To: dm-crypt@saout.de
[-- Attachment #1: Type: text/plain, Size: 1463 bytes --]
Hi,
The program code is published athttps://gitlab.com/cryptsetup/cryptsetup/wikis/API/index.html
Looking in
static int handle_active_device(const char *device_name)
at
if (crypt_status(cd, device_name) == CRYPT_ACTIVE)
printf("Device %s is still active.\n", device_name);
else {
printf("Something failed perhaps, device %s is not active.\n", device_name);
crypt_free(cd);
return -1;
}
/*
* crypt_deactivate() is used to deactivate device
*/
r = crypt_deactivate(cd, device_name);
if (r < 0) {
printf("crypt_deactivate() failed.\n");
crypt_free(cd);
return r;
}
But if I look in /usr/include/libcryptsetup.h, I see
typedef enum {
CRYPT_INVALID, /**< device mapping is invalid in this context */
CRYPT_INACTIVE, /**< no such mapped device */
CRYPT_ACTIVE, /**< device is active */
CRYPT_BUSY /**< device is active and has open count > 0 */
} crypt_status_info;
and
crypt_status_info crypt_status(struct crypt_device *cd, const char *name);
It appears to me that the code flow is good since we probably can't deactivate a busy container
but it appears to me that the error is misleading in the event of CRYPT_BUSY because the message
indicates the device isn't active.
Am I interpreting correctly?
Hugh
[-- Attachment #2: Type: text/html, Size: 3548 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [dm-crypt] Question about "An example of using LUKS device through libcryptsetup API"
2015-09-26 1:03 [dm-crypt] Question about "An example of using LUKS device through libcryptsetup API" H McCurdy
@ 2015-09-26 6:11 ` Milan Broz
2015-09-26 19:13 ` H McCurdy
0 siblings, 1 reply; 3+ messages in thread
From: Milan Broz @ 2015-09-26 6:11 UTC (permalink / raw)
To: H McCurdy, dm-crypt@saout.de
On 09/26/2015 03:03 AM, H McCurdy wrote:
> Hi,
>
> The program code is published at
> https://gitlab.com/cryptsetup/cryptsetup/wikis/API/index.html
>
> Looking in
>
> static int handle_active_device(const char *device_name)
>
> at
> if (crypt_status(cd, device_name) == CRYPT_ACTIVE)
> printf("Device %s is still active.\n", device_name);
> else {
> printf("Something failed perhaps, device %s is not active.\n", device_name);
> crypt_free(cd);
> return -1;
> }
>
> /*
> * crypt_deactivate() is used to deactivate device
> */
> r = crypt_deactivate(cd, device_name);
> if (r < 0) {
> printf("crypt_deactivate() failed.\n");
> crypt_free(cd);
> return r;
> }
>
> But if I look in /usr/include/libcryptsetup.h, I see
>
> typedef enum {
> CRYPT_INVALID, /**< device mapping is invalid in this context */
> CRYPT_INACTIVE, /**< no such mapped device */
> CRYPT_ACTIVE, /**< device is active */
> CRYPT_BUSY /**< device is active and has open count > 0 */
> } crypt_status_info;
>
> and
>
> crypt_status_info crypt_status(struct crypt_device *cd, const char *name);
>
> It appears to me that the code flow is good since we probably can't deactivate a busy container
> but it appears to me that the error is misleading in the event of CRYPT_BUSY because the message
> indicates the device isn't active.
>
> Am I interpreting correctly?
Yes, that example should probably handle busy device differently.
Anyway, you will receive error message "Device ... is still in use." before the printf above.
Milan
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [dm-crypt] Question about "An example of using LUKS device through libcryptsetup API"
2015-09-26 6:11 ` Milan Broz
@ 2015-09-26 19:13 ` H McCurdy
0 siblings, 0 replies; 3+ messages in thread
From: H McCurdy @ 2015-09-26 19:13 UTC (permalink / raw)
To: Milan Broz, dm-crypt@saout.de
[-- Attachment #1: Type: text/plain, Size: 2290 bytes --]
Thanks Milan,
What I'm trying to do is write my own program that is fairly automatic and smart. If the device is busy, it may want to try again.
The information you provided helps me. Thank you.
Hugh
On Saturday, September 26, 2015 2:12 AM, Milan Broz <gmazyland@gmail.com> wrote:
On 09/26/2015 03:03 AM, H McCurdy wrote:
> Hi,
>
> The program code is published at
> https://gitlab.com/cryptsetup/cryptsetup/wikis/API/index.html
>
> Looking in
>
> static int handle_active_device(const char *device_name)
>
> at
> if (crypt_status(cd, device_name) == CRYPT_ACTIVE)
> printf("Device %s is still active.\n", device_name);
> else {
> printf("Something failed perhaps, device %s is not active.\n", device_name);
> crypt_free(cd);
> return -1;
> }
>
> /*
> * crypt_deactivate() is used to deactivate device
> */
> r = crypt_deactivate(cd, device_name);
> if (r < 0) {
> printf("crypt_deactivate() failed.\n");
> crypt_free(cd);
> return r;
> }
>
> But if I look in /usr/include/libcryptsetup.h, I see
>
> typedef enum {
> CRYPT_INVALID, /**< device mapping is invalid in this context */
> CRYPT_INACTIVE, /**< no such mapped device */
> CRYPT_ACTIVE, /**< device is active */
> CRYPT_BUSY /**< device is active and has open count > 0 */
> } crypt_status_info;
>
> and
>
> crypt_status_info crypt_status(struct crypt_device *cd, const char *name);
>
> It appears to me that the code flow is good since we probably can't deactivate a busy container
> but it appears to me that the error is misleading in the event of CRYPT_BUSY because the message
> indicates the device isn't active.
>
> Am I interpreting correctly?
Yes, that example should probably handle busy device differently.
Anyway, you will receive error message "Device ... is still in use." before the printf above.
Milan
_______________________________________________
dm-crypt mailing list
dm-crypt@saout.de
http://www.saout.de/mailman/listinfo/dm-crypt
[-- Attachment #2: Type: text/html, Size: 5359 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-09-26 19:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-26 1:03 [dm-crypt] Question about "An example of using LUKS device through libcryptsetup API" H McCurdy
2015-09-26 6:11 ` Milan Broz
2015-09-26 19:13 ` H McCurdy
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.