gparted r857 - in trunk: . src



Author: gedakc
Date: Sun Jun 15 17:57:48 2008
New Revision: 857
URL: http://svn.gnome.org/viewvc/gparted?rev=857&view=rev

Log:
Improved math for rounding starting sector to cylinder boundaries for logical partitions, and the first primary partition for MBR and GPT partition tables.  This fixes a problem where a resize operation could turn into a move due to problems with the snap_to_cylinder function.

Modified:
   trunk/ChangeLog
   trunk/src/GParted_Core.cc

Modified: trunk/src/GParted_Core.cc
==============================================================================
--- trunk/src/GParted_Core.cc	(original)
+++ trunk/src/GParted_Core.cc	Sun Jun 15 17:57:48 2008
@@ -109,7 +109,7 @@
 	
 	ufs fs_ufs;
 	FILESYSTEMS .push_back( fs_ufs .get_filesystem_support() ) ;
-	
+
 	xfs fs_xfs;
 	FILESYSTEMS .push_back( fs_xfs .get_filesystem_support() ) ;
 	
@@ -250,9 +250,23 @@
 {
 	if ( ! partition .strict )
 	{
-		//FIXME: this doesn't work to well, when dealing with layouts which contain an extended partition
-		//because of the metadata length % cylindersize isn't always 0
-		Sector diff = partition .sector_start % device .cylsize ;
+		Sector diff = 0;
+		if ( partition.type == TYPE_LOGICAL ||
+			 partition.sector_start == device .sectors
+		   ) {
+			//Must account the relative offset between:
+			// (A) the Extended Boot Record sector and the next track of the
+			//     logical partition (usually 63 sectors), and
+			// (B) the Master Boot Record sector and the next track of the first
+			//     primary partition
+			diff = (partition .sector_start - device .sectors) % device .cylsize ;
+		} else if ( partition.sector_start == 34 ) {
+			// (C) the GUID Partition Table (GPT) and the start of the data
+			//     partition at sector 34
+			diff = (partition .sector_start - 34 ) % device .cylsize ;
+		} else {
+			diff = partition .sector_start % device .cylsize ;
+		}
 		if ( diff )
 		{
 			if ( diff < ( device .cylsize / 2 ) )



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