zuluCrypt  5.7.1
About: zuluCrypt is a simple but feature rich solution for hard drives encryption. It can manage PLAIN dm-crypt, LUKS, TrueCrypt and VeraCrypt encrypted volumes.
  Fossies Dox: zuluCrypt-5.7.1.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

is_luks.c
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2011-2015
4  * name : Francis Banyikwa
5  * email: mhogomchungu@gmail.com
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #include "includes.h"
21 
22 #include <libcryptsetup.h>
23 #include <fcntl.h>
24 #include <unistd.h>
25 
26 static int _is_luks( const char * dev,const resolve_path_t * opts )
27 {
28  struct crypt_device * cd ;
29  int st ;
30 
31  if( opts ){;}
32 
33  if( crypt_init( &cd,dev ) != 0 ){
34 
35  return 0 ;
36  }
37 
38  st = crypt_load( cd,NULL,NULL ) ;
39 
40  crypt_free( cd ) ;
41 
42  return st == 0 ;
43 }
44 
45 int zuluCryptVolumeIsLuks( const char * device )
46 {
47  /*
48  * resolve_path_t is defined in includes.h
49  */
50  resolve_path_t opts ;
51 
52  memset( &opts,'\0',sizeof( opts ) ) ;
53 
54  opts.device = device ;
55  opts.error_value = 0 ;
56 
57  /*
58  * zuluCryptResolveDevicePath() is defined in resolve_path.c
59  */
60  return zuluCryptResolveDevicePath( _is_luks,&opts ) ;
61 }
62 
63 int zuluCryptVolumeIsNotLuks( const char * dev )
64 {
65  return !zuluCryptVolumeIsLuks( dev ) ;
66 }
zuluCryptResolveDevicePath
int zuluCryptResolveDevicePath(int(*)(const char *, const resolve_path_t *), const resolve_path_t *)
Definition: resolve_paths.c:389
_is_luks
static int _is_luks(const char *dev, const resolve_path_t *opts)
Definition: is_luks.c:26
zuluCryptVolumeIsNotLuks
int zuluCryptVolumeIsNotLuks(const char *dev)
Definition: is_luks.c:63
resolve_path_t::error_value
int error_value
Definition: includes.h:116
zuluCryptVolumeIsLuks
int zuluCryptVolumeIsLuks(const char *device)
Definition: is_luks.c:45
resolve_path_t::device
const char * device
Definition: includes.h:115
includes.h
resolve_path_t
Definition: includes.h:114