Task::future< QVector< volumeEntryProperties > >& zuluMountTask::updateVolumeList() { return Task::run< QVector< volumeEntryProperties > >( [](){ QStringList l = zuluMountTask::hiddenVolumeList() ; auto _validEntry = [ & ]( const QString& e ){ if( e.startsWith( "/dev/md/md-device-map" ) ){ return false ; } if( e.contains( "\tswap\t" ) || e.contains( "member\t" ) || e.contains( "\t/run/media/public" ) ){ return false ; } if( !l.isEmpty() ){ for( const auto& it : l ){ if( e.startsWith( it + '\t' ) ){ return false ; } } } return true ; } ; QVector< volumeEntryProperties > list ; auto all = utility::Task( utility::appendUserUID( "%1 -l" ).arg( zuluMountPath ),10000 ) ; if( all.finished() ){ auto system = utility::Task( utility::appendUserUID( "%1 -S" ).arg( zuluMountPath ),10000 ) ; if( system.finished() ){ auto a = all.splitOutput( '\n' ) ; auto s = system.splitOutput( '\n' ) ; for( const auto& it : a ){ if( _validEntry( it ) ){ const auto& e = utility::split( it,'\t' ) ; list.append( volumeEntryProperties( e,s.contains( e.first() ) ) ) ; } } } } return list ; } ) ; }
volumeEntryProperties _getVolumeProperties( const QString& e ) { QString device = _device( e ) ; auto r = utility::Task( utility::appendUserUID( "%1 -L -d \"%2\"" ).arg( zuluMountPath,device ) ) ; if( r.success() ) { return volumeEntryProperties( r.splitOutput( '\t' ),_volumeIsSystemVolume( device ) ) ; }else{ return volumeEntryProperties() ; } }
void Task::updateVolumeListTask() { auto r = utility::Task( QString( ZULUCRYPTzuluCrypt ) + QString( " -L" ) ) ; if( r.success() ){ QStringList l = r.splitOutput( '\n' ) ; QStringList entry ; for( const auto& it : l ){ entry = utility::split( it,'\t' ) ; if( entry.size() >= 3 ){ emit addItemToTable( entry.at( 0 ),entry.at( 1 ),entry.at( 2 ) ) ; } } } }
volumeMiniPropertiesTaskResult zuluMountTask::volumeMiniProperties( const QString& volume ) { auto _loopDeviceIsGone =[]( const QString& device ){ QDir d( "/sys/block" ) ; QStringList l = d.entryList() ; QString e ; QString dev = QString( "%1\n" ).arg( device ) ; QByteArray s ; QFile f ; for( const auto& it : l ){ if( it.startsWith( "loop" ) ){ e = QString( "/sys/block/%1/loop/backing_file" ).arg( it ) ; f.setFileName( e ) ; if( f.open( QIODevice::ReadOnly ) ){ s = f.readAll() ; f.close() ; } if( s == dev ){ return false ; } } } return true ; } ; volumeMiniPropertiesTaskResult s{ volume,false,nullptr } ; if( !volume.startsWith( "UUID" ) && !volume.startsWith( "/dev/" ) ){ /* * There is some sort of a race condition here and things do not always work as expected * try to sleep for a second to see if it will help */ utility::Task::waitForOneSecond() ; if( _loopDeviceIsGone( volume ) ){ /* * we were just asked to find properties of a loop device * that no longer exists,remove it from the list in the GUI window */ s.volumeRemoved = true ; return s ; } } auto r = utility::Task( utility::appendUserUID( "%1 -L -d \"%2\"" ).arg( zuluMountPath,volume ) ) ; if( r.success() ){ s.entry = new volumeEntryProperties( r.splitOutput( '\t' ),_volumeIsSystemVolume( volume ) ) ; } return s ; }