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

.. ink .. mhogomchungu at gmail.com
Tue Nov 27 23:26:28 CET 2012


test using cryptsetup version 1.5.1

simple test:
1. open a mapper against a device.

2 call crypt_init_by_name() on the mapper and the call return "0" to mean
success,this is expected.

3.Unplug the device.

4.call the function again and it still return "0" to mean success,shouldnt
it fail since the underlying device is no longer available?

Simple test to show this:

open a mapper against a device:
root at mtz ink]# cryptsetup luksOpen /dev/sdc6 sdc6
Enter passphrase for /dev/sdc6:

run the "test" program on the mapper and results are below( source code
below )
[root at mtz ink]# ./test /dev/mapper/sdc6
pass1
pass2

unplugged the device and rerun the test again and the results are below.
[root at mtz ink]# ./test /dev/mapper/sdc6
pass1
fail2
[root at mtz ink]#


source code of the test program:


#include<libcryptsetup.h>

int main( int argc,char * argv[] )
{
    const char * path = argv[ 1 ] ;
    struct crypt_device * cd;

    if( crypt_init_by_name( &cd,path ) < 0 ){
        puts( "fail1" ) ;
        crypt_free( cd ) ;
        return 1 ;
    }else{
        puts( "pass1" ) ;
    }

    const char * e = crypt_get_device_name( cd ) ;

    if( e ){
        puts( "pass2" ) ;
    }else{
        puts( "fail2" ) ;
    }

    crypt_free( cd ) ;

    return 0 ;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.saout.de/pipermail/dm-crypt/attachments/20121127/af162661/attachment.html>


More information about the dm-crypt mailing list