[gparted] Add check if partition table re-read work around code is needed



commit 39208ba2afb576980cae5a27a6cf75b1f71c7d7f
Author: Curtis Gedak <gedakc gmail com>
Date:   Mon Mar 1 11:04:17 2010 -0700

    Add check if partition table re-read work around code is needed
    
    A patch to alleviate the "failure to inform kernel of partition
    changes problem" (bug #604298) has been included in parted-2.2.
    Hence when parted-2.2 or higher is used, the work around code in
    GParted is not required.

 configure.in        |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 src/GParted_Core.cc |    5 +++--
 2 files changed, 54 insertions(+), 2 deletions(-)
---
diff --git a/configure.in b/configure.in
index 1f78e01..ff7ecff 100644
--- a/configure.in
+++ b/configure.in
@@ -82,6 +82,55 @@ int main ()
 LIBS="$LIBS_save"
 
 
+dnl======================
+dnl check whether libparted >= 2.2 (has improved partition table re-read code)
+dnl======================
+LIBPARTED_VERSION=2.2
+AC_MSG_CHECKING(if libparted >= $LIBPARTED_VERSION (has improved pt re-read))
+LIBS_save="$LIBS"
+LIBS="-lparted -luuid -ldl"
+need_work_around=yes
+AC_TRY_RUN(
+#include <stdio.h>
+#include <parted/parted.h>
+
+int main ()
+{
+	int min_major = 0;
+	int min_minor = 0;
+	int min_micro = 0;
+	int major = 0;
+	int minor = 0;
+	int micro = 0;
+
+	if ( ( sscanf( "$LIBPARTED_VERSION", "%d.%d.%d", &min_major, &min_minor, &min_micro ) == 3 ) ||
+	     ( sscanf( "$LIBPARTED_VERSION", "%d.%d", &min_major, &min_minor ) == 2 ) ||
+	     ( sscanf( "$LIBPARTED_VERSION", "%d", &min_major ) == 1 )
+	   )
+	{
+		if ( ( sscanf( ped_get_version(), "%d.%d.%d", &major, &minor, &micro ) == 3 ) ||
+		     ( sscanf( ped_get_version(), "%d.%d", &major, &minor ) == 2 ) ||
+		     ( sscanf( ped_get_version(), "%d", &major ) == 1 )
+		   )
+		{
+			return ! ( (major > min_major) ||
+			           ( (major == min_major) && (minor > min_minor) ) ||
+			           ( (major == min_major) && (minor == min_minor) && (micro >= min_micro) )
+			         ) ;
+		}
+	}
+
+	return 1 ;
+}
+,[AC_MSG_RESULT(yes)
+  AC_DEFINE([HAVE_LIBPARTED_2_2_0_PLUS], [1], [Define to 1 if libparted contains improved partition table re-read code])
+  need_pt_reread_work_around=no]
+,[AC_MSG_RESULT(no)
+  need_pt_reread_work_around=yes]
+)
+LIBS="$LIBS_save"
+
+
 dnl GTKMM
 PKG_CHECK_MODULES(GTKMM, gtkmm-2.4 > 2.8 )
 AC_SUBST(GTKMM_LIBS)
@@ -147,5 +196,7 @@ echo "          Installing into prefix  :  $prefix"
 echo ""
 echo "            Build documentation?  :  $enable_doc"
 echo ""
+echo "    Need pt re-read work around?  :  $need_pt_reread_work_around"
+echo ""
 echo " If all settings are OK, type make and make install "
 echo "========================================================"
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 6c07adb..2485f01 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -2783,8 +2783,8 @@ bool GParted_Core::commit_to_os( std::time_t timeout )
 	else
 	{
 		succes = ped_disk_commit_to_os( lp_disk ) ;
-
-		//FIXME:  Work around to try to alleviate problems caused by
+#ifndef HAVE_LIBPARTED_2_2_0_PLUS
+		//Work around to try to alleviate problems caused by
 		//  bug #604298 - Failure to inform kernel of partition changes
 		//  If not successful the first time, try one more time.
 		if ( ! succes )
@@ -2792,6 +2792,7 @@ bool GParted_Core::commit_to_os( std::time_t timeout )
 			sleep( 1 ) ;
 			succes = ped_disk_commit_to_os( lp_disk ) ;
 		}
+#endif
 	}
 
 	settle_device( timeout ) ;



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