static int _restore_luks_header( const struct_opts * opts,const char * temp_path ) { int st ; struct crypt_device * cd ; if( crypt_init( &cd,opts->device ) != 0 ){ st = 7 ; }else{ if( crypt_load( cd,NULL,NULL ) != 0 ){ st = 2 ; }else{ if( crypt_header_restore( cd,NULL,temp_path ) == 0 ){ st = 1 ; }else{ st = 7 ; } } crypt_free( cd ) ; } return st ; }
static int restore_luks_header(struct reenc_ctx *rc) { struct crypt_device *cd = NULL; int r; log_dbg("Restoring header for %s from %s.", rc->device, rc->header_file_new); r = crypt_init(&cd, rc->device); if (r == 0) { crypt_set_confirm_callback(cd, NULL, NULL); r = crypt_header_restore(cd, CRYPT_LUKS1, rc->header_file_new); } crypt_free(cd); if (r) log_err(_("Cannot restore LUKS header on device %s.\n"), rc->device); else log_verbose(_("LUKS header on device %s restored.\n"), rc->device); return r; }