Example #1
0
char * zuluCryptGetLoopDeviceAddress( const char * device )
{
	char * z = NULL ;
	const char * e ;

	string_t st = StringVoid ;
	string_t xt = StringVoid ;

	int i ;
	int r ;

	z = zuluCryptLoopDeviceAddress_1( device ) ;

	if( z == NULL ){
		return NULL ;
	}else{
		st = String( "" ) ;

		for( i = 0 ; i < 255 ; i++ ){

			StringReplace( st,"/sys/block/loop" ) ;
			StringAppendInt( st,i ) ;

			xt = StringGetFromVirtualFile( StringAppend( st,"/loop/backing_file" ) ) ;

			e = StringRemoveRight( xt,1 ) ;
			r = StringsAreEqual( e,z ) ;

			StringDelete( &xt ) ;

			if( r ){

				StringReplace( st,"/dev/loop" ) ;
				e = StringAppendInt( st,i ) ;

				if( StringsAreNotEqual( device,e ) ){

					break ;
				}
			}else{
				StringReset( st ) ;
			}
		}

		StringFree( z ) ;

		if( StringIsEmpty( st ) ){

			StringDelete( &st ) ;
			return NULL ;
		}else{
			return StringDeleteHandle( &st ) ;
		}
	}
}
Example #2
0
static stringList_t _add_entry( stringList_t stx,stringList_t tmp,string_t ( *function )( const vInfo * ),
                                char * const ** entry,size_t * entry_len )
{
    string_t st ;

    u_int64_t e ;

    vInfo volumeInfo ;

    StringListStringArray_1( entry,entry_len,tmp ) ;

    volumeInfo.device       = *( *entry + *entry_len - 2 ) ;
    volumeInfo.mountPoint   = *( *entry + 4 ) ;
    volumeInfo.fileSystem   = *( *entry + *entry_len - 3 ) ;
    volumeInfo.mountOptions = *( *entry + 5 ) ;
    volumeInfo.rootPath     = *( *entry + 3 ) ;

    if( StringsAreEqual( volumeInfo.fileSystem,"fuse.encfs" ) ) {

        st = StringListStringAt( tmp,*entry_len - 2 ) ;

        StringReset( st ) ;

        e = StringJenkinsOneAtATimeHash( volumeInfo.mountPoint ) ;

        volumeInfo.device = StringAppendInt( st,e ) ;
    }

    if( _valid_entry( &volumeInfo ) ) {

        st = function( &volumeInfo ) ;
        stx = StringListAppendString_1( stx,&st ) ;
    }

    return stx ;
}