help with understanding cryptsetup through the library

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



trying to switch from using cryptsetup in the commandline to using the library and i am having a bit of a problem understanding the library interface.

what am doing wrong in the following code? i can not seem to get a handle and use it correctly.

#include<stdio.h>
#include<libcryptsetup.h>

int main( int argc, char *argv[] )
{
struct crypt_device *cd ;
char * device = argv[1] ;
int i ;
const char *c ;
printf("device in use: %s\n",device);
i = crypt_init( &cd ,device);
if ( i != 0 ){
perror("") ;
return 1 ;
}

c = crypt_get_type( cd ) ;
if ( c == NULL )
printf("device not known\n") ;
else
printf("%s\n",c );

crypt_free( cd ) ;
return 0 ;
}

running the above code gives this output:
device in use: /home/ink/cs/luks
device not known

It does not seem to know the device. But the device is a luks device and the following command proves it

cryptsetup isLuks /home/ink/cs/luks ; echo $?
0

_______________________________________________
dm-crypt mailing list
dm-crypt@xxxxxxxx
http://www.saout.de/mailman/listinfo/dm-crypt

[Index of Archives]     [Device Mapper Devel]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux