From de99c530d45877f7bce1b0c0f616c03e8c1ebb89 Mon Sep 17 00:00:00 2001 From: Curtis Gedak Date: Wed, 14 Nov 2012 13:05:50 -0700 Subject: [PATCH] Remove SWRaid method as it is no longer needed (#678379) Active Linux software RAID devices are detected in the Proc_Partitions_Info method. Hence the SWRaid method is no longer required. Removal of the SWRaid method fixes the problem with the error message: Could not stat device /dev/md/0 - No such file or directory This fixes the problem because we no longer use "mdadm --examine --scan" in an attempt to detect Linux software RAID devices. The mdadm command was returning device names such as /dev/md/0, which are incorrect for GParted. NOTE: With this change, GParted no longer requires the mdadm command to detect Linux software RAID devices. Closes Bug #678379 - Could not stat device /dev/md/0 - No such file or directory --- README | 4 -- include/Makefile.am | 1 - include/SWRaid.h | 55 ----------------------- src/GParted_Core.cc | 12 ----- src/Makefile.am | 1 - src/SWRaid.cc | 104 -------------------------------------------- 6 files changed, 177 deletions(-) delete mode 100644 include/SWRaid.h delete mode 100644 src/SWRaid.cc diff --git a/README b/README index aedb3fe9..9ef58fba 100644 --- a/README +++ b/README @@ -149,10 +149,6 @@ Optional packages include: package before that. -For Linux software RAID support, the following package is required: - mdadm - tool to administer Linux MD arrays - - For dmraid support, the following packages are required: dmsetup - removes /dev/mapper entries diff --git a/include/Makefile.am b/include/Makefile.am index 31eab076..136da213 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -34,7 +34,6 @@ EXTRA_DIST = \ OperationLabelPartition.h \ Partition.h \ Proc_Partitions_Info.h \ - SWRaid.h \ TreeView_Detail.h \ Utils.h \ Win_GParted.h \ diff --git a/include/SWRaid.h b/include/SWRaid.h deleted file mode 100644 index 4d74d07d..00000000 --- a/include/SWRaid.h +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright (C) 2009 Curtis Gedak - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Library General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -/* READ THIS! - * This class was created in an effort to reduce the complexity of the - * GParted_Core class. - * This class provides support for Linux software RAID devices (mdadm). - * Static elements are used in order to reduce the disk accesses required to - * load the data structures upon each initialization of the class. - */ - -#ifndef SWRAID_H_ -#define SWRAID_H_ - -#include "../include/Utils.h" - -#include - -namespace GParted -{ - - -class SWRaid -{ -public: - SWRaid() ; - SWRaid( const bool & do_refresh ) ; - ~SWRaid() ; - bool is_swraid_supported() ; - void get_devices( std::vector & swraid_devices ) ; -private: - void load_swraid_cache() ; - void set_commands_found() ; - static bool swraid_cache_initialized ; - static bool mdadm_found ; - static std::vector swraid_devices ; -}; - -}//GParted - -#endif /* SWRAID_H_ */ diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index c56f27af..7a4dd862 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -19,7 +19,6 @@ #include "../include/Win_GParted.h" #include "../include/GParted_Core.h" #include "../include/DMRaid.h" -#include "../include/SWRaid.h" #include "../include/FS_Info.h" #include "../include/LVM2_PV_Info.h" #include "../include/OperationCopy.h" @@ -144,7 +143,6 @@ void GParted_Core::set_devices( std::vector & devices ) Proc_Partitions_Info pp_info( true ) ; //Refresh cache of proc partition information FS_Info fs_info( true ) ; //Refresh cache of file system information DMRaid dmraid( true ) ; //Refresh cache of dmraid device information - SWRaid swraid( true ) ; //Refresh cache of swraid device information LVM2_PV_Info lvm2_pv_info( true ) ; //Refresh cache of LVM2 PV information init_maps() ; @@ -171,16 +169,6 @@ void GParted_Core::set_devices( std::vector & devices ) ped_device_get( temp_devices[ k ] .c_str() ) ; } - //Try to find all swraid devices - if (swraid .is_swraid_supported() ) { - std::vector swraid_devices ; - swraid .get_devices( swraid_devices ) ; - for ( unsigned int k=0; k < swraid_devices .size(); k++ ) { - set_thread_status_message( String::ucompose ( _("Scanning %1"), swraid_devices[k] ) ) ; - ped_device_get( swraid_devices[k] .c_str() ) ; - } - } - //Try to find all dmraid devices if (dmraid .is_dmraid_supported() ) { std::vector dmraid_devices ; diff --git a/src/Makefile.am b/src/Makefile.am index 7c65fb29..d5ec826b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -44,7 +44,6 @@ gpartedbin_SOURCES = \ OperationLabelPartition.cc \ Partition.cc \ Proc_Partitions_Info.cc \ - SWRaid.cc \ TreeView_Detail.cc \ Utils.cc \ Win_GParted.cc \ diff --git a/src/SWRaid.cc b/src/SWRaid.cc deleted file mode 100644 index 98fde1d2..00000000 --- a/src/SWRaid.cc +++ /dev/null @@ -1,104 +0,0 @@ -/* Copyright (C) 2009 Curtis Gedak - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Library General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "../include/SWRaid.h" - -namespace GParted -{ - -//Initialize static data elements -bool SWRaid::swraid_cache_initialized = false ; -bool SWRaid::mdadm_found = false ; -std::vector SWRaid::swraid_devices ; - -SWRaid::SWRaid() -{ - //Ensure that cache has been loaded at least once - if ( ! swraid_cache_initialized ) - { - swraid_cache_initialized = true ; - set_commands_found() ; - load_swraid_cache() ; - } -} - -SWRaid::SWRaid( const bool & do_refresh ) -{ - //Ensure that cache has been loaded at least once - if ( ! swraid_cache_initialized ) - { - swraid_cache_initialized = true ; - set_commands_found() ; - if ( do_refresh == false ) - load_swraid_cache() ; - } - - if ( do_refresh ) - load_swraid_cache() ; -} - -SWRaid::~SWRaid() -{ -} - -void SWRaid::load_swraid_cache() -{ - //Load data into swraid structures - Glib::ustring output, error ; - swraid_devices .clear() ; - - if ( mdadm_found ) - { - if ( ! Utils::execute_command( "mdadm --examine --scan", output, error, true ) ) - { - if ( output .size() > 0 ) - { - std::vector temp_arr ; - Utils::tokenize( output, temp_arr, "\n" ) ; - for ( unsigned int k = 0; k < temp_arr .size(); k++ ) - { - Glib::ustring temp = Utils::regexp_label( temp_arr[k], "^[^/]*(/dev/[^\t ]*)" ) ; - if ( temp .size() > 0 ) - swraid_devices .push_back( temp ) ; - } - } - } - } -} - -void SWRaid::set_commands_found() -{ - //Set status of commands found - mdadm_found = (! Glib::find_program_in_path( "mdadm" ) .empty() ) ; -} - -bool SWRaid::is_swraid_supported() -{ - //Determine if Linux software RAID is supported - return ( mdadm_found ) ; -} - -void SWRaid::get_devices( std::vector & device_list ) -{ - //Retrieve list of Linux software RAID devices - device_list .clear() ; - - for ( unsigned int k=0; k < swraid_devices .size(); k++ ) - device_list .push_back( swraid_devices[k] ) ; -} - -}//GParted