[gparted] Remove now unused Proc_Partitions_Info::get_alternate_paths() (#767842)



commit 0f4df8dfd171ccdf076f562c4371fa237525a674
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Sat Jun 18 14:17:57 2016 +0100

    Remove now unused Proc_Partitions_Info::get_alternate_paths() (#767842)
    
    Now Device and Partition objects only have a single path,
    get_alternate_paths() is never called.  Remove the method and population
    of the private alternate_paths_cache member that went with it.
    
    Bug 767842 - File system usage missing when tools report alternate block
                 device names

 include/Proc_Partitions_Info.h |    6 ++--
 src/Proc_Partitions_Info.cc    |   43 +++++----------------------------------
 2 files changed, 9 insertions(+), 40 deletions(-)
---
diff --git a/include/Proc_Partitions_Info.h b/include/Proc_Partitions_Info.h
index c877e0f..8084492 100644
--- a/include/Proc_Partitions_Info.h
+++ b/include/Proc_Partitions_Info.h
@@ -24,7 +24,8 @@
 #ifndef GPARTED_PROC_PARTITIONS_INFO_H
 #define GPARTED_PROC_PARTITIONS_INFO_H
 
-#include "../include/Utils.h"
+#include <glibmm/ustring.h>
+#include <vector>
 
 namespace GParted
 {
@@ -36,12 +37,11 @@ public:
        Proc_Partitions_Info( bool do_refresh ) ;
        ~Proc_Partitions_Info() ;
        std::vector<Glib::ustring> get_device_paths() ;
-       std::vector<Glib::ustring> get_alternate_paths( const Glib::ustring & path ) ;
+
 private:
        void load_proc_partitions_info_cache() ;
        static bool proc_partitions_info_cache_initialized ;
        static std::vector<Glib::ustring> device_paths_cache ;
-       static std::map< Glib::ustring, Glib::ustring > alternate_paths_cache ;
 };
 
 }//GParted
diff --git a/src/Proc_Partitions_Info.cc b/src/Proc_Partitions_Info.cc
index 5e6ed74..153c006 100644
--- a/src/Proc_Partitions_Info.cc
+++ b/src/Proc_Partitions_Info.cc
@@ -15,10 +15,11 @@
  */
 
 #include "../include/Proc_Partitions_Info.h"
+#include "../include/Utils.h"
 
+#include <glibmm/ustring.h>
+#include <vector>
 #include <fstream>
-#include <limits.h>
-#include <stdlib.h>
 
 namespace GParted
 {
@@ -26,7 +27,6 @@ namespace GParted
 //Initialize static data elements
 bool Proc_Partitions_Info::proc_partitions_info_cache_initialized = false ;
 std::vector<Glib::ustring> Proc_Partitions_Info::device_paths_cache ;
-std::map< Glib::ustring, Glib::ustring > Proc_Partitions_Info::alternate_paths_cache ;
 
 Proc_Partitions_Info::Proc_Partitions_Info()
 {
@@ -61,34 +61,22 @@ std::vector<Glib::ustring> Proc_Partitions_Info::get_device_paths()
        return device_paths_cache ;
 }
 
-std::vector<Glib::ustring> Proc_Partitions_Info::get_alternate_paths( const Glib::ustring & path ) 
-{
-       std::vector<Glib::ustring> paths ;
-       std::map< Glib::ustring, Glib::ustring >::iterator iter ;
-
-       iter = alternate_paths_cache .find( path ) ;
-       if ( iter != alternate_paths_cache .end() )
-               paths .push_back( iter ->second ) ;
-
-       return paths ;
-}
-
 //Private Methods
+
 void Proc_Partitions_Info::load_proc_partitions_info_cache()
 {
-       alternate_paths_cache .clear();
        device_paths_cache .clear() ;
 
-       //Initialize alternate_paths
        std::ifstream proc_partitions( "/proc/partitions" ) ;
        if ( proc_partitions )
        {
                std::string line ;
                Glib::ustring device;
 
+               // Read whole disk device names, excluding partitions, from
+               // /proc/partitions and save in this cache.
                while ( getline( proc_partitions, line ) )
                {
-                       //Build cache of disk devices.
                        //Whole disk devices are the ones we want.
                        //Device names without a trailing digit refer to the whole disk.
                        device = Utils::regexp_label(line, "^[\t ]+[0-9]+[\t ]+[0-9]+[\t ]+[0-9]+[\t 
]+([^0-9]+)$") ;
@@ -125,25 +113,6 @@ void Proc_Partitions_Info::load_proc_partitions_info_cache()
                                device = "/dev/" + device;
                                device_paths_cache .push_back( device ) ;
                        }
-
-                       //Build cache of potential alternate paths
-                       device = Utils::regexp_label( line, "^[ ]*[0-9]+[ ]+[0-9]+[ ]+[0-9]+[ 
]+([[:graph:]]+)$" );
-                       if ( device != "" )
-                       {
-                               device = "/dev/" + device;
-                               char * rpath = NULL;
-                               if (    file_test( device, Glib::FILE_TEST_EXISTS )
-                                    && ( ( rpath = realpath( device.c_str(), NULL ) ) != NULL )
-                                  //&& device != rpath
-                                  )
-                               {
-                                       //Because we can make no assumption about which path libparted will
-                                       //detect, we add all combinations.
-                                       alternate_paths_cache[rpath] = device;
-                                       alternate_paths_cache[device] = rpath;
-                                       free( rpath );
-                               }
-                       }
                }
                proc_partitions .close() ;
        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]