Enhanced copy/paste checks when MBR/EBR involved.

svn path=/trunk/; revision=1040
This commit is contained in:
Curtis Gedak 2009-01-24 17:16:57 +00:00
parent 128796790d
commit e77e1e3dbc
3 changed files with 89 additions and 18 deletions

View File

@ -1,3 +1,9 @@
2009-01-24 Curtis Gedak <gedakc@gmail.com>
* src/Dialog_Partition_Copy.cc,
src/Win_GParted.cc: Enhanced copy/paste checks when MBR/EBR involved.
- Related to GParted bug #567402
2009-01-20 Curtis Gedak <gedakc@gmail.com> 2009-01-20 Curtis Gedak <gedakc@gmail.com>
* doc/gparted.8: Updated manual page. * doc/gparted.8: Updated manual page.

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort /* Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Bart Hakvoort
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -44,26 +44,50 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons
MB_PER_PIXEL = TOTAL_MB / 500.00 ; MB_PER_PIXEL = TOTAL_MB / 500.00 ;
long COPIED_LENGTH_MB = Utils::round( Utils::sector_to_unit( copied_partition .get_length(), GParted::UNIT_MIB ) ) ; long COPIED_LENGTH_MB = Utils::round( Utils::sector_to_unit( copied_partition .get_length(), GParted::UNIT_MIB ) ) ;
//Adjust for situation when an MSDOS partition table is in // /* Copy Primary not at start of disk to within Extended partition */
// use and a primary partition is copied and pasted into // Adjust when a primary partition is copied and pasted
// an unallocated space in an extended partition. // into an unallocated space in an extended partition
// of an MSDOS partition table.
// Since the Extended Boot Record requires an additional track, // Since the Extended Boot Record requires an additional track,
// we need to add this to the destination (selected) partition. // this must be considered in the required space for the
// Because GUI selection of partition size is in MB and we round // destination (selected) partition.
// to the cylinder size, we will increase the partition by an
// additional 8 MB. 8 MB is typical cylinder size with
// todays larger disks.
// 8 MB = (255 heads) * (63 sectors) * (512 bytes)
// NOTE: This problem does not occur for a primary partition // NOTE: This problem does not occur for a primary partition
// at the the start of the disk because the size of the EBR and // at the the start of the disk because the size of the EBR and
// Master Boot Record are the same. // Master Boot Record are the same.
//
// /* Copy Primary not at start of disk to Primary at start of disk */
// Also Adjust when a primary partition that does not start at the
// beginning of the disk is copied and pasted
// into an unallocated space at the start of the disk device.
// Since the Master Boot Record requires an additional track,
// this must be considered in the required space for the
// destination (selected) partition.
//
// Because the largest unit used in the GUI is one
// cylinder size (round to cylinders), the space
// needed in the destination partition needs to be increased
// by enough to round up one cylinder size.
// Increase by half a cylinder size (or 4 MB) because this
// will round up to the next cylinder size.
// 8 MB is typical cylinder size with todays larger disks.
// 8 MB = (255 heads) * (63 sectors) * (512 bytes)
//
//FIXME: Should confirm MSDOS partition table type, track sector size, and use cylinder size from device //FIXME: Should confirm MSDOS partition table type, track sector size, and use cylinder size from device
if ( copied_partition .type == TYPE_PRIMARY if ( (/* Copy Primary not at start of disk to within Extended partition */
&& copied_partition .sector_start != 63 copied_partition .type == TYPE_PRIMARY
&& selected_partition .type == TYPE_UNALLOCATED && copied_partition .sector_start > 63
&& selected_partition .inside_extended && selected_partition .type == TYPE_UNALLOCATED
&& selected_partition .inside_extended
)
|| ( /* Copy Primary not at start of disk to Primary at start of disk */
copied_partition .type == TYPE_PRIMARY
&& copied_partition .sector_start > 63
&& selected_partition .type == TYPE_UNALLOCATED
&& selected_partition .sector_start <=63 /* Beginning of disk device */
&& ! selected_partition .inside_extended
)
) )
COPIED_LENGTH_MB += 8 ; COPIED_LENGTH_MB += 4 ;
//now calculate proportional length of partition //now calculate proportional length of partition
frame_resizer_base ->set_x_start( 0 ) ; frame_resizer_base ->set_x_start( 0 ) ;
@ -82,7 +106,7 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons
if ( fs .filesystem == GParted::FS_XFS ) //bit hackisch, but most effective, since it's a unique situation if ( fs .filesystem == GParted::FS_XFS ) //bit hackisch, but most effective, since it's a unique situation
fs .MIN = copied_partition .sectors_used + (BUF * 2) ; fs .MIN = copied_partition .sectors_used + (BUF * 2) ;
else else
fs .MIN = (COPIED_LENGTH_MB +1) * MEBIBYTE ; fs .MIN = COPIED_LENGTH_MB * MEBIBYTE ;
GRIP = true ; GRIP = true ;
//set values of spinbutton_before //set values of spinbutton_before

View File

@ -836,9 +836,50 @@ void Win_GParted::set_valid_operations()
else else
required_size = copied_partition .get_length() ; required_size = copied_partition .get_length() ;
if ( ( required_size + devices[ current_device ] .cylsize ) <= selected_partition .get_length() ) // /* Copy Primary not at start of disk to within Extended partition */
// Adjust when a primary partition is copied and pasted
// into an unallocated space in an extended partition
// of an MSDOS partition table.
// Since the Extended Boot Record requires an additional track,
// this must be considered in the required space for the
// destination (selected) partition.
// NOTE: This problem does not occur for a primary partition
// at the the start of the disk because the size of the EBR and
// Master Boot Record are the same.
//
// /* Copy Primary not at start of disk to Primary at start of disk */
// Also Adjust when a primary partition that does not start at the
// beginning of the disk is copied and pasted
// into an unallocated space at the start of the disk device.
// Since the Master Boot Record requires an additional track,
// this must be considered in the required space for the
// destination (selected) partition.
//
// Because the largest unit used in the GUI is one
// cylinder size (round to cylinders), the space
// needed in the destination partition needs to be increased
// by one cylinder size.
if ( (/* Copy Primary not at start of disk to within Extended partition */
copied_partition .type == TYPE_PRIMARY
&& copied_partition .sector_start > devices[ current_device ] .sectors /* 63 for MSDOS Partition Table */
&& devices[ current_device ] .disktype == "msdos"
&& selected_partition .type == TYPE_UNALLOCATED
&& selected_partition .inside_extended
)
|| ( /* Copy Primary not at start of disk to Primary at start of disk */
copied_partition .type == TYPE_PRIMARY
&& copied_partition .sector_start > devices[ current_device ] .sectors /* 63 for MSDOS Partition Table */
&& devices[ current_device ] .disktype == "msdos"
&& selected_partition .type == TYPE_UNALLOCATED
&& selected_partition .sector_start <= devices[ current_device ] .sectors /* Beginning of disk device */
&& ! selected_partition .inside_extended
)
)
required_size += devices[ current_device ] .cylsize ;
if ( required_size <= selected_partition .get_length() )
allow_paste( true ) ; allow_paste( true ) ;
} }
return ; return ;
} }