From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nm3-vm6.bullet.mail.ne1.yahoo.com (nm3-vm6.bullet.mail.ne1.yahoo.com [98.138.91.96]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mail.server123.net (Postfix) with ESMTPS for ; Sat, 26 Sep 2015 03:04:55 +0200 (CEST) Date: Sat, 26 Sep 2015 01:03:44 +0000 (UTC) From: H McCurdy Reply-To: H McCurdy Message-ID: <1087656308.1214643.1443229424819.JavaMail.yahoo@mail.yahoo.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_1214642_329404628.1443229424817" Subject: [dm-crypt] Question about "An example of using LUKS device through libcryptsetup API" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "dm-crypt@saout.de" ------=_Part_1214642_329404628.1443229424817 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi, The program code is published athttps://gitlab.com/cryptsetup/cryptsetup/wi= kis/API/index.html Looking in=20 static int handle_active_device(const char *device_name) at =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (crypt_status(cd, device= _name) =3D=3D 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 =3D 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 deactiv= ate a busy container but it appears to me that the error is misleading in the event of CRYPT_BUS= Y because the message indicates the device isn't active. Am I interpreting correctly? Hugh ------=_Part_1214642_329404628.1443229424817 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi,

The pr= ogram code is published at

Looking in 

static
int handle_active_device(const char *device_name)

at
    &nbs= p;   if (crypt_status(cd, device_name) =3D=3D CRYPT_ACTIVE)<= br> printf("Device %s is still active.\n", device_name);
else {
printf("Someth= ing failed perhaps, device %s is not active.\n", device_name);
crypt_free(cd); return -= 1;
}

/*
* crypt_deactivate() is used to deactivate device
*/
r =3D 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 mappin= g is invalid in this context */
CRYPT_INACTIVE, /**< no such mapped device */
CRYPT_ACTIVE, /**< device is ac= tive */
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 sinc= e we probably can't deactivate a busy container
but it appears to me tha= t the error is misleading in the event of CRYPT_BUSY because the messageindicates the device isn't active.

Am I interpreting correctly?
=
Hugh


------=_Part_1214642_329404628.1443229424817--