When configuring GParted build with libparted from GIT it may perform
the version compares incorrectly and think the version of libparted is
higher that it actually is. Libparted uses the number of commits from
the last git tag as the third part of the version number.
For example install libparted from one commit before release 3.1, 142
commits after release 3.0.
$ git checkout v3.1^
$ describe
v3.0-142-g82327a3
$ ./bootstrap
$ ./configure --prefix=/tmp/parted-3.0-git
$ make && make install
Configure GParted:
$ export CPPFLAGS=-I/tmp/parted-3.0-git/include
$ export LDFLAGS=-L/tmp/parted-3.0-git/lib
$ export LD_RUN_PATH=/tmp/parted-3.0-git/lib
$ export PKG_CONFIG_PATH=/tmp/parted-3.0-git/lib/pkgconfig
$ ./configure
...
checking for libparted >= 1.7.1 (querying pkg-config)... 3.0.142-8232
checking for 2.0 <= libparted <= 3.0 (loop table creation doesn't delete old partitions)... (cached) no
checking for libparted >= 2.2 (improved pt re-read)... (cached) yes
checking for ped_file_system_resize in -lparted... no
checking for ped_file_system_resize in -lparted-fs-resize... yes
checking for libparted >= 3.2 (online resize)... (cached) no
...
Libparted is reported as version 3.0.142, but checking of the version
between 2.0 and 3.0 inclusive fails.
The configure script is multiplying components of the version by 100
when adding them together.
$ echo 3.0.142-8232 | awk -F. '{print $1 * 10000 + $2 * 100 + $3}'
30142
So it is only allowing up to 99 commits before it is equivalent to the
second minor number increasing by one. Increase the multiplication
factor to 10000, allowing up to 9999 commits between releases. An order
of magnitude more commits than so far seen between parted releases.
Bug 753525 - Configuration issues when using non-system location or
non-released versions of libparted
When configuring GParted build with a custom install of libparted the
configure script is using the wrong version number for the version of
libparted. It uses the version of the system install of libparted,
rather that the version of the specified custom install of libparted.
For example configuring GParted build on CentOS 7 with system provided
libparted 3.1 and custom install of libparted 3.2 from GIT in
/tmp/parted-3.2-git:
$ export CPPFLAGS=-I/tmp/parted-3.2-git/include
$ export LDFLAGS=-L/tmp/parted-3.2-git/lib
$ export LD_RUN_PATH=/tmp/parted-3.2-git/lib
$ ./configure
...
checking for libparted >= 1.7.1 (querying pkg-config)... 3.1
checking for 2.0 <= libparted <= 3.0 (loop table creation doesn't delete old partitions)... (cached) no
checking for libparted >= 2.2 (improved pt re-read)... (cached) yes
checking for ped_file_system_resize in -lparted... no
checking for ped_file_system_resize in -lparted-fs-resize... yes
checking for libparted >= 3.2 (online resize)... (cached) no
...
$ make
$ ldd src/gpartedbin | fgrep libparted
libparted-fs-resize.so.0 => /tmp/parted-3.2-git/lib/libparted-fs-resize.so.0 (0x00007f9a460ee000)
libparted.so.2 => /tmp/parted-3.2-git/lib/libparted.so.2 (0x00007f9a45ea3000)
Configure script used version 3.1 as reported by pkg-config to make most
of the decisions (those version related checks with cached results) but
the executable was still linked with the custom libparted 3.2 install.
Temporarily rename the system libparted pkg-config file out of the way:
# cd /usr/lib64/pkgconfig
# mv libparted.pc libparted.pc-NOT
and reconfigure the GParted build:
$ ./configure
...
checking for libparted >= 1.7.1 (querying pkg-config)... not found
checking for libparted >= 1.7.1 (querying libparted)... 3.2.25-5a92
checking for 2.0 <= libparted <= 3.0 (loop table creation doesn't delete old partitions)... (cached) no
checking for libparted >= 2.2 (improved pt re-read)... (cached) yes
checking for ped_file_system_resize in -lparted... no
checking for ped_file_system_resize in -lparted-fs-resize... yes
checking for libparted >= 3.2 (online resize)... (cached) yes
...
Now configure is having to compile a program with the custom install of
libparted and gets the correct version.
Restore libparted pkg-config file:
# mv libparted.pc-NOT libparted.pc
and this time set environment variable PKG_CONFIG_PATH to inform
pkg-config of the additional directory to search for .pc files before
the default system location:
$ export PKG_CONFIG_PATH=/tmp/parted-3.2-git/lib/pkgconfig
$ ./configure
...
checking for libparted >= 1.7.1 (querying pkg-config)... 3.2.25-5a92
checking for 2.0 <= libparted <= 3.0 (loop table creation doesn't delete old partitions)... (cached) no
checking for libparted >= 2.2 (improved pt re-read)... (cached) yes
checking for ped_file_system_resize in -lparted... no
checking for ped_file_system_resize in -lparted-fs-resize... yes
checking for libparted >= 3.2 (online resize)... (cached) yes
...
Now configure is getting the correct version of the custom install of
libparted when querying pkg-config and thus making the correct
decisions.
Update the README file to reflect the need to also set the
PKG_CONFIG_PATH environment variable when building GParted with a custom
install of libparted.
Bug 753525 - Configuration issues when using non-system location or
non-released versions of libparted
The ntfs-3g package previously provided the FUSE based NTFS driver to
mount the file system and ntfsprogs provided the user space tools. In
April 2011 the packages have merged [1] forming ntfs-3g_ntfsprogs. Arch
Linux / Debian / Slackware / Ubuntu now just have an ntfs-3g package
with everything; where as CentOS / Fedora / openSUSE are sticking with
the original two package names. Reverse the order of the needed
packages to:
ntfs-3g / ntfsprogs
[1] Release: NTFS-3G + NTFSPROGS 2011.4.12
http://www.tuxera.com/release-ntfs-3g-ntfsprogs-2011-4-12/
For reiserfs the upstream package is named reiserfsprogs. Arch Linux /
Debian / Slackware / Ubuntu use this name; but CentOS / Fedora name it
reiserfs-utils and openSUSE names it just reiserfs. Update the README
file with all 3 package names.
reiserfsprogs / reiserfs-utils / reiserfs
In the File System Support dialog just use the first 2 package names as
we don't want to make the dialog too wide with all 3 names and hopefully
on openSUSE it is more obvious that the reiserfs package is needed to
support the reiserfs file system.
NOTE:
Again this slightly increases the width of the File System Support
dialog on my CentOS 6 desktop with default fonts, now from 676 to 707
pixels. Again still well within the 800 wide target and still narrower
than the main window.
Bug 753436 - Update documentation of GParted software dependencies
In Fedora bug report:
Bug 1176108 - Warning shown on BTRFS partition because of missing btrfs-tools package
https://bugzilla.redhat.com/show_bug.cgi?id=1176108#c0
The user said:
However there is no btrfs-tools package in the standard Fedora repo.
There is a btrfs-progs package, which is already installed. It's
unclear whether this is a real error or simply a mismatched package
name.
The upstream software is named btrfs-progs. Arch Linux / CentOS /
Fedora / Slackware use the upstream name. Debian / Ubuntu name it
btrfs-tools and openSUSE calls it btrfsprogs (no dash).
Rename the needed software to:
btrfs-progs / btrfs-tools
Upstream name first separated by slash from alternative names
distributions use.
NOTE:
This slightly increases the width of the File System Support dialog on
my CentOS 6 desktop with default fonts, from 655 to 676 pixels. Still
well within the 800 wide target and still narrower that the main window.
Bug 753436 - Update documentation of GParted software dependencies
Update the README file to document the blkid command as a mandatory
requirement for GParted. GParted will run without blkid but it is
needed to detect a number of file systems which libparted doesn't and in
a number of other situations.
Blkid is needed to detect these file systems:
exfat
f2fs
ReFS
SWRaid
ZFS
Blkid also detects these file systems (for which GParted has simple
internal detection but libparted, mostly, doesn't detect):
btrfs (detected by libparted >= 3.2)
LVM2 PV
LUKS
nilfs2 (detected by libparted >= 2.4)
reiser4
Blkid is also needed for these commits:
1) f8faee6377
Avoid whole disk FAT being detected as MSDOS partition table (#743181)
(with libparted 1.9.0 to 2.3 inclusive)
2) 9e5e9f5627
Enhance file system detection to use FS_Info method - blkid
(Detect file systems with sector sizes other than 512 bytes with
libparted 2.2)
Other changes to the DISTRIBUTION NOTES section of the README file:
* Drop NOTE about vol_id and blkid being used to read volume labels for
specific file systems and read the UUIDs. Vol_id was deprecated in
May 2009 and is not included in any currently supported distribution.
Blkid is now mandatory. List of optional commands at the end of the
section seems to cover everything that is necessary.
* Indent description of optional commands at the end of the section to
match the indentation earlier in the section.
* Line wrap the section at column 72 to match the rest of the file.
Bug 753436 - Update documentation of GParted software dependencies
This message would be displayed as part of the details for an operation
to create or format a partition as LVM2 PV on a disk using partition
table types dvh or pc98, which don't have an lvm flag.
v Format /dev/sdb1 as lvm2 pv
> calibrate /dev/sdb1
> clear old file system signatures in /dev/sdb1
> set partition type on /dev/sdb1
Skip setting unsupported partition flag: lvm
> create new lvm2 pv file system
Translators found this message difficult to translate, as reported in
bug 752901 - Add translator comment or fix string. It is also only
standard practice to set the lvm flag on partitions containing LVM2 PVs,
and not required. In hindsight reporting that an operation was skipped,
when the operation is not a necessity, is probably bad practice as it
could lead to uncertainty on behalf of the user and questions as to why
the flag isn't supported. Just remove the message.
Correct the colour name comment for NILFS2.
Colour for LVM2 PV was a Medium Brown. This is close to Face Skin Dark
from the GNOME colour palette. Use this instead.
Make colour for ReFS a bit darker so it is more distinct from the colour
for NTFS.
Add translation comments to improve the clarity of some translatable
text strings regarding setting partition flags.
Bug 752901 - Add translator comment or fix string
Opening the Resize/Move dialog on a logical partition causes GParted to
crash. This crash affects current GParted GIT HEAD, but does not affect
GParted 0.22.0. Git bisect identifies that it was broken with the
following commit:
Remove Set_Data() from the copy, resize/move and new dialog class APIs
7a4a375ed6
The problem was trying to treat the reference display_partitions_ref
like a pointer, and in particular on line 1732 trying to make it refer
to the a different vector of partitions, .logicals sub-vector.
1721 void Win_GParted::activate_resize()
1722 {
...
1726 std::vector<Partition> & display_partitions_ref = display_partitions;
1727 if ( selected_partition_ptr->type == TYPE_LOGICAL )
1728 {
1729 unsigned int ext = 0 ;
1730 while ( ext < display_partitions.size() && display_partitions[ext].type != TYPE_EXTENDED )
1731 ext++;
* 1732 display_partitions_ref = display_partitions[ext].logicals;
1733 }
1734
1735 Dialog_Partition_Resize_Move dialog( gparted_core.get_fs( selected_partition_ptr->filesystem ),
1736 *selected_partition_ptr,
1737 display_partitions_ref );
What was actually happening was that the .logicals sub-vector was being
copied, replacing the display_partitions vector and freeing the original
sub-vector. This left selected_partition_ptr pointing to the original
memory where the selected partition use to exist in the .logicals
sub-vector. At some point in the Dialog_Partition_Resize_Move class
*selected_partition_ptr was referenced, accessing the freed memory.
Crash soon followed.
Fix by using a pointer instead of a reference, which can be assigned to
point to a different object.
Bug 752587 - GParted crashing when opening Resize/Move dialog on
logical partition
Since GParted commit 52a2a9b "Reduce threading (#685740)", released in
GParted 0.15.0, application of operations occurs in the main thread
running the UI, therefore long running libparted actions such as
resizing a FAT16 or FAT32 file system hang the UI for as long as it take
to complete the operation.
https://git.gnome.org/browse/gparted/commit/?id=52a2a9b00a32996921ace055e71d0e09fb33c5fe
Though this problem exists for all libparted actions, it is particularly
noticeable when performing a large resize of fat16/fat32/hfs/hfs+ file
systems.
To address this significant cause of an unresponsive GUI, this
enhancement adds threading to the libparted ped_file_system_resize
function call.
Bug 737022 - UI hangs while running libparted operations such as
FAT16/FAT32 resizing
GParted was also searching the PATH for the availability of the udevadm
and udevsettle commands for every device with a busy partition during a
refresh and for every applied operation effecting a partition table. As
with hdparm previously this was wasteful.
Again, remember the result of searching the PATH at startup and refresh
when clicking on the [Rescan For Supported Actions] button in the File
System Support dialog.
Previously on every refresh for every device, GParted was searching the
PATH to discover if the hdparm command existed. Stracing GParted showed
that calling Glib::find_program_in_path("hdparm") made the following OS
calls:
access("/usr/lib64/qt-3.3/bin/hdparm", X_OK) = -1 ENOENT (No such file or directory)
access("/usr/local/sbin/hdparm", X_OK) = -1 ENOENT (No such file or directory)
access("/usr/local/bin/hdparm", X_OK) = -1 ENOENT (No such file or directory)
access("/sbin/hdparm", X_OK) = 0
getuid() = 0
stat("/sbin/hdparm", {st_mode=S_IFREG|0755, st_size=137, ...}) = 0
stat("/sbin/hdparm", {st_mode=S_IFREG|0755, st_size=137, ...}) = 0
The Linux VFS is very fast but repeatedly doing this is wasteful.
Remember the result of searching the PATH for the hdparm command at
startup and refresh this when the [Rescan For Supported Actions] button
is pressed in the File System Support dialog. This is the same as
GParted already does for file system specific commands and their
capabilities.
Bug 751251 - Show serial number in device information
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
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
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
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)
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
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
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
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
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.
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.
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
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