added a check to see wether a device is 'real' or not. Thanks to

Francois Dupoux for the patch.

svn path=/trunk/; revision=764
This commit is contained in:
Bart Hakvoort 2007-01-07 20:29:03 +00:00
parent dfe1f4ec4f
commit 4e9d368102
2 changed files with 21 additions and 3 deletions

View File

@ -1,3 +1,8 @@
2007-01-07 Bart Hakvoort <hakvoort@cvs.gnome.org>
* src/GParted_Core.cc: added a check to see wether a device is 'real'
or not. (thanks to François Dupoux for the patch)
2006-12-19 Theppitak Karoonboonyanan <thep@linux.thai.net>
* configure.in: Added 'th' (Thai) to ALL_LINGUAS.

View File

@ -155,8 +155,21 @@ void GParted_Core::set_devices( std::vector<Device> & devices )
lp_device = ped_device_get_next( NULL );
while ( lp_device )
{
//only add this device if we can read the first sector (which means it's a real device)
char * buf = static_cast<char *>( malloc( lp_device ->sector_size ) ) ;
if ( buf )
{
if ( ped_device_open( lp_device ) )
{
if ( ped_device_read( lp_device, buf, 0, 1 ) )
device_paths .push_back( lp_device ->path ) ;
ped_device_close( lp_device ) ;
}
free( buf ) ;
}
lp_device = ped_device_get_next( lp_device ) ;
}
close_device_and_disk() ;
@ -166,7 +179,7 @@ void GParted_Core::set_devices( std::vector<Device> & devices )
for ( unsigned int t = 0 ; t < device_paths .size() ; t++ )
{
if ( device_paths[ t ] .length() > 6 && device_paths[ t ] .is_ascii() && open_device_and_disk( device_paths[ t ], false ) )
if ( open_device_and_disk( device_paths[ t ], false ) )
{
temp_device .Reset() ;