Commit Graph

943 Commits

Author SHA1 Message Date
Curtis Gedak 7fc8aa49fe Organize partition information fields into logical sections (#690542)
This is part of a series of changes to enable viewing all partition
information details on a minimum 800x600 display.

Part of Bug 690542 - Partition Information Dialog Warning not readable
2014-04-28 08:42:40 +01:00
Mike Fleetwood 5f6656f267 Initialise file system objects only once
The code used to unnecessarily destroy and re-create the file system
objects on every scan for file system support tools.

Instead only create the file system objects once and just call each
object's get_filesystem_support() method on each rescan.
2014-04-23 10:25:56 -06:00
Mike Fleetwood 131098a797 Remove set_proper_filesystem() method
Prior to commit:

    1f3b11748e
    Remove GParted_Core::p_filesystem (#683149)

set_proper_filesystems() used to set GParted_Core::p_filesystem member
variable to one of the FileSystem objects, but that was just treating it
like a local variable.  After the commit local variables named
p_filesystem were used where required and set_proper_filesystem() became
a function which did nothing other than call get_filesystem_object().

Now remove set_proper_filesystem() altogether and use
get_filesystem_object() in its place.
2014-04-23 10:25:27 -06:00
Mike Fleetwood 438685577b Remove outdated comment about ped_partition_is_busy() for DMRaid devices
Comment is outdated after GParted stopped using ped_partition_is_busy()
for busy partition detection of normal and logical partitions since
commit:

    4202992063
    Fix false busy detection of unusual case with Linux Software RAID (#712533)
2014-04-23 09:54:20 -06:00
Curtis Gedak 7b1011237c Avoid using String::ucompose to build command lines
The String::ucompose method is for easy, i18n-friendly composition of
strings with Gtkmm.  From past experience, String::ucompose should not
be used to build command lines due to differences in how locales handle
number translation.  More specifically, not all locales use number
separators (spaces, commas or periods) and the decimal separator
(period or comma) in the same way.

The problem with using String::ucompose for command lines was
originally encountered and corrected in the following commit:

Fix attempt data rescue fail to open read-only view (#673246)
e494eca1f7
2014-03-05 22:12:10 +00:00
Phillip Susi 86111fe12a Use e2image to move/copy ext[234] file systems (#721516)
Use e2image features added in e2fsprogs 1.42.9 to move/copy
an ext[234] file system more efficiently by skipping unused blocks.
Fall back to the internal copy algorithm if e2image is not found
or does not support move/copy.

Bug #721516 - Use e2image to move/copy ext[234] filesystems
2014-03-05 22:12:10 +00:00
Curtis Gedak 203a345cfb Update copyright year 2014-02-08 12:23:55 +00:00
Phillip Susi 5f9a55fdcb Remove incorrect rounding in file system resize (#723543)
Work on bug 701075 inadvertently introduced a problem where ext2/3/4,
resierfs, and ntfs file systems were rounding the file system size up
to the nearest kiB.

The problem was discovered when a user resized a partition by moving
only the start boundary to the right thereby shrinking the partition.
In the situation where the resulting partition size was not an integer
kiB value (such as might occur on a 512 byte per sector device) the
file system size was rounded up to the nearest kiB.  This resulted in
a file system size being set one sector larger than the partition
size.

This problem was introduced with the following commit:

Shrink file systems to exact size (#701075)
3461413d28

The fix chosen for this problem involved removing the rounding logic.

Bug 723543 - Shrink ext2/3/4 results in attempt to set partition
             smaller than file system
2014-02-06 10:20:05 -07:00
Mike Fleetwood 9728479771 Recognise BitLocker encrypted partitions (#723232)
Only recognises partitions containing BitLocker Disk Encryption content.
No other actions are supported.

Bug #723232 - BitLocker Disk Encryption not recognised
2014-01-31 09:55:05 -07:00
Mike Fleetwood a70bfd32fe Restore compilation order of source files
Restore the order of the source files so that they are once again
compiled in order A-Z, a-z.  Order is obtained with:

    fgrep .cc src/Makefile.am | LANG=C sort
    fgrep .h include/Makefile.am | LANG=C sort
2014-01-27 10:54:48 -07:00
Mike Fleetwood 6f9b99f138 Make the File System Support dialog resizable (#342682)
Make the dialog resizable, add a vertical scrollbar and set the minimum
(and therefore initial) height to 500 pixels.  This is so that the
dialog entirely fits on an 800x600 screen, thus allowing the rescan
button to be pressed.

100 pixel difference is to account for the size of the top and bottom
GNOME 2 panels and two sets of title bars.  Two sets of title bars
because the window manager tries to place the top of dialog title bars
in line with the bottom of the main window title bar.

Bug #342682 - too much information in 'features' dialog
2014-01-27 10:54:48 -07:00
Mike Fleetwood cb8ce9caea Indent File System Support legend narrative (#342682)
Use padding to indent the legend narrative to better show hierarchy and
association with the "Legend" category as recommended in the:

    GNOME HIG 2.2.3 / Visual Design / Window Layout
    https://developer.gnome.org/hig-book/stable/design-window.html.en

Padding the legend narrative widget also deliberately increases the
spacing to the legend icons too.

Bug #342682 - too much information in 'features' dialog
2014-01-27 10:54:48 -07:00
Mike Fleetwood 59f684d8cd Always show the File System Support dialog legend (#342682)
Make the legend always shown, ready for when the dialog is resizable.

Change the widget containing the legend from an expander to a frame
widget.  Set the frame to be borderless using a bold label as
recommended in the GNOME Human Interface Guidelines 2.2.1 / Controls /
Frames and Separators.

    https://developer.gnome.org/hig-book/2.32/controls-frames.html.en

Bug #342682 - too much information in 'features' dialog
2014-01-27 10:54:48 -07:00
Mike Fleetwood dd9e2161d4 Enhance readability of the DialogFeatures constructor
The DialogFeatures::DialogFeatures() constructor used four levels of
nested code blocks and reused the same variable names at multiple
levels.  The variable hbox was used at three of the four levels.  This
was done by commit:

    91b971691d
    Bug #634090: Change some attributes to local variables

In my opinion this made the code hard to understand.  Give every local
variable a unique and meaningful name and remove the nested code blocks.
2014-01-27 10:54:48 -07:00
Daniel Mustieles 3861b9257b Replace obsolete FSF postal address in copyright notices (#721565)
This is part of parent bug:
    Bug #721455 - Obsolete info in license text on multiple modules

and GNOME Goal:
    https://wiki.gnome.org/Initiatives/GnomeGoals/Proposals

    * verify all source files to make sure they have a license and a
      copyright, and that both are up-to-date

Bug #721565 -  License text contains obsolete FSF postal address
2014-01-26 10:53:23 +00:00
Mike Fleetwood 0e253fa234 Prevent crash when creating new partition on loop label (#721988)
Write a loop partition table to a disk and then try to create a new
partition on that disk crashes GParted.

Analysis:

1) Loop partition table, actually just the signature / label
   "GNU Parted Loopback 0", is written to the disk.
2) create_partition() calls ped_disk_app_partition() to create the
   partition which, arguably erroneously, clears the loop signature.
3) In erase_filesystem_signatures(), get_device_and_disk() fails because
   there's no longer a loop signature for libparted to recognise.  This
   leaves lp_device, lp_disk and lp_partition = NULL, but incorrectly
   overall_success = true.
4) Overall_success = true allows the signature erasure loop to run and
   evaluate lp_device->sector_size, dereferencing a NULL pointer and
   crashing GParted.

Fix erase_filesystem_signatures() to correctly handle failure from
get_device_and_disk(), broken by this commit:

    246e05559d
    Clear btrfs file system super block mirror copies too (#705426)

Bug #721988 - Crash when creating new partition on disk with loop label
2014-01-13 08:06:09 +00:00
Mike Fleetwood 7b43d52720 Display partition table types in order (#711098)
In the Create Partition Table dialog display the entries in the combobox
in order.

Previously the default of MSDOS or GPT was moved to the first item in
the combobox.  Now the partition table types remain in order with just
either MSDOS or GPT being selected as as the default as required.

The partition table types are displayed in the order supplied by
libparted, which is alphabetic except with "loop" last.

Bug #711098 - Default partition table can not handle > 2 TiB disks
2014-01-06 10:45:00 +00:00
Phillip Susi 07bd72ba80 Default to GPT on disks >= 2 TiB (#711098)
MSDOS partition table is limited to addressing 2^32 sectors, limiting
disks using 512 byte sectors to 2 TiB in size.  Fdisk reports the
following warning on disks 2 TiB and larger.

    # truncate -s 2T /var/tmp/loop-2T
    # losetup /dev/loop0 /var/tmp/loop-2T
    # fdisk /dev/loop0

    WARNING: The size of this disk is 2.2 TB (2199023255552 bytes).
    DOS partition table format can not be used on drives for volumes
    larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID
    partition table format (GPT).

(Fdisk arguably reports this warning one sector too early.  Anyway for
safety and consistency GParted will use this limit too).  Continue to
use MSDOS as the default partition table type for disks smaller than 2
TiB and use GPT as the default for disks 2 TiB and larger.  This
maximises compatibility.

Also remove the advanced expander and always show the partition table
list box.

Bug #711098 - Default partition table can not handle > 2 TiB disks
2014-01-06 10:44:59 +00:00
Mike Fleetwood a4b82a9305 Successfully read kernel versions with only 2 components
When the kernel version as stated in /proc/version did not have at least
three numbers separated by periods, the version would fail to be read.
Sample /proc/version to demonstrate problem:

    Linux version 3.10-3-686-pae ...

The Linux kernel will always have a major number and a minor number
separated by a period.  There is likely also a patch version number too
that would be preceded by a period.  This enhancement will read 2 and 3
component Linux kernel versions.
2013-12-04 18:22:34 -07:00
Mike Fleetwood b3f0a0b1be Remove multi-line comment compiler warning from PipeCapture.cc
Remove this compiler warning:
    PipeCapture.cc:56:2: warning: multi-line comment [-Wcomment]
      //      /\                                          /\        /\
      ^

added by commit:
    1b54123580
    Enhance line discipline in PipeCapture::OnReadable() (#709276)
2013-11-27 20:21:10 +00:00
Curtis Gedak d842b8cdfb Show SWRAID active/not active status in information dialog (#712533)
Bug #712533 - Partitions not detected as busy inside Software RAID on
              some distros
2013-11-27 20:21:10 +00:00
Mike Fleetwood ad63ede421 Fix detection of busy status of extended partitions (#712533)
GParted doesn't report extended partitions as busy if it contains only
busy LVM2 PV or SWRAID logical partitions.  Libparted's
ped_partition_is_busy() only detects mounted file systems and swap space
as busy, not active LVM2 PVs or SWRAID members.  This is as of libparted
3.1 and earlier.

Fix by determining the busy status of an extended partition based solely
on the busy status of the logical partitions it contains.  This makes it
unnecessary to check for mounted DMRAID logical partitions or call
ped_partition_is_busy() for extended partitions.

Bug #712533 - Partitions not detected as busy inside Software RAID on
              some distros
2013-11-27 20:21:10 +00:00
Mike Fleetwood 4202992063 Fix false busy detection of unusual case with Linux Software RAID (#712533)
In this unusual setup of having one Linux Software RAID array
partitioned and a second array not partitioned, /dev/md1p1 partition in
the first array is falsely reported as busy when the file system filling
the second array /dev/md2 is mounted.

  Partition   RAID                File System        Mount mount
  ---------   -----------------   ----------------   -----------
  /dev/sdb1   SWRAID /dev/md1
                     /dev/md1p1   ext4,Label=test1   (Unmounted)
  /dev/sdb2   SWRAID /dev/md2     ext4,Label=test2   /mnt/2

This again affects Debian 6, Debian 7 and RHEL/CentOS 6.x and is as a
result of the this bug fixed in libparted 2.4:
    http://git.savannah.gnu.org/cgit/parted.git/commit/?id=db52898c214310dab4ed84e6cb2f9ffc8c3aa502
    linux: also detect "in-use" dmraid and scsi-Nth (N>=16) partition

Fix by not using libparted's ped_partition_is_busy() to determine if a
normal or logical partition is busy.

Bug #712533 - Partitions not detected as busy inside Software RAID on
              some distros
2013-11-27 20:21:10 +00:00
Mike Fleetwood 4d7ebe0314 Fix busy detection of file systems inside Linux Software RAID (#712533)
On some distributions GParted doesn't detect when a file system is busy
and mounted when the partition is within a Linux Software RAID array.
Affected distributions include: Debian 6, Debian 7 and RHEL/CentOS 6.x.

This is because of a bug in libparted 2.3 and earlier.  It was fixed by
this change in libparted 2.4:
    http://git.savannah.gnu.org/cgit/parted.git/commit/?id=db52898c214310dab4ed84e6cb2f9ffc8c3aa502
    linux: also detect "in-use" dmraid and scsi-Nth (N>=16) partition

Ubuntu 13.10 with libparted 2.3 is not affected because it contains a
distribution specific patch to correct it.

Fix by using GParted's internal mounted partitions map, mount_info, to
determine if a partition is busy, in addition to using libparted's
ped_partition_is_busy().

Bug #712533 - Partitions not detected as busy inside Software RAID on
              some distros
2013-11-27 20:21:10 +00:00
Phillip Susi de2844d02d Add online resize support (#694622)
Many file systems are capable of growing while mounted, and a few can
even shrink.  This support must be explicitly enabled at configure time
with the --enable-online-resize flag and depends on a patched libparted.
Also requires kernel >= 3.6 for partition resizing, even if the
partition is in use (BLKPG_RESIZE_PARTITION).

Thanks to Mike Fleetwood for double check mark idea instead of a second
column to show the online grow/shrink.

Bug #694622 - Add support for online resize
2013-11-24 10:10:37 +00:00
Phillip Susi 73f2c689f7 Change default file system to ext4 (#711114)
In the Create New Partition dialog use ext4 as the default choice for
new file systems.  It has been the preferred file system of
distributions for many years.  Use ext3 and ext2 as second and third
choice defaults.  This handles RHEL/CentOS 5.x which doesn't support
ext4.

Bug #711114 - Change default fs to ext4
2013-10-31 21:16:14 +00:00
Mike Fleetwood 98cd693818 Make Partition Information dialog warnings selectable (#705596)
Allow all partition warning messages to be selectable and copied.  Merge
all the messages into a single Gtk::Label widget so that they can be
selected together.

Use a blank line between individual messages so that each message can be
distinguished. Therefore each message should be formatted as one or more
non-blank lines, with an optional trailing new line.  This is true of
GParted internal messages and probably all external messages and errors
from libparted and executed commands too.

Bug #705596 - Partition Information Dialog - let user copy warnings
2013-10-22 10:12:16 -06:00
Mike Fleetwood d2e1130ad2 Detect busy status of Linux Software RAID members (#709640)
Read the contents of /proc/mdstat file to determine if a device is a
member of of an active RAID array.

    $ cat /proc/mdstat
    Personalities : [raid1]
    md1 : active raid1 sda1[2] sdb1[3]
          524224 blocks super 1.0 [2/2] [UU]

    md2 : active raid1 sdb2[2] sda2[3](F)
          5238720 blocks super 1.1 [2/1] [U_]

    md3 : active raid1 sdb3[1]
          10477440 blocks super 1.1 [2/1] [_U]
          bitmap: 1/1 pages [4KB], 65536KB chunk

    md4 : inactive sda4[0](S)
          1048564 blocks super 1.2

    unused devices: <none>

There are 5 example Linux Software RAID arrays, md1 to md5.  All are
RAID1 mirrors with 2 members, in various states.

    Array  Members     Status
    md1    sda1, sdb2  Fully operational.
    md2    sda2, sdb2  Member sda2 marked as faulty.  (Device sda2 is
                       still in use).
    md3    sda3, sdb3  Member sda3 has been removed.  (Device sda3 is
                       not in use).
    md4    sda4, sdb4  Incremental start of member sda4 only.  (Neither
                       member devices is in use).
    md5    sda5, sdb5  Array stopped.  (Neither member device is in
                       use).

Also disable "Unmount" in the partition menu for active RAID array
members.

Bug #709640 - Linux Swap Suspend and Software RAID partitions not
              recognised
2013-10-19 10:21:03 -06:00
Mike Fleetwood fac3f5b865 Recognise Linux Swap Suspend and Software RAID partitions (#709640)
Recognise in kernel, Linux Swap Suspend partitions.  (When hibernated
the kernel write the RAM out to swap space and changes the magic string
from swap space to suspend).  Recognition required either
libparted >= 1.8.8.1 or blkid from util-linux >= 2.15 or before that
blkid from e2fsprogs >= 1.39.

Recognise Linux Software RAID partitions.  Recognition requires blkid
from util-linux >= 2.15.

Example:

    # blkid /dev/sda10 /dev/sda11
    /dev/sda10: ... TYPE="swsuspend"
    /dev/sda11: ... TYPE="linux_raid_member"

    # parted /dev/sda print
    Model: ATA SAMSUNG HM500JI (scsi)
    Disk /dev/sda: 500GB
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos

    Number  Start   End     Size    Type      File system     Flags
    ...
    10      361GB   362GB   1074MB  logical   swsusp
    11      362GB   363GB   1074MB  logical                   raid

Bug #709640 - Linux Swap Suspend and Software RAID partitions not
              recognised
2013-10-19 10:05:54 -06:00
Mike Fleetwood be2689ad25 Stop using deprecated widget alignment enumerators (#652044)
Step 3 of 3:

Now that all label widgets are created with ALIGN_LEFT and ALIGN_CENTER
alignment remove the x_align and y_align parameters from mk_label() and
always use this alignment.  Also specify this alignment via floats
rather than enumerators, one of which was deprecated.

Bug #652044 - uses deprecated APIs
2013-10-18 10:17:22 -06:00
Mike Fleetwood 18e2eb8618 Replace widget alignment ALIGN_RIGHT with ALIGN_LEFT (#652044)
Step 2 of 3:

ALIGN_RIGHT was only used for the size figures in the GParted > Devices
device selector with radio buttons.  Change to ALIGN_LEFT and adjust the
widget packing to maintain appearance.

Bug #652044 - uses deprecated APIs
2013-10-18 10:17:22 -06:00
Mike Fleetwood 8b57278f67 Replace widget alignment ALIGN_TOP with ALIGN_CENTER (#652044)
Gtkmm release 2.24 in February 2011 deprecated the use of these
alignment enumerators superseding them with:

    Deprecated enumerator    Use instead
    Gtk::ALIGN_LEFT          Gtk::ALIGN_START
    Gtk::ALIGN_RIGHT         Gtk::ALIGN_END
    Gtk::ALIGN_TOP           Gtk::ALIGN_START
    Gtk::ALIGN_BOTTOM        Gtk::ALIGN_END

    gtkmm: gtkmm Enums and Flags [2.24]
    https://developer.gnome.org/gtkmm/2.24/group__gtkmmEnums.html

The deprecated alignment enumerators were only used in the creation of
Gtk::Label widgets by method Utils::mk_label().  In all but three cases
the alignment was left, center.  So make all labels with alignment left,
center and then stop using the deprecated enumerators.

Step 1 of 3:

ALIGN_TOP was only used for these 2 labels:

    "Path:" text in View > Device Information;
    "Path:" text in Partition > Information.

Use of ALIGN_TOP makes no difference to these labels so just change to
ALIGN_CENTER.

Bug #652044 - uses deprecated APIs
2013-10-18 10:17:22 -06:00
Mike Fleetwood 7f5ac07c3a Stop using deprecated method free_colors() (#652044)
Gtkmm releases 2.7.1 in July 2005 and 2.8 in September 2005 deprecated
Gdk::Colormap::free_colors() and replaced it with
Gdk::Colormap::free_color().  The oldest distribution currently
supported is RHEL / CentOS 5.9 with gtkmm 2.10 so just unconditionally
replace.

    ANNOUNCE: gtkmm 2.7.1
    https://mail.gnome.org/archives/gnome-announce-list/2005-July/msg00025.html

    ANNOUNCE: gtkmm and glibmm 2.8
    https://mail.gnome.org/archives/gnome-announce-list/2005-September/msg00026.html

Bug #652044 - uses deprecated APIs
2013-10-15 10:09:15 -06:00
Mike Fleetwood 21e166c949 Turn on resize2fs text progress bar (#709276)
Turn on the text progress bar for the resize2fs command.  Looks like:

    # resize2fs -p /dev/sda13 262144
    resize2fs 1.41.12 (17-May-2010)
    Resizing the filesystem on /dev/sda13 to 262144 (4k) blocks.
    Begin pass 2 (max = 97177)
    Relocating blocks             XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    Begin pass 3 (max = 80)
    Scanning inode table          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    Begin pass 4 (max = 5597)
    Updating inode references     XXXXXXXXX-------------------------------

Bug #709276 - Percentage indicator for subcommand
2013-10-03 10:23:46 -06:00
Mike Fleetwood 1b54123580 Enhance line discipline in PipeCapture::OnReadable() (#709276)
Add concept of cursor position within the current line, separate from
the end of the buffer.  This is so that programs which output a text
progress bar using backspace, such as resize2fs -p, are displayed
correctly.

Bug #709276 - Percentage indicator for subcommand
2013-10-03 10:23:46 -06:00
Mike Fleetwood 21aa90b847 Allow GParted to read the UUID from older btrfs-show command
All the code was there in btrfs::read_uuid() to read the UUID from the
btrfs-show command.  It just needed enabling.

This is only relevant when: (1) the blkid command is unavailable as
GParted primarily reads the UUID through the FS_Info cache using the
blkid command, and (2) the btrfs command is unavailable and the btrfs
module uses the older btrfs-show command instead.
2013-09-24 09:49:10 -06:00
Mike Fleetwood 293c8929a7 Actually display error message from statvfs() failure
Pass error_message parameter by reference to
get_mounted_filesystem_usage() so that the caller can access the
modified error message when required.
2013-09-24 09:49:10 -06:00
Mike Fleetwood 387b391d6d Add reporting of linux-swap usage (#708107)
For active swap space read the usage from /proc/swaps.  (Linux kernel
uses units of 1 KiB).  By definition inactive swap space is 100% free.

    $ cat /proc/swaps
    Filename                                Type            Size    Used    Priority
    /dev/sda2                               partition       5242876 430552  -1

Always set fs.read = FS::EXTERNAL even if /proc/swaps doesn't exist so
that an attempt is made to open the file generating a specific error, in
addition to the generic error.

    open("/proc/swaps", O_RDONLY): No such file or directory

    Unable to read the contents of this file system!
    Because of this some operations may be unavailable.

    The cause might be a missing software package.
    The following list of software packages is required for linux-
    swap file system support: util-linux.

Closes Bug #708107 - Usage of swap space is not reported
2013-09-24 09:49:10 -06:00
Mike Fleetwood 59a22673da Enable %age complete display from e2fsck command (#697662)
Enable the text progress bar and percentage complete from the e2fsck
command.  Looks like:

    # e2fsck -f -y -v -C 0 /dev/sda8
    e2fsck 1.41.12 (17-May-2010)
    Pass 1: Checking inodes, blocks, and sizes
    Pass 2: Checking directory structure
    test8: |=========================================               / 73.6%

Note that e2fsck deliberately brackets the progress bar with control-A
and control-B characters when it detects that it is not being run from a
terminal so that logsave(8) can exclude the progress bar from being
written to a log file.  As GParted doesn't run e2fsck via a pty it
receives these control characters.  Ignore them.

References:
Change e2fsck to bracket its progress bar output with ctrl-A and ctrl-B
http://git.kernel.org/cgit/fs/ext2/e2fsprogs.git/commit/?id=bc34d6be65cb93a65451ad209cfea2f98b03fd22

Don't print ^A and ^B chars when e2fsck is talking directly to a tty
http://git.kernel.org/cgit/fs/ext2/e2fsprogs.git/commit/?id=54a31a3b2e432c124aa03442f2983c4f4d4a974c

Closes Bug #697662 - Do not hide the progress of the tools used
2013-09-09 09:23:58 -06:00
Mike Fleetwood a8b699d896 Allow ntfsresize command to report real-time %age progress (#697662)
Remove the -P, no progress bar option, from the ntfsresize command.
This allows the command to display the %age complete on its output which
is displayed in the operation details dialog, updated in real time.
Possible since:
    Bug #685740 - Refactor to use asynchronous command execution

Bug #697662 - Do not hide the progress of the tools used
2013-09-09 09:23:58 -06:00
Mike Fleetwood 78c558c350 Also accept btrfs tools using IEC prefix multipliers (#706914)
Currently the btrfs command outputs figures to 2 decimal places followed
by an SI multiplier, e.g. 1.00GB.

This patch to btrfs-progs has been included in the integration
repository and will likely be included in the official btrfs-progs
repository at some point.  It changes btrfs-progs to use IEC
multipliers, e.g. 1.00GiB.  In fact multipliers already aren't used for
figures less than 1024.
    [PATCH] btrfs-progs: use IEC units for size
    http://permalink.gmane.org/gmane.comp.file-systems.btrfs/26888
    https://patchwork.kernel.org/patch/2825841/

Make GParted capable of also accepting IEC prefix multipliers, just "B"
for bytes and no multiplier, as well as an optional space between the
number and multiplier.  Therefore accept values like these:
    1.00GB         1.00 GB
    1.00GiB        1.00 GiB
    1073741824B    1073741824 B
    1073741824

Closes Bug #706914 - Prepare for btrfs tools using IEC prefix
                     multipliers
2013-08-29 10:20:52 -06:00
Mike Fleetwood 246e05559d Clear btrfs file system super block mirror copies too (#705426)
With recent btrfs-progs, GParted failed to format a btrfs file system
over the top of an existing one.  Make btrfs failed with this error:

    # mkfs.btrfs /dev/sdb1
    ...
    /dev/sdb1 appears to contain an existing filesystem (btrfs).
    Use the -f option to force overwrite.

With this commit to btrfs-progs on 2013-02-19, mkfs.btrfs checks for
existing file system signatures, including all mirror copies of btrfs
super blocks, before writing to the partition.

    http://git.kernel.org/cgit/linux/kernel/git/mason/btrfs-progs.git/commit/?id=2a2d8e1962e8b6cda7b0a7584f6d2fb95d442cb6
    btrfs-progs: require mkfs -f force option to overwrite filesystem or partition table

Make GParted clear all the mirror copies of the btrfs file system super
blocks as erase_filesystem_signatures() is intended to prevent detection
of old signatures.  This also avoids having to determine if the -f
option to mkfs.btrfs is available before trying to use it.

Closes Bug #705426 - Formatting Existing BTRFS Partition as BTRFS Fails
                     Because mkfs.btrfs Is Not Run with "-f"
2013-08-26 10:16:01 -06:00
Curtis Gedak 51845b7799 Fix regression - linux-swap resize broken (#706604)
Unfortunately a regression was introduced with GParted 0.14.1 wherein
linux-swap grow and shrink operations were broken.  This regression was
a direct result of the following commit:

    Prevent file system grow when partition grow fails (#686668)
    fd96328920

The regression did not result in an error in the GUI, but rather the
linux-swap file system was not "resized" to the correct partition size.

The logic error introduced with the above commit listed has now been
fixed.

BACKGROUND INFORMATION ON LINUX-SWAP RESIZING

Currently no command line tools are available for resizing linux-swap.
However, since linux-swap does not contain data in the usual sense, we
simulate resizing linux-swap by re-creating (maximizing to fill
partition) the linux-swap file system with the same UUID and volume
label.  To work correctly, the linux-swap file system must be re-created
after the final partition resize action has occurred.

Closes Bug #706604 - Failure to properly grow or shrink linux-swap when
                     resizing
2013-08-24 16:17:08 +01:00
Mike Fleetwood 73a80db912 Ensure running GParted is named correctly under GNOME Shell (#705323)
Under GNOME Shell a running instance of GParted was getting named
"Gpartedbin".  Ultimately GNOME Shell [1] uses the WM_CLASS X Window
property [2], which GDK defaults from the executable name.

    $ xprop WM_NAME WM_CLASS
    (Click on running GParted window)
    WM_NAME(STRING) = "/dev/sda - GParted"
    WM_CLASS(STRING) = "gpartedbin", "Gpartedbin"

Set the Class name, second string of the WM_CLASS X Window property, to
"GParted".  (This prevents the use of the '--class' GTK+/GDK common
command line option [3] to override the class name, but I expect nobody
ever uses the option.  GNOME Terminal has the same limitation.  It also
has the same change setting the Class name [4]).

References:

[1] Application Based GNOME 3
    https://wiki.gnome.org/GnomeShell/ApplicationBased

[2] WM_CLASS Property, Inter-Client Communication Conventions Manual
    http://tronche.com/gui/x/icccm/sec-4.html#s-4.1.2.5

[3] Running GTK+ Applications, Common command line options
    https://developer.gnome.org/gtk3/stable/gtk-running.html

[4] Bug #685742 - Window class of terminals doesn't match the desktop
    file name
    https://bugzilla.gnome.org/show_bug.cgi?id=685742
    https://git.gnome.org/browse/gnome-terminal/commit/?id=3370c0e51159f5be476b909e94ac05e5362dd28a

Closes Bug #705323 - Shows up as 'Gpartedbin' in GNOME Shell
2013-08-13 15:17:34 -06:00
Mike Fleetwood 1ae03dee95 Recognise new dosfstools program names (#704629)
Dosfstools >= 3.0.18, released June 2013, renamed the programs thus:

    dosfslabel becomes fatlabel,
    dosfsck becomes fsck.fat,
    and mkdosfs becomes mkfs.fat.

Dosfstools creates symbolic links for the old names for backward
compatibility, but unfortunately the Debian dosfstools-3.0.22-1
(experimental) package doesn't include those symbolic links.  This
causes create, check and read unmounted FAT16/32 file systems to not be
supported.

Make GParted look for the new names first and the old names second.

Closes Bug #704629 - Program name changes in dosfstools 3.0.18+ break
                     FAT16/32 support
2013-07-27 11:32:20 -06:00
Sinlu Bes 20006e1f8e Add create_with_label flag to struct FS (#701569)
It was difficult to retrieve whether a filesystem's label can be set on reformat.

The read_label flag can't be used as it decides whether to use the logic in the filesystem class
rather than the fallback in GParted::set_device_partitions, to determine the label of a partition.

The create_with_label flag is NONE for file systems that we cannot format with a
label (or that we cannot format at all).
The value is usually EXTERNAL for file systems that we can format with a label.
2013-06-09 09:50:54 -06:00
Mike Fleetwood aed1fb58cf Remove unused read-only functionality from internal block copy
The read-only functionality is unused and the readonly parameter is
always false in copy_filesystem() and copy_blocks() methods.  This has
been the case since the copy simulation was dropped by commit:

    b9b4b2e55d
    Remove simulation pass ( read test ) on move
2013-06-05 10:57:39 -06:00
Curtis Gedak 8ed7155e6d Set NTFS minimum partition size to 2 MiB (#697848)
The minimum NTFS volume size supported by the ntfs-3g mkntfs command
is 1 MiB.  Since 1 extra sector is required for the backup NTFS boot
sector, an NTFS partition must be at least 1 MiB plus 1 sector.

To demonstrate, create a 1 MiB unformatted partition using MiB
alignment (/dev/sdd1), and then try to format the partition as NTFS.

# mkntfs -Q -v -L "ntfs-test" /dev/sdd1
Device is too small (1023kiB).  Minimum NTFS volume size is 1MiB.

For GParted this means a minimum NTFS partition size of 2 MiB since
the smallest unit in the GUI is MiB.

Bug #697848 - Failure to Create 1 MiB NTFS Partition
2013-05-30 21:33:11 +01:00
Mike Fleetwood 28d41d0d6a Place options before device name for the ntfsresize command
Place the size and noaction options before the device name when resizing
an NTFS file system to match the order documented in the manual page.
Example fixed command:

    # ntfsresize -P --force --force -s 104857600 --no-action /dev/sda11
2013-05-29 09:50:26 -06:00
Mike Fleetwood 3461413d28 Shrink file systems to exact size (#701075)
Ext[234] file systems were being shrunk 1 KiB too small.  Ntfs and
reiserfs file systems were being shrunk 1 byte too small.  The resultant
file systems were ending up 1 block smaller than they could have been.

This looks like an accidental leftover from when GParted use to:
1) Shrink the file system 1 cylinder too small
2) Shrink the partition
3) Grow the file system to fill the partition
Relevant commit:

    d663c3c277
    removed cylindersize buffering during resize from the filesystems

Closes Bug #701075 - Setting the backup boot sector when resizing NTFS
2013-05-29 09:50:26 -06:00