Added lvm2 physical volume detection

svn path=/trunk/; revision=1000
This commit is contained in:
Curtis Gedak 2008-12-07 18:43:35 +00:00
parent 84d4beb27c
commit 4ef71e5004
7 changed files with 114 additions and 40 deletions

View file

@ -1,3 +1,12 @@
2008-12-07 Curtis Gedak <gedakc@gmail.com>
* include/Utils.h,
src/Dialog_Partition_New.cc,
src.DialogFeatures.cc,
src/GParted_Core.cc,
src/Utils.cc,
src/Win_GParted.cc: Added lvm2 physical volume detection.
2008-12-03 Curtis Gedak <gedakc@gmail.com>
* src/Dialog_Partition_Info.cc,

View file

@ -65,7 +65,9 @@ enum FILESYSTEM
FS_UFS = 16,
FS_USED = 17,
FS_UNUSED = 18
FS_UNUSED = 18,
FS_LVM2 = 19
} ;
enum SIZE_UNIT

View file

@ -100,9 +100,16 @@ DialogFeatures::DialogFeatures()
void DialogFeatures::load_filesystems( const std::vector<FS> & FILESYSTEMS )
{
liststore_filesystems ->clear() ;
for ( unsigned short t = 0; t < FILESYSTEMS .size() -1 ; t++ )
//fill the features chart with valid file systems
for ( unsigned short t = 0; t < FILESYSTEMS .size() ; t++ )
{
//Skip lvm2 and unknown because these are not file systems
if( FILESYSTEMS[ t ] .filesystem == GParted::FS_LVM2 ||
FILESYSTEMS[ t ] .filesystem == GParted::FS_UNKNOWN )
continue ;
show_filesystem( FILESYSTEMS[ t ] ) ;
}
}
void DialogFeatures::show_filesystem( const FS & fs )

View file

@ -41,13 +41,29 @@ void Dialog_Partition_New::Set_Data( const Partition & partition,
this ->new_count = new_count;
this ->selected_partition = partition;
this ->cylinder_size = cylinder_size ;
//copy GParted FILESYSTEMS
this ->FILESYSTEMS = FILESYSTEMS ;
this ->FILESYSTEMS .back() .filesystem = GParted::FS_UNFORMATTED ;
this ->FILESYSTEMS .back() .create = GParted::FS::LIBPARTED ;
FS fs_tmp ;
fs_tmp .filesystem = GParted::FS_EXTENDED ;
this ->FILESYSTEMS .push_back( fs_tmp ) ;
//remove all non-valid file systems
for ( unsigned int t = this ->FILESYSTEMS .size( ) ; t > 0 ; t-- )
{
if ( this ->FILESYSTEMS[ t ] .filesystem == GParted::FS_UNKNOWN ||
this ->FILESYSTEMS[ t ] .filesystem == GParted::FS_LVM2 )
this ->FILESYSTEMS .erase( this->FILESYSTEMS .begin() + t ) ;
}
FS *fs_tmp ;
//add FS_UNFORMATTED
fs_tmp = new( FS ) ;
fs_tmp ->filesystem = GParted::FS_UNFORMATTED ;
fs_tmp ->create = GParted::FS::LIBPARTED ;
this ->FILESYSTEMS .push_back( * fs_tmp ) ;
//add FS_EXTENDED
fs_tmp = new( FS ) ;
fs_tmp ->filesystem = GParted::FS_EXTENDED ;
this ->FILESYSTEMS .push_back( * fs_tmp ) ;
//add table with selection menu's...
table_create .set_border_width( 10 ) ;
@ -269,13 +285,16 @@ void Dialog_Partition_New::optionmenu_changed( bool type )
void Dialog_Partition_New::Build_Filesystems_Menu( bool only_unformatted )
{
//fill the file system menu with the file systems (except for extended)
for ( unsigned int t = 0 ; t < FILESYSTEMS .size( ) -1 ; t++ )
for ( unsigned int t = 0 ; t < FILESYSTEMS .size( ) ; t++ )
{
//skip extended (lvm2 and unknown removed in Set_Data())
if( FILESYSTEMS[ t ] .filesystem == GParted::FS_EXTENDED )
continue ;
menu_filesystem .items() .push_back(
Gtk::Menu_Helpers::MenuElem( Utils::get_filesystem_string( FILESYSTEMS[ t ] .filesystem ) ) ) ;
menu_filesystem .items()[ t ] .set_sensitive(
menu_filesystem .items() .back() .set_sensitive(
! only_unformatted && FILESYSTEMS[ t ] .create &&
this ->selected_partition .get_length() >= FILESYSTEMS[ t ] .MIN ) ;
this ->selected_partition .get_length() >= FILESYSTEMS[ t ] .MIN ) ;
}
//unformatted is always available

View file

@ -105,7 +105,7 @@ void GParted_Core::find_supported_filesystems()
linux_swap fs_linux_swap;
FILESYSTEMS .push_back( fs_linux_swap .get_filesystem_support() ) ;
ntfs fs_ntfs;
FILESYSTEMS .push_back( fs_ntfs .get_filesystem_support() ) ;
@ -120,12 +120,19 @@ void GParted_Core::find_supported_filesystems()
xfs fs_xfs;
FILESYSTEMS .push_back( fs_xfs .get_filesystem_support() ) ;
FS *fs ;
//lvm2 physical volume -- not a file system
fs = new( FS ) ;
fs ->filesystem = GParted::FS_LVM2 ;
FILESYSTEMS .push_back( * fs ) ;
//unknown file system (default when no match is found)
FS fs ; fs .filesystem = GParted::FS_UNKNOWN ;
FILESYSTEMS .push_back( fs ) ;
fs = new( FS ) ;
fs ->filesystem = GParted::FS_UNKNOWN ;
FILESYSTEMS .push_back( * fs ) ;
}
void GParted_Core::set_user_devices( const std::vector<Glib::ustring> & user_devices )
{
this ->device_paths = user_devices ;
@ -757,6 +764,7 @@ GParted::FILESYSTEM GParted_Core::get_filesystem()
//other file systems libparted couldn't detect (i've send patches for these file systems to the parted guys)
// - no patches sent to parted for lvm2
char buf[512] ;
ped_device_open( lp_device );
@ -767,7 +775,27 @@ GParted::FILESYSTEM GParted_Core::get_filesystem()
if ( Glib::ustring( buf ) == "ReIsEr4" )
return GParted::FS_REISER4 ;
//lvm2
//NOTE: lvm2 is not a file system but we do wish to recognize the Physical Volume
char magic1[16] ;
char magic2[16] ;
ped_device_open( lp_device );
ped_geometry_read( & lp_partition ->geom, buf, 1, 1 ) ;
strncpy(magic1, buf+0, 8) ; magic1[8] = '\0' ; //set and terminate string
strncpy(magic2, buf+24, 4) ; magic2[4] = '\0' ; //set and terminate string
ped_device_close( lp_device );
if ( Glib::ustring( magic1 ) == "LABELONE"
&& Glib::ustring( magic2 ) == "LVM2" )
{
temp = _( "Logical Volume Management is not yet supported." ) ;
temp += "\n" ;
partition_temp .messages .push_back( temp ) ;
return GParted::FS_LVM2 ;
}
//no file system found....
temp = _( "Unable to detect file system! Possible reasons are:" ) ;
temp += "\n-";
@ -856,7 +884,8 @@ void GParted_Core::set_mountpoints( std::vector<Partition> & partitions )
{
if ( ( partitions[ t ] .type == GParted::TYPE_PRIMARY ||
partitions[ t ] .type == GParted::TYPE_LOGICAL ) &&
partitions[ t ] .filesystem != GParted::FS_LINUX_SWAP )
partitions[ t ] .filesystem != GParted::FS_LINUX_SWAP &&
partitions[ t ] .filesystem != GParted::FS_LVM2 )
{
if ( partitions[ t ] .busy )
{
@ -896,6 +925,7 @@ void GParted_Core::set_used_sectors( std::vector<Partition> & partitions )
for ( unsigned int t = 0 ; t < partitions .size() ; t++ )
{
if ( partitions[ t ] .filesystem != GParted::FS_LINUX_SWAP &&
partitions[ t ] .filesystem != GParted::FS_LVM2 &&
partitions[ t ] .filesystem != GParted::FS_UNKNOWN )
{
if ( partitions[ t ] .type == GParted::TYPE_PRIMARY ||

View file

@ -67,27 +67,28 @@ Glib::ustring Utils::get_color( FILESYSTEM filesystem )
{
switch( filesystem )
{
case FS_UNALLOCATED : return "#A9A9A9" ;
case FS_UNKNOWN : return "#000000" ;
case FS_UNFORMATTED : return "#000000" ;
case FS_EXTENDED : return "#7DFCFE" ;
case FS_EXT2 : return "#9DB8D2" ;
case FS_EXT3 : return "#7590AE" ;
case FS_LINUX_SWAP : return "#C1665A" ;
case FS_FAT16 : return "#00FF00" ;
case FS_FAT32 : return "#18D918" ;
case FS_NTFS : return "#42E5AC" ;
case FS_REISERFS : return "#ADA7C8" ;
case FS_REISER4 : return "#887FA3" ;
case FS_XFS : return "#EED680" ;
case FS_JFS : return "#E0C39E" ;
case FS_HFS : return "#E0B6AF" ;
case FS_HFSPLUS : return "#C0A39E" ;
case FS_UFS : return "#D1940C" ;
case FS_USED : return "#F8F8BA" ;
case FS_UNUSED : return "#FFFFFF" ;
case FS_UNALLOCATED : return "#A9A9A9" ; // ~ medium grey
case FS_UNKNOWN : return "#000000" ; //black
case FS_UNFORMATTED : return "#000000" ; //black
case FS_EXTENDED : return "#7DFCFE" ; // ~ light blue
case FS_EXT2 : return "#9DB8D2" ; //blue hilight
case FS_EXT3 : return "#7590AE" ; //blue medium
case FS_LINUX_SWAP : return "#C1665A" ; //red medium
case FS_FAT16 : return "#00FF00" ; //green
case FS_FAT32 : return "#18D918" ; // ~ medium green
case FS_NTFS : return "#42E5AC" ; // ~ light turquoise
case FS_REISERFS : return "#ADA7C8" ; //purple hilight
case FS_REISER4 : return "#887FA3" ; //purple medium
case FS_XFS : return "#EED680" ; //accent yellow
case FS_JFS : return "#E0C39E" ; //face skin medium
case FS_HFS : return "#E0B6AF" ; //red hilight
case FS_HFSPLUS : return "#C0A39E" ; // ~ serene red
case FS_UFS : return "#D1940C" ; //accent yellow dark
case FS_USED : return "#F8F8BA" ; // ~ light tan yellow
case FS_UNUSED : return "#FFFFFF" ; //white
case FS_LVM2 : return "#CC9966" ; // ~ medium brown
default : return "#000000" ;
default : return "#000000" ;
}
}
@ -130,6 +131,7 @@ Glib::ustring Utils::get_filesystem_string( FILESYSTEM filesystem )
case FS_UFS : return "ufs" ;
case FS_USED : return _("used") ;
case FS_UNUSED : return _("unused") ;
case FS_LVM2 : return "lvm2" ;
default : return "" ;
}

View file

@ -380,8 +380,13 @@ Gtk::Menu * Win_GParted::create_format_menu()
{
menu = manage( new Gtk::Menu() ) ;
for ( unsigned int t =0; t < gparted_core .get_filesystems() .size() -1 ; t++ )
for ( unsigned int t =0; t < gparted_core .get_filesystems() .size() ; t++ )
{
//Skip lvm2 and unknown because these are not file systems
if( gparted_core .get_filesystems()[ t ] .filesystem == GParted::FS_LVM2 ||
gparted_core .get_filesystems()[ t ] .filesystem == GParted::FS_UNKNOWN )
continue ;
hbox = manage( new Gtk::HBox() );
//the colored square