[gparted] Create new method make_path_dmraid_compatible
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Create new method make_path_dmraid_compatible
- Date: Tue, 17 Aug 2010 16:38:10 +0000 (UTC)
commit 73e7f85a2f4508f81501083ee56a2483cb2931d7
Author: Curtis Gedak <gedakc gmail com>
Date: Tue Aug 17 09:27:44 2010 -0600
Create new method make_path_dmraid_compatible
This method will be used to ensure that the partition path
matches the name that would be created by the dmraid command.
include/DMRaid.h | 3 ++-
src/DMRaid.cc | 40 +++++++++++++++++++++++++++++++++++++++-
2 files changed, 41 insertions(+), 2 deletions(-)
---
diff --git a/include/DMRaid.h b/include/DMRaid.h
index 5bfb016..ac7cfc9 100644
--- a/include/DMRaid.h
+++ b/include/DMRaid.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2009 Curtis Gedak
+/* Copyright (C) 2009, 2010 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
@@ -53,6 +53,7 @@ public:
Glib::ustring get_dmraid_name( const Glib::ustring & dev_path ) ;
int get_partition_number( const Glib::ustring & partition_name ) ;
Glib::ustring get_udev_name( const Glib::ustring & dev_path ) ;
+ Glib::ustring make_path_dmraid_compatible( Glib::ustring partition_path ) ;
bool create_dev_map_entries( const Partition & partition, OperationDetail & operationdetail ) ;
bool create_dev_map_entries( const Glib::ustring & dev_path ) ;
bool delete_affected_dev_map_entries( const Partition & partition, OperationDetail & operationdetail ) ;
diff --git a/src/DMRaid.cc b/src/DMRaid.cc
index b2c9c3d..8554edf 100644
--- a/src/DMRaid.cc
+++ b/src/DMRaid.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2009 Curtis Gedak
+/* Copyright (C) 2009, 2010 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
@@ -254,6 +254,44 @@ Glib::ustring DMRaid::get_udev_name( const Glib::ustring & dev_path )
return udev_name ;
}
+Glib::ustring DMRaid::make_path_dmraid_compatible( Glib::ustring partition_path )
+{
+ //The purpose of this method is to ensure that the partition name matches
+ // the name that the dmraid command would create.
+ //
+ //From my experience, the general rule of thumb naming convention for creating
+ // partition names is as follows:
+ //
+ // A) If the device name ends in a number, then append the letter "p" and
+ // the partition number to create the partition name.
+ // For Example:
+ // Device Name : /dev/mapper/isw_cjbdddajhi_Disk0
+ // Partition Name: /dev/mapper/isw_cjbdddajhi_Disk0p1
+ //
+ // B) If the device name does not end in a number, then append the
+ // partition number only to create the partition name.
+ // For Example:
+ // Device Name : /dev/mapper/isw_cjbdddajhi_Volume
+ // Partition Name: /dev/mapper/isw_cjbdddajhi_Volume1
+ //
+ //The dmraid command appears to never add the "p" into the partition name.
+ // Instead in all cases dmraid simply appends the partition number to the
+ // device name to create a partition name.
+ //
+ for ( unsigned int k=0; k < dmraid_devices .size(); k++ )
+ {
+ Glib::ustring reg_exp = DEV_MAP_PATH + dmraid_devices[ k ] + "p([0-9]+)" ;
+ Glib::ustring partition_number = Utils::regexp_label( partition_path, reg_exp ) ;
+ if ( ! partition_number .empty() )
+ {
+ partition_path = DEV_MAP_PATH + dmraid_devices[ k ] + partition_number ;
+ break ;
+ }
+ }
+
+ return partition_path ;
+}
+
bool DMRaid::create_dev_map_entries( const Partition & partition, OperationDetail & operationdetail )
{
//Create all missing dev mapper entries for a specified device.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]