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)  

real_path.c
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2012-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 <limits.h> /* PATH_MAX */
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <sys/stat.h>
25 #include "includes.h"
26 #include <stdlib.h>
27 
28 char * zuluCryptRealPath( const char * path )
29 {
30  string_t st ;
31  string_t xt ;
32 
33  char * e = realpath( path,NULL ) ;
34 
35  if( StringPrefixEqual( e,"/dev/dm-" ) ){
36 
37  st = String_1( "/sys/block/",e + 5,"/dm/name",NULL ) ;
38 
40 
41  StringRemoveRight( xt,1 ) ;
42 
43  StringPrepend( xt,"/dev/mapper/" ) ;
44 
45  StringFree( e ) ;
46 
47  StringDelete( &st ) ;
48 
49  return StringDeleteHandle( &xt ) ;
50  }else{
51  return e ;
52  }
53 }
54 
55 int zuluCryptPathStartsWith( const char * path,const char * start )
56 {
57  int st = 0 ;
58  char * p = zuluCryptRealPath( path ) ;
59  if( p != NULL ){
60  st = StringPrefixEqual( p,start ) ;
61  StringFree( p ) ;
62  }
63  return st ;
64 }
65 
66 int zuluCryptPathDoesNotStartsWith( const char * path,const char * start )
67 {
68  int st = 0;
69  char * p = zuluCryptRealPath( path ) ;
70  if( p != NULL ){
71  st = StringPrefixEqual( p,start ) ;
72  StringFree( p ) ;
73  }
74  return st == 0 ;
75 }
76 
77 int zuluCryptPathDidNotChange( const char * path )
78 {
79  char * p = zuluCryptRealPath( path ) ;
80  int st = 0 ;
81  if( p != NULL ){
82  st = StringsAreEqual( path,p ) ;
83  StringFree( p ) ;
84  }
85  return st ;
86 }
87 
88 int zuluCryptPathDeviceIsBlockDevice( const char * device )
89 {
90  if( device ){;}
91  return 0 ;
92 }
StringGetFromVirtualFile
string_t StringGetFromVirtualFile(const char *path)
Definition: String.c:2050
zuluCryptPathDeviceIsBlockDevice
int zuluCryptPathDeviceIsBlockDevice(const char *device)
Definition: real_path.c:88
zuluCryptPathDidNotChange
int zuluCryptPathDidNotChange(const char *path)
Definition: real_path.c:77
zuluCryptRealPath
char * zuluCryptRealPath(const char *path)
Definition: real_path.c:28
StringPrepend
const char * StringPrepend(string_t st, const char *s)
Definition: String.c:1015
zuluCryptPathStartsWith
int zuluCryptPathStartsWith(const char *path, const char *start)
Definition: real_path.c:55
StringsAreEqual
#define StringsAreEqual(x, y)
Definition: zuluSafe.c:46
StringDeleteHandle
char * StringDeleteHandle(string_t *xt)
Definition: String.c:233
StringContent
static const __inline__ char * StringContent(string_t st)
Definition: String.h:1011
zuluCryptPathDoesNotStartsWith
int zuluCryptPathDoesNotStartsWith(const char *path, const char *start)
Definition: real_path.c:66
StringType
Definition: String.c:49
String_1
string_t String_1(const char *cstring,...)
Definition: String.c:363
e
static QString e
Definition: about.cpp:31
includes.h
StringDelete
void StringDelete(string_t *st)
Definition: String.c:162
StringRemoveRight
const char * StringRemoveRight(string_t st, size_t x)
Definition: String.c:634
StringPrefixEqual
static __inline__ int StringPrefixEqual(const char *x, const char *y)
Definition: String.h:905
StringFree
static __inline__ void StringFree(const void *str)
Definition: String.h:823