[dm-crypt] shoulnt "crypt_init_by_name()" fail when the underlying device is no longer available?

.. ink .. mhogomchungu at gmail.com
Wed Nov 28 19:29:40 CET 2012

No it should not. It is explained in API doc:

> http://wiki.cryptsetup.googlecode.com/git/API/libcryptsetup_8h.html#a99bc4160e7afacfba1d2c5ee6dbaf3be
> "In case device points to active LUKS device but header load fails,
> context device type
> is set to NULL and 0 is returned as if it were successful.
> Context with NULL device type can only be deactivated by crypt_deactivate"
> So the only think you can do here is deactivate device-mapper device
> (which explains why it is needed).
So,this function can be used to check if the underlying device is present
or not.Good to know,it will be nice if the docs could say this.

The does clearly states the behavior,and i missed it somehow,my bad.

But why does this function behave this way though? Docs states this
behavior but it doesnt say why and this gives inconsistent behavior.I
always though checking for return value is sufficient to give indication if
i should proceed or bail out,it almost became automatic.It looks like with
this function,i should not check the return value but "cd".

Let say i want to be lazy and only do one check,should checking if "cd" is
NULL be sufficient to cover all invalid cases or its necessary to do bo
checks to be 100% sure.

>  Milan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.saout.de/pipermail/dm-crypt/attachments/20121128/b4cd1745/attachment.html>

More information about the dm-crypt mailing list