diff --git a/include/GParted_Core.h b/include/GParted_Core.h index 55434c0b..1c85ca1f 100644 --- a/include/GParted_Core.h +++ b/include/GParted_Core.h @@ -46,8 +46,9 @@ public: bool snap_to_mebibyte( const Device & device, Partition & partition, Glib::ustring & error ) ; bool snap_to_alignment( const Device & device, Partition & partition, Glib::ustring & error ) ; bool apply_operation_to_disk( Operation * operation ); - - bool set_disklabel( const Glib::ustring & device_path, const Glib::ustring & disklabel ) ; + + bool set_disklabel( const Device & device, const Glib::ustring & disklabel ); + bool new_disklabel( const Glib::ustring & device_path, const Glib::ustring & disklabel ); bool toggle_flag( const Partition & partition, const Glib::ustring & flag, bool state ) ; diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index e4f5584a..8d435264 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -802,10 +802,33 @@ bool GParted_Core::apply_operation_to_disk( Operation * operation ) return succes ; } -bool GParted_Core::set_disklabel( const Glib::ustring & device_path, const Glib::ustring & disklabel ) +bool GParted_Core::set_disklabel( const Device & device, const Glib::ustring & disklabel ) +{ + Glib::ustring device_path = device.get_path(); + + if ( disklabel == "loop" ) + { + // Ensure that any previous whole disk device file system can't be + // recognised in preference to the "loop" partition table signature about + // to be written. + OperationDetail dummy_od; + Partition temp_partition; + temp_partition.Set_Unallocated( device_path, + true, + 0LL, + device.length - 1LL, + device.sector_size, + false ); + erase_filesystem_signatures( temp_partition, dummy_od ); + } + + return new_disklabel( device_path, disklabel ); +} + +bool GParted_Core::new_disklabel( const Glib::ustring & device_path, const Glib::ustring & disklabel ) { bool return_value = false ; - + PedDevice* lp_device = NULL ; PedDisk* lp_disk = NULL ; if ( get_device( device_path, lp_device ) ) diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc index fac415af..609bfcf3 100644 --- a/src/Win_GParted.cc +++ b/src/Win_GParted.cc @@ -2396,7 +2396,7 @@ void Win_GParted::activate_disklabel() if ( dialog .run() == Gtk::RESPONSE_APPLY ) { - if ( ! gparted_core .set_disklabel( devices[ current_device ] .get_path(), dialog .Get_Disklabel() ) ) + if ( ! gparted_core.set_disklabel( devices[current_device], dialog.Get_Disklabel() ) ) { Gtk::MessageDialog dialog( *this, _("Error while creating partition table"),