Enhanced to recognize /dev/mapper/* devices.

The move away from libparted device recognition broke recognition of /dev/mapper/* devices.  Problem now fixed.
Thanks to Colin Watson for the patch.

svn path=/trunk/; revision=933
This commit is contained in:
Curtis Gedak 2008-10-15 15:51:24 +00:00
parent bf9dc06d97
commit 57bda0a93c
3 changed files with 67 additions and 1 deletions

View File

@ -22,6 +22,9 @@ Curtis Gedak <gedakc@users.sourceforge.net>
* Created OperationLabelPartition.h, OperationLabelPartition.cc
* Maintained from official 0.3.5 release onward
Colin Watson <cjwatson@debian.org>
* Wrote patch to recognize /dev/mapper/* devices
Michael Monreal <michael.monreal@gmx.net>
* Wrote small patch to implement themed app icon in hicolor

View File

@ -1,3 +1,11 @@
2008-10-15 Curtis Gedak <gedakc@gmail.com>
* src/GParted_Core.cc: Enhanced to recognize /dev/mapper/* devices
- The move away from libparted device recognition broke
recognition of /dev/mapper/* devices. Problem now fixed.
- Thanks to Colin Watson for the patch.
- Closes GParted bug #556114
2008-10-14 Curtis Gedak <gedakc@gmail.com>
* src/Dialog_Progress.cc: Enhanced detail log to pass as XHTML

View File

@ -38,8 +38,14 @@
#include "../include/reiser4.h"
#include "../include/ufs.h"
#include <set>
#include <cerrno>
#include <cstring>
#include <sys/statvfs.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <dirent.h>
std::vector<Glib::ustring> libparted_messages ; //see ped_exception_handler()
@ -136,7 +142,11 @@ void GParted_Core::set_devices( std::vector<Device> & devices )
{
device_paths .clear() ;
//Fixme: Remove code to read /proc/partitions when libparted bug 194 is fixed.
//Fixme: Remove code to read:
// /proc/partitions,
// /proc/devices, and
// /dev/mapper
// when libparted bug 194 is fixed.
// This was a problem with no floppy drive yet BIOS indicated one existed.
// http://parted.alioth.debian.org/cgi-bin/trac.cgi/ticket/194
//
@ -164,6 +174,51 @@ void GParted_Core::set_devices( std::vector<Device> & devices )
}
}
proc_partitions .close() ;
std::set<unsigned int> dm_majors;
std::ifstream proc_devices( "/proc/devices" ) ;
if ( proc_devices )
{
//parse device numbers from /proc/devices
std::string line ;
bool seen_bd = false ;
while ( getline( proc_devices, line ) )
{
if ( ! seen_bd )
{
if ( ! line .compare( 0, 14, "Block devices:" ) == 0 )
seen_bd = true ;
continue ;
}
unsigned int major ;
char c_str[256+1] ;
if ( sscanf( line .c_str(), "%u %256s", &major, c_str ) == 2 )
dm_majors .insert( major );
}
proc_devices .close() ;
}
DIR *mapper_dir = opendir( "/dev/mapper" );
if ( mapper_dir )
{
struct dirent *mapper_entry ;
while ( (mapper_entry = readdir( mapper_dir )) )
{
if ( strcmp( mapper_entry ->d_name, "." ) == 0 ||
strcmp( mapper_entry ->d_name, ".." ) == 0 ||
strcmp( mapper_entry ->d_name, "control" ) == 0 )
continue ;
std::string mapper_name = "/dev/mapper/" ;
mapper_name += mapper_entry ->d_name ;
struct stat st ;
if ( stat( mapper_name .c_str(), &st ) != 0 )
continue;
if ( dm_majors .find( major( st.st_rdev ) ) != dm_majors .end() )
//TODO avoid probing partition nodes for dmraid devices
ped_device_get( mapper_name .c_str() ) ;
}
closedir( mapper_dir ) ;
}
}
else
{