Commit Graph

2618 Commits

Author SHA1 Message Date
Mike Fleetwood 4fce7cd5ee Don't hang reading binary data from command output (#751251)
With a Kobo Touch eReader connected via USB, GParted would hang when
scanning the device with this error written to the terminal:

    $ sudo src/gpartedbin
    ======================
    libparted : 2.3
    ======================

    (gpartedbin:10261): glibmm-CRITICAL **:
    unhandled exception (type Glib::Error) in signal handler:
    domain: g_convert_error
    code  : 1
    what  : Invalid byte sequence in conversion input

The hdparm command was printing binary data as the serial number.
Fragment of the 'hdparm -I /dev/sdf' output:

    # hdparm -I /dev/sdf

    /dev/sdf:
    SG_IO: bad/missing sense data, sb[]:  70 00 05 00 00 00 00 0a 00 00 00 00 24 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

    ATAPI Optical card reader/writer, with non-removable media
            Model Number:       {BINARY_DATA}
            Serial Number:      {BINARY_DATA}
            Firmware Revision:  {BINARY_DATA}

GParted reads command output using the Glib::IOChannel class.  However
by default an IOChannel performs character set conversion on the data it
reads, so when it came across an invalid byte sequence in the binary
data the above exception was raised and the IOChannel::read() method
never returned.  Hence GParted became stuck reportedly scanning the
same device forever.  Code fragment:

src/PipeCapture.cc
    49  bool PipeCapture::OnReadable( Glib::IOCondition condition )
    50  {
    ...
    58          Glib::ustring str;
>>  59          Glib::IOStatus status = channel->read( str, 512 );
    60          if (status == Glib::IO_STATUS_NORMAL)
    61          {
    62                  for( Glib::ustring::iterator s = str.begin(); s != str.end(); s++ )

Quote from the IOChannel class reference:
    https://developer.gnome.org/glibmm/stable/classGlib_1_1IOChannel.html

    Note that IOChannels implement an automatic implicit character set
    conversion to the data stream, and usually will not pass by default
    binary data unchanged. To set the encoding of the channel, use
    e.g. set_encoding("ISO-8859-15"). To set the channel to no encoding,
    use set_encoding() without any arguments.

Fix by disabling the automatic character set conversion in the IOChannel
used to read output from executed commands.

Bug 751251 - Show serial number in device information
2015-07-01 10:22:57 -06:00
Mike Fleetwood 4b72ecd44e Display device serial numbers (#751251)
Run "hdparm -I /dev/DISK" to get the hard drive serial number of
every device which has one and display it in the Device Information.
The displayed value can either be the actual serial number, "none" or
blank.  "none" means the device doesn't have a hard drive serial number,
such as for Linux software RAID arrays, BIOS fake RAID arrays or USB
flash drives.  Blank means something went wrong getting the serial
number.  Either it couldn't be found in the hdparm output or the hdparm
command wasn't installed.

Example real hard drive:
    # hdparm -I /dev/sda
    ...
    ATA device, with non-removable media
            Model Number:       SAMSUNG HM500JI
            Serial Number:      S1WFJDSZ123732
    ...

Example Linux software RAID array:
    # hdparm -I /dev/md127

    /dev/md127:
     HDIO_DRIVE_CMD(identify) failed: Inappropriate ioctl for device

On my desktop with 4 internal hard drives 2 Linux software RAID arrays
on those hard drives, 2 USB flash drives and 1 USB hard drive attached,
running hdparm 9 times added 0.07 seconds to the device refresh time.

Bug 751251 - Show serial number in device information
2015-07-01 10:22:47 -06:00
Mike Fleetwood 8308ee6051 Support changing the UUID of a btrfs file system (#751337)
Btrfs-progs 4.1, released June 2015, includes support for changing the
UUID of a btrfs file system using the btrfstune command.  Check for
availability by looking for the -u option in the btrfstune help output.
Use btrfstune like this:

    # umount /dev/sdb1
    # btrfstune -f -u /dev/sdb1
    Current fsid: e7ad5dba-d721-4f99-990b-1ba2901c8ad2
    New fsid: 231563d9-e173-410d-b1da-d34c4319a423
    Set superblock flag CHANGING_FSID
    Change fsid in extents
    Change fsid on devices
    Clear superblock flag CHANGING_FSID
    Fsid change finished
    # echo $?
    0

Bug 751337 - btrfstune in btrfs-progs 4.1 supports changing the file
             system UUID
2015-06-28 10:57:58 -06:00
Mike Fleetwood d405bb2264 Provide comment for btrfs::clear_cache() call
Explain why the implementation uses a clear_cache() call, rather than a
straight load_cache() call.  This commit from 2014-02-17 implemented
incremental loading of the btrfs device cache:
    76e64f2905
    Detect busy status of multi-device btrfs file systems (#723842)
2015-06-13 10:56:31 -06:00
Mike Fleetwood 9be8d37600 Delay loading LVM2_PV_info cache until actually needed (#750582)
The lvm query commands were always run and the cache loaded even if
GParted, actually blkid, didn't identify any LVM2 PVs.  (GParted uses
libparted and blkid to identify partition content and the lvm commands
to provide the needed configuration details).

Now implement complete lazy initialization of the cache.  Never force
loading of the cache.  The cache is only loaded when the first value is
accessed from it.  When there are no LVM2 PVs, the cache is never
queried, so never loaded.  All the needed infrastructure for delayed
loading was previously added by this commit from 2011-12-11:
    ff8ad04120
    Lazy initialize the cache from querying LVM2 PVs (#160787)
Every public member function which access values from the cache already
calls initialize_if_required().  Just need to replace force loading of
the cache with a function which just clears the cache.

On my desktop, only when there are no LVM2 PVs, not loading the cache
and therefore not executing these external commands in
load_lvm2_pv_info_cache() saves 1.0 seconds of the 3.7 seconds it takes
to perform the a refresh in GParted:
    lvm vgscan
    lvm pvs ... -o pv_name,...
    lvm pvs ... -o vg_name,...

Bug 750582 - Refactor the LVM2_PV_Info module object interface and
             internal cache representation
2015-06-13 10:56:31 -06:00
Mike Fleetwood e6f7ea01f9 Parse LVM2_PV_Info cache into fields while loading (#750582)
GParted used to cache the results of the "lvm pvs" commands used to query
the state of the Logical Volume Manager as a series of lines of text.
Then every time a particular value was queried GParted would split all
the lines of text into fields until the required value was found.

Stop this repeat splitting of cached lines of text.  Instead parse the
lines of text into separate fields and store in structures of values of
the correct type in the cache.

Bug 750582 - Refactor the LVM2_PV_Info module object interface and
             internal cache representation
2015-06-13 10:56:15 -06:00
Mike Fleetwood 2c5e7b0d90 Stop needing any LVM2_PV_Info objects (#750582)
The LVM2_PV_Info cache had a pretend multi-object interface, yet all the
data is static.  An LVM2_PV_Info object doesn't contain any member
variables, yet was needed just to call the member functions.

Make all the member functions static removing the need to use any
LVM2_PV_Info objects.

Bug 750582 - Refactor the LVM2_PV_Info module object interface and
             internal cache representation
2015-06-13 10:56:12 -06:00
Mike Fleetwood 81f0b934bc Stop borrowing the constructor to load the LVM2_PV_Info cache (#750582)
An LVM2_PV_Info object contains no member variables as all the data is
static (exists once in the program and accessed by all objects).  The
constructor did nothing, except when passed true to load the cache.

Provide a separate load_cache() member function and remove the
constructors and destructor which do nothing.  The C++ compiler will
provide a default constructor and destructor, which don't do anything as
there are no member variables to initialise and finalise.

This makes the interface a little easier to understand.  Mostly a step
along the way of refactoring how the LVM2_PV_Info cache module works.

Bug 750582 - Refactor the LVM2_PV_Info module object interface and
             internal cache representation
2015-06-13 10:55:48 -06:00
Mike Fleetwood 7a4a375ed6 Remove Set_Data() from the copy, resize/move and new dialog class APIs
The copy, resize/move and new dialog classes (Dialog_Partition_Copy,
Dialog_Partition_Resize_Move and Dialog_Partition_New respectively) had
to be used like this:

    construct dialog object passing some parameters
    call Set_Data() to pass more parameters
    run() dialog
    call Get_New_Partition()

There is nothing in the classes which forces Set_Data() to be called,
but it must be called for the dialogs to work and prevent GParted from
crashing.

Make these class APIs safer by making it impossible to program
incorrectly in this regard.  Move all the additional parameters from
each Set_Data() method to each constructor.  The constructors just call
the now private set_data() methods.
2015-06-10 10:44:33 -06:00
Mike Fleetwood 32a5ace156 Rename Dialog_Base_Partition member to new_partition
The member variable was named selected_partition.  It is assigned from
Win_GParted::selected_partition_ptr (which is a pointer to a const
partition object so is never updated).  This gives connotations that it
won't be modified.

However it is updated freely as the new resultant partition object is
prepared before being returned from the dialog, most notable in the
Get_New_Partition() methods.

Therefore rename from selected_partition to new_partition.
2015-06-10 10:44:33 -06:00
Mike Fleetwood 8b96f8409f Stop copying selected_partition back on itself in the copy dialog (#750168)
The code goes like this:

    Dialog_Partition_Copy::Get_New_Partition()
        call Dialog_Base_Partition::Get_New_Partition()
            Update this->selected_partition with results from running
            the dialog.
            return this->selected_partition by value.
        Save value back to this->selected_partition.
        Update this->selected_partition some more.
        return this->selected_partition by value.

So there is an unnecessary copy of the partition object returned from
the base class Get_New_Partition() function back to the same variable in
the derived copy class Get_New_Partition() function.

Need to keep the base class Get_New_Partition() function as derived
class Dialog_Partition_Resize_Move uses that implementation as it
doesn't override it, and it's part of the interface.

Avoid this unnecessary copy by moving base class Get_New_Partition()
code into a new private function, called prepare_new_partition(), which
doesn't return anything.  Then have Get_New_Partition() in both classes
just return the required partition object.  Like this:

    Dialog_Base_Partition::Get_New_Partition()
        call prepare_new_partition()
        return this->selected_partition by value.

    Dialog_Partition_Copy::Get_New_Partition()
        call Dialog_Base_Partition::prepare_new_partition()
        Update this->selected_partition some more.
        return this->selected_partition by value.

Bug 750168 - Reduce the amount of copying of partition objects
2015-06-10 10:44:33 -06:00
Mike Fleetwood 90e3ed68fc Shallow copy Device object into Operation object (#750168)
When Operation objects are created they take a copy of the Device object
to which the operation is to be applied.  The Device object includes a
vector of all the contained Partition objects currently on the device,
so these get copied too.

These additional deep copied Partition objects in the Operation object
are never accessed.  Therefore don't copy the contained Partition
objects when copying the Device object into the Operation object.

Bug 750168 - Reduce the amount of copying of partition objects
2015-06-10 10:44:33 -06:00
Mike Fleetwood ece945685c Stop copying selected partition object in Manage Flags dialog (#750168)
When opening the Manage Flags dialog, creation of the dialog object was
creating a copy of the selected partition object.  If this was an
extended partition it also included recursively constructing the
contained logical partitions too.

Instead, replace the partition object in the DialogManageFlags class
with a reference to it.

Bug 750168 - Reduce the amount of copying of partition objects
2015-06-10 10:44:33 -06:00
Mike Fleetwood efaea94301 Stop copying selected partition object in Information dialog (#750168)
When opening the Partition Information dialog, creation of the dialog
object was creating a copy of the partition object to be displayed.  If
this was an extended partition it also included recursively constructing
the contained logical partitions too.

Instead, replace the partition object in the Dialog_Partition_Info class
with a reference to it.

NOTE:
In C++ a reference is really just a pointer under the hood.  As such,
dereferences of a pointer to an object in the context of needing a
reference to the object doesn't copy the object.  It merely initialises
the reference from the pointer.

Specifically, with this prototype:
    Dialog_Partition_Info( const Partition & partition );
and the dialog object being constructed in Win_GParted::activate_info():
    Dialog_Partition_Info dialog( *selected_partition_ptr );
the partition object is not copy constructed.  A reference (pointer) to
it is merely passed to the dialog constructor.

Bug 750168 - Reduce the amount of copying of partition objects
2015-06-10 10:43:43 -06:00
Mike Fleetwood 7f05037dbc Stop copying displayed partition objects in activate_resize() (#750168)
The first actions of Win_GParted::activate_resize() were to create a
copy of the vector of partitions for the currently displayed device and
visually apply any pending operations.  Exactly this has already been
done in Win_GParted::Refresh_Visual() with the result now available in
the member variable display_partitions.  Stop this unnecessary partition
object copying and processing by just using display_partitions member
variable instead.

Bug 750168 - Reduce the amount of copying of partition objects
2015-06-10 10:43:40 -06:00
Mike Fleetwood 1143917d34 Document how the GUI works and the lifetimes of important data (#750168)
Document how GParted displays partitions in the GUI and manages the
lifetime and ownership of that data.

Bug 750168 - Reduce the amount of copying of partition objects
2015-06-10 10:43:40 -06:00
Mike Fleetwood 6ae327c8f9 Assert selected_partition_ptr is valid before use (#750168)
Further ensure that a bug doesn't get introduced with the use of
selected_partition_ptr, by asserting that it points to a current
partition object in the vector of display partitions.

After deliberately breaking the code so that selected_partition_ptr
points to some other partition object, trying to display the Information
dialog causes this crash:

======================
libparted : 2.4
======================
**
ERROR:Win_GParted.cc:989:void GParted::Win_GParted::set_valid_operations(): assertion failed: (valid_display_partition_ptr( selected_partition_ptr ))
Aborted (core dumped)

At this point in the code:

    973  void Win_GParted::set_valid_operations()
    974  {
    ...
    986          // No partition selected ...
    987          if ( ! selected_partition_ptr )
    988                  return ;
>>  989          g_assert( valid_display_partition_ptr( selected_partition_ptr ) );  // Bug: Not pointing at a valid display partition object

Bug 750168 - Reduce the amount of copying of partition objects
2015-06-10 10:43:40 -06:00
Mike Fleetwood 5e027d6989 Assert selected_partition_ptr is not NULL (#750168)
Add Glib g_assert() to ensure that a bug doesn't get introduced which
allows a partition callback to be called without a partition being
selected first.

After deliberately breaking the code so that selected_partition_ptr is
not set, trying to display the Information dialog causes this crash:

    # ./gpartedbin
    ======================
    libparted : 2.4
    ======================
    ERROR:Win_GParted.cc:1978:void GParted::Win_GParted::activate_info(): assertion failed: (selected_partition_ptr != NULL)
    Aborted (core dumped)

At this point in the code:

   1976  void Win_GParted::activate_info()
   1977  {
>> 1978          g_assert( selected_partition_ptr != NULL );  // Bug: Partition callback without a selected partition
   1979

Bug 750168 - Reduce the amount of copying of partition objects
2015-06-10 10:43:17 -06:00
Mike Fleetwood da39e3cad3 Change selected partition into a pointer (#750168)
Now that TreeView_Details and DrawingAreaVisualDisk classes store and
pass pointers to partition objects in the Gtk signal callbacks, change
the selected partition into a pointer too.

Bug 750168 - Reduce the amount of copying of partition objects
2015-06-10 10:43:14 -06:00
Mike Fleetwood cc1448abd2 Store pointers to partition objects in DrawingAreaVisualDisk (#750168)
This stops copying of each displayed partition object into the
DrawingAreaVisualDisk class.

Bug 750168 - Reduce the amount of copying of partition objects
2015-06-10 10:43:14 -06:00
Mike Fleetwood acd5d7e580 Store pointers to partition objects in TreeView_Details (#750168)
This stops copying of each displayed partition object into the
TreeView_Details class.

It also stops copy constructing lots of partition objects when just
clicking on a partition in the disk graphic.  The disk graphic needs to
inform the main GUI and then the partition list which partition has been
selected.  The call sequence goes like:

    DrawingAreaVisualDisk::on_button_press_event(event)
      Win_GParted::on_partition_selected(partition_ptr, src_is_treeview)
        TreeView_Detail::set_selected(partition_ptr)
          TreeView_Detail::set_selected(rows, partition_ptr,
                                        inside_extended)

Relevant source and highlighted comparison line:

   140  bool TreeView_Detail::set_selected( Gtk::TreeModel::Children rows,
   141                                      const Partition * partition_ptr, bool inside_extended )
   142  {
   143          for ( unsigned int t = 0 ; t < rows .size() ; t++ )
   144          {
>> 145                  if ( static_cast<Partition>( rows[t][treeview_detail_columns.partition] ) == *partition_ptr )
   146                  {
   147                          if ( inside_extended )
   148                                  expand_all() ;
   149
   150                          set_cursor( static_cast<Gtk::TreePath>( rows[ t ] ) ) ;
   151                          return true ;
   152                  }
   153
   154                  if ( set_selected( rows[t].children(), partition_ptr, true ) )
   155                          return true ;
   156          }
   157
   158          return false ;
   159  }

Then in this function the partition selected in the disk graphic
(partition_ptr parameter) is compared in turn with each partition object
stored in the Gtk::TreeView model to find the matching one to mark it as
selected.  This mere act of accessing the partition object stored in a
row of the Gtk::TreeView model causes it to be copy constructed.  So
clicking on the 5th partition in the disk graphic will copy construct
the first 5 partition objects just to do a compare to find the matching
one.

This is because it is not possible to get a reference from a
Gtk:TreeViewProxy in gtkmm.  Merely accessing a value in a Gtk::TreeView
model takes a copy of that value.

    Subject: get a reference from a Gtk::TreeValueProxy
    http://comments.gmane.org/gmane.comp.gnome.gtkmm/2217
    http://marc.info/?t=104400417500001&r=1&w=4

Bug 750168 - Reduce the amount of copying of partition objects
2015-06-10 10:43:14 -06:00
Mike Fleetwood c430acf52a Pass by pointer in the signal_partition_selected callbacks (#750168)
Change from passing a reference to the selected partition, to passing a
pointer to the selected partition in the signal_partition_selected
callbacks between the disk graphic, partition list and core GUI modules.

This is an enabler for the following patches.

Bug 750168 - Reduce the amount of copying of partition objects
2015-06-10 10:43:14 -06:00
Mike Fleetwood 545b75d957 Move vector of partition objects to a Win_GParted class member (#750168)
Win_GParted::Refresh_Visual() used a local variable containing a copy of
the vector of partitions in the current device to be displayed.  After
visually applying pending operations it loaded copies of each partition
object into the GUI widgets to display the disk graphic and partition
list, DrawingAreaVisualDisk and TreeView_Details classes respectively.
When a partition is selected in the UI, again a partition object is
copied.  Also several of the partition dialogs, including the
information dialog, take a copy of the partition object.  All these are
copies of the same set of partition objects, those currently being
displayed in the UI.

Move the vector of displayed partitions from a local variable in
Refresh_Visual() to a Win_GParted member variable.  This will allow for
the above cases to be changed to used pointers and references to the
same set of partition objects.

The valid lifetime of pointers to elements in this partition object
vector is from one refresh to the next, when the vector is cleared and
repopulated with a new set of partition objects.  This is exactly what
is needed as the GUI widgets are reloaded on each refresh, the selected
partition is reset and none of the partition dialog objects exist.
Dialog objects being created and destroyed on each use.

On the other hand some copies of partition objects currently being
displayed, still need to be made because they have lifetimes which need
to last longer than the next call to Refresh_Visual().  Specifically the
source of the copy partition and the partition objects copied into the
in the list of pending operations.

Bug 750168 - Reduce the amount of copying of partition objects
2015-06-10 10:42:36 -06:00
Gábor Kelemen 7090866b2a Updated Hungarian translation 2015-06-01 14:27:03 +00:00
Mike Fleetwood 8bbb77f1f8 Remove cylinder size adjustments in the copy dialog (#749867)
BUF in the copy dialog class, Dialog_Partition_Copy, is use to adjust
limits in 2 cases:

1) Minimum size when copying an XFS file system

Minimum size was set to the used space + 2 * cylinder size (typically
plus ~16 MiB).  This commit from 2004-12-20 added it:
    a54b52ea33
    xfs copy now uses xfsdump and xfsrestore. icw some hacks in the other 2

Issues:
* This is increasing the minimum XFS file system size when copying it,
  which doesn't happen in the resize case for other file systems.
* It allows an XFS file system to be created which is smaller than the
  minimum size allowed by GParted.  Copying an empty XFS file system can
  create a new file system as small as 26 MiB.  This is smaller than the
  minimum GParted allows of 32 MiB because that is the minimum
  xfs_repair can handle.

Remove this addition when copying an XFS file system and enforce minimum
file system size.

2) Maximum size when copying a file system into empty space larger than
   it's maximum size

Maximum size was set to maximum file system size - cylinder size
(typically minus ~8 MiB).  Only applied to FAT16 which has a maximum
file system size set in and can be grown.  Added by this commit from
2004-12-15:
    10e8f3338d
    :get_fs now returns a const reference. in copy and resizedialog
    ...
    * in copy and resizedialog filesystems with MAX set now have a max size of MAX - one cylinder .

Issue:
* This is applying a lower maximum resize when copying the file system
  compared to that when creating the file system.
  NOTE:
  GParted currently allows all file systems to be resize to any size,
  regardless of the maximum file system size.  This is probably an
  oversight, but it does allow libparted to convert FAT16 to FAT32 file
  system when resizing.

Remove this lower maximum file system size when copying and resizing,
compared to creating.

Bug 749867 - Some limits are adjusted by arcane cylinder size amount
             when copying and resizing in a single operation
2015-05-28 12:53:41 -06:00
Mike Fleetwood b9262922a7 Remove last trace of cylinder size adjustments in the resize dialog (#749867)
This commit from 2010-05-20 removed use of cylinder size increase in the
minimum, and cylinder size decrease in the maximum file system sizes
from the resize/move dialog.
    e62a23b5b5
    Add partition alignment option to align to MiB (#617409)

This cylinder size limit adjustments were being performed using the
Dialog_Base_Partition::BUF member variable.  Now in the
Dialog_Partition_Resize_Move class it is never accessed, and only
unnecessarily set.  Move BUF from the common base class into the
Dialog_Partition_Copy class where it is still used.

Bug 749867 - Some limits are adjusted by arcane cylinder size amount
             when copying and resizing in a single operation
2015-05-28 12:44:51 -06:00
Mike Fleetwood 9ced6b051e Small simplification of Win_GParted code which calls get_custom_text()
Avoid long lines, long statements and repeated calls to
gparted_core.get_filesystem_object( selected_partition.filesystem ) by
storing the returned pointer in a local variable.

Needs the previous commit so that the the local variable can be a
pointer to a const FileSystem object instead of a pointer to a
(modifiable) FileSystem object.
2015-05-19 10:34:59 -06:00
Mike Fleetwood f6e4390aaf Add const qualifier to get_custom_text() member functions
The function never modifies any member variables so make it a const
member function.

(FileSystem::get_custom_text() is a virtual function so can't be made
static).
2015-05-19 10:34:59 -06:00
Mike Fleetwood d0580d5955 Rename two GParted_Core methods to detect_filesystem*()
Rename a couple of GParted_Core methods for consistency and to better
distinguish get_filesystem() from get_filesystems() which do completely
unrelated things.

  get_filesystem()                 -> detect_filesystem()
  recognise_filesystem_signature() -> detect_filesystem_internal()

Also make detect_filesystem() a static member method as it doesn't use
any member variables.  Requirement cascades to get_partition_path().
2015-05-07 08:01:43 -06:00
Mike Fleetwood 42cd956a54 Make GParted_Core methods flush_device(), get_device(), etc static
GParted_Core methods:
    flush_device()
    get_device()
    get_disk()
    get_device_and_disk()
    destroy_device_and_disk()
    commit()
    commit_to_os()
    settle_device()

This group of methods only call libparted API functions and run external
executables.  None of them access any GParted_Core member variables.
Make them all static member functions.
2015-05-07 08:01:43 -06:00
Mike Fleetwood df000a94a6 Tidy-up GParted_Core::init/fini_filesystems() function declarations
These member functions are only used within the GParted_Core class and
only operate on the static member variable FILESYSTEM_MAP.

Make both functions private and also make init_filesystems() static.
2015-05-07 08:01:43 -06:00
Mike Fleetwood 40820bada7 Fix memory leak of FileSystem objects in init_filesystems() (#749036)
The FileSystem objects stored in the FILESYSTEM_MAP are allocated once
using new in init_filesystems() but never deleted.

Valgrind output fragment:

    # valgrind --leak-check=full ./gparted
    ==29314== 353 (72 direct, 281 indirect) bytes in 1 blocks are definitely lost in loss record 6,287 of 6,905
    ==29314==    at 0x4A075FC: operator new(unsigned long) (vg_replace_malloc.c:298)
>>  ==29314==    by 0x46EDA5: GParted::GParted_Core::init_filesystems() (GParted_Core.cc:106)
    ==29314==    by 0x46EC5F: GParted::GParted_Core::GParted_Core() (GParted_Core.cc:96)
    ==29314==    by 0x4A74F4: GParted::Win_GParted::Win_GParted(std::vector<Glib::ustring, std::allocator<Glib::ustring> > const&) (Win_GParted.cc:51)
    ==29314==    by 0x4D600A: main (main.cc:56)
    ...
    ==29314== 161 (72 direct, 89 indirect) bytes in 1 blocks are definitely lost in loss record 6,119 of 6,905
    ==29314==    at 0x4A075FC: operator new(unsigned long) (vg_replace_malloc.c:298)
>>  ==29314==    by 0x46F50C: GParted::GParted_Core::init_filesystems() (GParted_Core.cc:124)
    ==29314==    by 0x46EC5F: GParted::GParted_Core::GParted_Core() (GParted_Core.cc:96)
    ==29314==    by 0x4A74F4: GParted::Win_GParted::Win_GParted(std::vector<Glib::ustring, std::allocator<Glib::ustring> > const&) (Win_GParted.cc:51)
    ==29314==    by 0x4D600A: main (main.cc:56)

GParted_Core.cc source:

   102  void GParted_Core::init_filesystems()
   103  {
   104          FILESYSTEM_MAP[ FS_UNKNOWN ]         = NULL ;
   105          FILESYSTEM_MAP[ FS_CLEARED ]         = NULL ;
>> 106          FILESYSTEM_MAP[ FS_BTRFS ]           = new btrfs() ;
   ...
>> 124          FILESYSTEM_MAP[ FS_XFS ]             = new xfs() ;
   125          FILESYSTEM_MAP[ FS_BITLOCKER ]       = NULL ;

Fix by deleting all FILESYSTEM_MAP pointers.  Note that delete on a NULL
pointer is defined by C++ as a safe do nothing operation.

    C++ FAQ / Do I need to check for null before delete p?
    https://isocpp.org/wiki/faq/freestore-mgmt#delete-handles-null

Fixing this reduces the valgrind reported definitely lost memory blocks
count from 25 down to 6.  19 FileSystem objects deleted and 19 memory
blocks no longer lost.

Bug 749036 - FileSystem objects are memory leaked in init_filesystems()
2015-05-07 08:01:43 -06:00
Daniel Șerbănescu aaddc15295 Updated Romanian Translation 2015-04-24 08:39:45 +02:00
Sveinn í Felli 5aa58519b6 Updated Icelandic translation 2015-04-22 10:15:44 +00:00
Sveinn í Felli 1002864e4c Updated Icelandic translation 2015-04-22 10:09:25 +00:00
Jordi Mas 6630320b0d Fixes to Catalan translation 2015-04-18 20:07:17 +02:00
Akom Chotiphantawanon ec910b9699 Updated Thai translation 2015-04-07 12:46:02 +07:00
Dušan Kazik b549a48640 Updated Slovak translation 2015-04-01 18:25:44 +00:00
Piotr Drąg 038274c9fd Updated Polish translation 2015-03-29 21:00:27 +02:00
GNOME Translation Robot 4baaf4436f Updated Scottish Gaelic translation 2015-03-28 11:23:27 +00:00
Marek Černocký 239723d78c Updated Czech translation 2015-03-27 15:42:07 +01:00
GNOME Translation Robot a76289046a Updated Scottish Gaelic translation 2015-03-27 10:16:19 +00:00
Curtis Gedak dcab9ad845 Minor change to help manual caution when copying a partition (#746559)
Bug 746559 - Various operations fail when following paste into existing
             partition
2015-03-26 20:33:09 +00:00
Mike Fleetwood cca8a55f51 Refactor operation cases in apply_operation_to_disk() (#746559)
Background:

GParted_Core::calibrate_partition() reloads the partition path name and
boundary to ensure they are correct before the operation is performed.
(See comments in calibrate_partition() for the reasons why this is
necessary).  This also displays details of the partition being modified
in the operation details to inform the user.

The operation object contains these relevant member objects:

  * partition_original
    Partition before the operation is applied.

  * partition_new
    Partition as it is intended to be after the operation has been
    applied.

  * partition_copied (for the copy operation only)
    Source partition being copied.

Issues:

GParted_Core::apply_operation_to_disk() was always calibrating partition
object partition_original, but for about half the operations
partition_original was not used and partition_new is used, so should be
calibrated instead.

Copy into an existing partition calibrated three partitions, the source,
destination before and destination after the operation was applied.
This doesn't really make sense in the operation details to the user.
They would expect to only see the source and destination partitions and
don't care about the distinction between the before and after
representation of the destination.

Minor issues:

The previous fix had to copy the correct partition path from the
calibrated partition_original object to the used partition_new object
for the format, label file system, name partition and change uuid
operations.

Calibrate was called for the create operation too, even though the
partition didn't yet exist.  It was a no-operation.

Fix:

Stop always calibrating the partition_original object and instead
calibrate the correct partition object in each operation case.  For the
copy into existing partition operation only calibrate the right two
partition objects as the user would expect.

Bug 746559 - Various operations fail when following paste into existing
             partition
2015-03-26 20:33:09 +00:00
Mike Fleetwood d9993c21ba Fix failing operations following paste into existing partition (#746559)
Format, label file system and new UUID operations would fail when
applied in a sequence to the destination partition following a previous
copy-paste operation.

Giving the copy of a file system a new label and a new UUID are the sort
of actions which should be performed when the disk containing the copy
remains attached to the same computer.  This really should work.

Fragment of the failing operation details for a copy and label operation
sequence:

    + Copy /dev/sdb1 to /dev/sdb2
      + calibrate /dev/sdb2
      + calibrate copy of /dev/sdb1
      + calibrate /dev/sdb1
      + check the file system on /dev/sdb1 for errors and (if possible fix them
      + copy file system of /dev/sdb1 to /dev/sdb2
    + Set file system label "small-dst" on copy of /dev/sdb1
      + calibrate copy of /dev/sdb1
          path: /dev/sdb2 (partition)
          ...
      + set file system label to "small-dst" on copy of /dev/sdb1
        + e2label copy of /dev/sdb1 "small-dst"
          Usage: e2label device [newlabel]

This is failing because the file system specific command is passed
"copy of /dev/sdb1" as the device name.  Code sequence:

 1) OperationCopy::OperationCopy() sets the real path name of the
    partition_new object to "copy of /dev/SRC" for display purposes.

 2) GParted_Core::apply_operation_to_disk() calls calibrate_partition()
    on partition_original object, restoring the real path name for
    object partition_original.

 3) apply_operation_to_disk() calls format(), label_filesystem() or
    change_uuid() on the partition_new object, which still has the real
    path name set to "copy of /dev/SRC".  File system specific commands
    fail with this as a path name.

Fix by copying the real path name from object partition_original to
partition_new, as is already done for the resize/move operation.  Also
apply this fix to the name partition operation, because it uses the
partition_new object and so that it displays the real path name in the
operation details.

Bug 746559 - Various operations fail when following paste into existing
             partition
2015-03-26 20:33:09 +00:00
Marek Černocký c83e37fe0e Updated Czech translation 2015-03-26 00:41:59 +01:00
Stas Solovey 33bce8cdbc Updated Russian translation 2015-03-25 19:47:31 +00:00
Mike Fleetwood 8d005aff1a Name partitions as required when creating a new partition (#746214)
When the partition is named in the Create New Partition dialog, set the
partition name as part of the create partition operation.  Currently
this is only supported for GPTs.  See
Utils::get_max_partition_name_length() for details.

Bug 746214 - Partition naming enhancements
2015-03-25 10:02:43 -06:00
Mike Fleetwood 5fd7c92671 Add partition name to Create New Partition dialog (#746214)
Add a partition name entry box to the Create New Partition dialog.  The
entry box is greyed out (not sensitive) for partition table types which
don't support partition naming.  Currently only supported for GPTs.  See
Utils::get_max_partition_name_length() for details.

There was a slightly wider gap between the file system combobox row and
the label entry row when there were only three widgets on the right hand
side of the dialog.  This has been removed now that there are four
widgets so that they are all evenly spaced and they line up with the
four widgets on the left hand side.

So far the partition name can be entered and previewed, but isn't yet
applied to the disk.

Bug 746214 - Partition naming enhancements
2015-03-25 10:02:43 -06:00
Mike Fleetwood 6a9a06af0e Pass Device object when setting up Dialog_Partition_New (#746214)
Adding a partition name entry to the Create New Partition dialog will
need access to these two Device methods: partition_naming_supported()
and get_max_partition_length().  The Set_Data() function already takes
two parameters, only_unformatted and disktype, taken from Device member
variables.

Rather than add two more parameters to the Set_Data() function pass the
Device object instead, replacing the current only_unformatted and
disktype parameters.

Bug 746214 - Partition name enhancements
2015-03-25 10:02:43 -06:00