Commit Graph

338 Commits

Author SHA1 Message Date
Mike Fleetwood 7ebedc4bb3 Don't show intrinsic unallocated space (#499202)
Most file systems report intrinsic unallocated space using the statvfs()
system call when mounted, but not using their own tools.  They are:
ext2/3/4, fat16/32, hfs, nilfs2, reiserfs and xfs.  Showing either a
little or no unallocated space, depending on whether a file system is
mounted or not, could be confusing to the user.

When all file systems are created filling their partitions the unused
figure reported by statvfs() and their own tools are the same or very
close.  Also the used plus unallocated figure from statvfs() agrees with
the used figure from their own tools.

For all file systems don't display intrinsic unallocated space (that
below the threshold of 2 to 5%), instead include it as used space.  As
soon as the amount of unallocated space becomes significant display it
everywhere and also trigger the warning.

For display purposes always use the new Partition methods:
get_sectors_used(), get_sectors_unused(), and get_sectors_unallocated().
When calculating new usage figures during Paste and Resize/Move
operations directly access sectors_used, sectors_unused and
sectors_unallocated members.

Bug #499202 - gparted does not see the difference if partition size
              differs from filesystem size
2012-06-18 12:41:59 -06:00
Mike Fleetwood 30385cbd37 Query unallocated space via libparted (#499202)
Update the implementation using libparted to set the file system size
and free space, thus allowing the unallocated space in the partition to
be calculated, for the following unmounted file systems:
    hfs, hfs+
(Requires libparted <= 2.4 or libparted >= 3.1, as the needed
functionality did not exist in libparted 3.0).

Bug #499202 - gparted does not see the difference if partition size
              differs from filesystem size
2012-06-18 10:24:28 -06:00
Mike Fleetwood 8093ba2ebd Record unallocated space within a partition (#499202)
Currently GParted assumes that a file system fills its containing
partition.  This is not always true and can occur when resizing is
performed outside of GParted or a resize operation fails.  GParted
doesn't display any information about unallocated space to the user
and in most cases it is simply included in used space.

Add partition unallocated space accounting.  Make GParted record the
unallocated space for mounted file system and display a warning in the
Partition Information dialog when too much unallocated space is found.

Partition::set_sector_usage( fs_size, fs_unused ), is the new preferred
method of recording file system usage because it allows the unallocated
space in a partition to be calculated.  Partition::Set_Unused() and
Partition::set_used() are now deprecated.

NOTES:

1)  Set the minimum unallocated space to be 5% before considering it
    significant to avoid false reporting.  Worst case found was a
    mounted xfs file system in a 100MiB partition, which reports as
    ~4.7% unallocated according to file system size from statvfs().
    However, it reports as having no unallocated space using xfs
    specific tools.

2)  Unallocated space is only a graphical representation for the user.
    GParted must still use relevant tools to resize file systems before
    shrinking the data and can't assume all unallocated space exists
    after the file system at the end of the partition.

Bug #499202 - gparted does not see the difference if partition size
              differs from filesystem size
2012-06-18 10:24:28 -06:00
Curtis Gedak c56d0df8ae Ensure Align to MiB does not overlap following partition (#661744)
Normally the GUI should restrict partitions from overlapping other
partitions.  However we have received a report where an overlap has
occurred.

Unfortunately we did not have enough details to recreate the problem.
Based on the report my thoughts are that somehow the problem arose
due to partitions aligned to boundaries other than MiB in combination
with the size of a partition being rounded up in the GUI resizer.

In an effort to prevent this problem in the future I have added a
check for primary or extended partitions overlapping other primary or
extended partitions.

Closes Bug #661744 - libparted "Can't have overlapping partitions."
                     after successful move+resize?!
2012-03-27 14:28:33 -06:00
Curtis Gedak 1c47c17a47 Rework align to MiB adjustments to end sector of partition
Ensure at least 2 sectors for Extended Boot Record (EBR) between end
of logical partition and start of next logical partition.

Ensure at least 34 sectors reserved for backup GUID Partition Table
(GPT) after the end of the last partition.
2012-03-27 14:28:33 -06:00
Curtis Gedak 1f1ea3f12e Use cached method first to read UUID to shorten scan time 2012-03-25 10:10:47 -06:00
Curtis Gedak bee2a643e2 Ensure space for EBR when resizing Extended partition (#664050)
When resizing an extended boot record we must ensure that at least 2
sectors is reserved in front of the nearest logical partition for the
Extended Boot Record.

Please note that unless specifically told otherwise, the Linux kernel
considers Extended Boot Records to be two sectors long, in order to
"leave room for LILO".

Closes Bug #664050 - Unable to resize extended partition
2012-03-17 19:20:45 -06:00
Curtis Gedak 57ee0a1638 Add requested partition details to log when resize/move fails 2012-03-17 19:20:45 -06:00
Curtis Gedak 0fda1d011d Enable new fs resize library available with parted-3.1 (#668281)
The parted-3.1 release brings back FAT16/FAT32 and HFS/HFS+ file
system resize capabilities in a new libparted fs resize library.

The following operations are again available when GParted is linked
with parted-3.1:

   FAT16 - grow and shrink
   FAT32 - grow and shrink
   HFS   - shrink
   HFS+  - shrink

Note that there is a difference in how move actions are handled for
FAT16/FAT32 file systems based on parted version.

When GParted is linked with parted >= 3.0:

   FAT16 - move performed internally by GParted
   FAT32 - move performed internally by GParted

When GParted is linked with parted < 3.0:

   FAT16 - move performed by libparted
   FAT32 - move performed by libparted

Thanks goes to Jim Meyering for restoring these file system resizing
capabilities in Parted 3.1 with a new libparted fs resize library.

Closes Bug #668281 - minimal file-system resize API? (FAT and HFS*
                     only)
2012-03-03 11:55:20 -07:00
Rogier Goossens 387feb143a Fix for implicit assumption that 'FS_UNKNOWN' is last in FILESYSTEMS list
This assumption was invalidated by commit
ce9feeda0e9a04da04cec0a1b01512ed68c2495c:
'Make FileSystem objects in GParted_Core accessible and usable by others'

This patch removes the dependency on this implicit assumption.
2012-02-18 10:32:13 -07:00
Curtis Gedak 93241cccbf Fix regression when shrinking, moving and copying swap (#670017)
Since linux-swap does not contain data and does not have a resize
command, linux-swap is recreated instead of moved, copied, or resized.

GParted 0.11.0 contained the following enhancement:
Bug #663980 - Avoid redundant file system maximize actions

An unfortunate side effect of this change was that the required
maximize action to recreate linux-swap would not occur when the new
size for the partition was less than or equal to the original size.

The changes associated with this commit address this regression.

Closes Bug #670017 - Corrupting swap partitions
2012-02-14 11:31:15 -07:00
Rogier Goossens 4108daf15f Implement changing UUID for NTFS (#667278)
Part 4 of 4 to provide new UUID support for NTFS.

Closes Bug #667278 - Add support for setting UUID
2012-02-10 10:33:13 -07:00
Rogier Goossens ce9feeda0e Make FileSystem objects in GParted_Core accessible and usable by others
Part 1 of 4 to provide new UUID support for NTFS.

See Bug #667278 - Add support for setting UUID
2012-02-10 10:33:12 -07:00
Rogier Goossens 50befd62a3 Check LVM cache only for LVM physical volumes
Determine the FS type before checking whether a FS is busy,
and check LVM only for LVM PVs.

Remove the LVM busy check for extended partitions, as they
don't contain LVM PVs - or any other FS for that matter.
(and even if they did, the rest of the code silently assumes
they don't...)
2012-02-08 15:46:36 -07:00
Mike Fleetwood 72ac712024 Show LVM2 PVs as supported, read-only (#160787)
Add LVM2 PV into the File System Support dialog list and remove the
warning message reporting LVM as not being supported.

Bug #160787 - lvm support
2012-02-02 10:24:31 -07:00
Mike Fleetwood aa085a3caa Display busy status of LVM2 PVs (#160787)
A Volume Group is active when any of its Logical Volume mappings are
loaded (and enabled) in the Kernel's device-mapper driver.  Therefore
all the Physical Volumes in the VG (must be considered) active too.
This is exactly equivalent to a mounted file system, as the kernel is
actively using the partition.  Mark active LVM2 PVs as busy in GParted.

Don't use statvfs() for determining sector usage of busy LVM2 PVs as it
will fail with "statvfs(VGNAME): No such file or directory".  Instead
always use the LVM2 PV specific method.

Display the status of the LVM2 PV in the Information dialog using one of
the following relevant messages:
    Not active (Not part of any volume group)
    VGNAME not active
    VGNAME active
(The code uses the VGNAME stored in the partition's first mount point,
as displayed in the "Mount Point" column, rather than going back to the
primary source of the information in the LVM2_PV_Info class).

Temporarily prevent GParted from offering to unmount LVM2 PVs until
activating and deactivating Volume Groups is implemented later.

Bug #160787 - lvm support
2012-02-02 10:24:31 -07:00
Mike Fleetwood 8083f11d84 Display LVM2 VGNAME as the PV's mount point (#160787)
As the Mount Point column is being borrowed to display the PV's VGNAME,
also suppress generation of the "Mount on" submenu for LVM2 PVs.

Bug #160787 - lvm support
2012-02-02 10:24:31 -07:00
Mike Fleetwood 608d992e82 Cache results from querying all LVM2 PVs (#160787)
Cache results from querying all LVM2 PVs in one go to minimise the
number of times lvm commands are executed.  Take inspiration from
caching performed by FS_Info and Proc_Partitions_Info.

Bug #160787 - lvm support
2012-02-02 10:24:28 -07:00
Mike Fleetwood abd0dd0426 Report space usage of LVM2 PVs (#160787)
Add minimal support for just reporting the space usage of LVM2 PVs.
Accept libparted / blkid detection of LVM2 PVs first, falling back on
GParted's specific detection code otherwise.  Maintain LVM not supported
warning message.

Bug #160787 - lvm support
2012-02-02 10:17:29 -07:00
Mike Fleetwood 391e5e12f9 Rename FS_LVM2 -> FS_LVM2_PV (#160787)
This is the first step of adding support for just LVM2 Phyiscal Volumes,
a subset of full LVM2 support.

Make it clear that it is only LVM2 PVs being treated like a file system.

Bug #160787 - lvm support
2012-01-31 10:26:51 -07:00
Rogier Goossens 9e96159bb2 Add support for setting UUID (#667278)
Add the ability to set a new random UUID on file systems that provide
the appropriate tools to perform this action.

Update the help manual to include this new functionality.  Also add
reference links to "setting a partition label" and "changing a
partition UUID" in the "copying and pasting a partition" section.

This patch does not include setting the UUID on an NTFS file system.

Bug #667278 - Add support for setting UUID

Bug #608308 - fix documentation - Copying and Pasting a Partition
2012-01-23 12:32:27 -07:00
Phillip Susi a1f843e74a Display pop up dialog on libparted exceptions
We used to just log libparted exceptions without handling them.  This patch
changes the exception handler to display a modal dialog box and return the
chosen action to libparted.
2012-01-08 13:03:20 -07:00
Mike Fleetwood df20b54d00 Add nilfs2 support (#642842)
Requires libparted 2.4 or higher, or blkid from utils-linux 2.20 or
higher for nilfs2 file system detection.

Requires nilfs-utils for nilfs2 file system support.

Closes Bug #642842 - nilfs is not detected
2011-12-16 11:40:46 -07:00
Curtis Gedak e8bdb5d704 Avoid redundant file system maximize actions (#663980)
When GParted performed operations or combinations of operations,
such as:
  a)  copy to same or smaller size destination partition
  b)  move to same or smaller size due to alignment change
  c)  resize to smaller size
a redundant maximize file system operation would occur.

Normally these redundant maximize operations to grow the file
system to take up all the space in the partition were not harmful.

However in situations where libparted failed to inform the kernel
of partition changes, then the extra maximize operation would
grow the file system to be the original partition size.  In cases
where the original partition was larger than the new partition
size, this caused problems because the file system would be
larger than the partition on reboot.

This enhancement avoids redundant file system maximize actions on
copy, move, and resize, and should help reduce problems described
in the following links:

WARNING! Problem Resizing File Systems with GParted
http://gparted-forum.surf4.info/viewtopic.php?id=13777

Bug #601574 - ERROR: Current NTFS volume size is bigger than the
              device size!

Bug #604298 - Problems resizing file systems with
              gparted-live-0.5.0-3

Closes Bug #663980 - Avoid redundant file system maximize actions
                     on copy, move, and resize
2011-11-13 11:24:07 -07:00
Curtis Gedak 38aab666b4 Enable copy to smaller XFS partition (#663806)
Closes Bug #663806 - Cannot copy XFS filesystem to new smaller
                     partition anymore
2011-11-11 11:52:49 -07:00
Curtis Gedak 370c084947 Improve code comments for reading volume labels 2011-11-01 13:13:28 -06:00
Curtis Gedak cf8293cf78 Display ext2/3/4 unicode volume labels properly (#662537)
Note that this enhancement changes GParted to first try the native
tools to determine the volume label for all file systems.  If the
volume label is not found then the fall back method is to use blkid.

There is a small degradation in device refresh times as a result of
this change.

Closes Bug #662537 - Ext4 unicode labels not shown correctly
2011-11-01 13:01:02 -06:00
Curtis Gedak 284cfa7ed9 Add missing exfat file system to set_proper_filesystem method
This should have been part of commit
7cbc125a2e
2011-10-22 14:40:08 -06:00
Curtis Gedak 7cbc125a2e Add detection of exfat file systems (#639760)
Note that util-linux v2.18 or higher is required to detect exfat file
systems.

Part of Bug #639760 - exfat / fat64 support
2011-10-22 11:54:54 -06:00
Curtis Gedak 8a58b5b53e Enable compile and link with libparted 3.0 (#651559)
The release of (lib)parted 3.0 includes a change to the Application
Programing Interface - API.  Most importantly, libparted 3.0 removes
many file system specific function calls, and hence the capabilities
provided by these functions.  In order for GParted to compile and link
with libparted 3.0, this libparted functionality is lost.

Specifically, the functionality that is lost when GParted is compiled
and linked with libparted 3.0 is as follows:

  - Loss of ability to grow and shrink FAT16 and FAT32 file systems
  - Loss of ability to shrink HFS and HFS+ file systems
  - Loss of ability to determine used and unused sectors in HFS and
      HFS+ file systems
  - Loss of ability to erase file system signatures on partition
      create and format

It is hoped that other free software projects will include some or all
of the above lost functionality, which can then be added back to
GParted.

This commit includes a change in how FAT16 and FAT32 file systems are
moved.  Specifically the move is now performed internally by GParted
when linked with libparted 3.0.  The move functionality is provided by
libparted for prior libparted versions (e.g. less than 3.0).

This is the final enhancement in a series of commits that enable
GParted to compile with libparted version 3.0.

Closes Bug #651559 - Doesn't compile against parted 3.0
2011-06-09 09:59:41 -06:00
Curtis Gedak 53b2b50f4a Fix size off by one sector with unrecognized disk label (#649444)
On disks with an unrecognized disk label, the end sector value
was saved as one sector larger than actual.  This caused the
Partition Information dialog to report the end sector value and
the total number of sectors on the disk as one larger than the
actual value.

Closes Bug #649444 - Partition information reports wrong sector
                     count
2011-05-31 09:45:18 -06:00
Curtis Gedak 2f99511228 Add flag --enable-libparted-dmraid to use native libparted dmraid
The new configure option --enable-libparted-dmraid enables the native
use of /dev/mapper dmraid support in the libparted library.

If this option is not specified, or is disabled, then gparted code
will be used to support dmraid.  The gparted code uses the old dmraid
partition naming scheme of always appending the partition number to
the device name.  The letter 'p' is not inserted between the device
name and the partition number.  The gparted code is particularly
useful when used with older versions of libparted that do not support
/dev/mapper dmraid.

Ubuntu launchpad bug 719129 - [Natty] Gparted duplicates dmraid
                              partition devices
https://bugs.launchpad.net/ubuntu/+source/gparted/+bug/719129
2011-02-22 13:22:49 -07:00
Joan Lledó ef37bdb7de Added support to lost data recovery using gpart 2011-01-29 14:58:02 -07:00
Curtis Gedak c299bbe9e2 Add possible cause for failure to read file system 2011-01-16 11:39:02 -07:00
Curtis Gedak 09848775f4 Add another reason to list when unable to detect file system 2011-01-16 11:15:35 -07:00
Curtis Gedak 340d506c04 Update copyright year 2011-01-16 10:45:25 -07:00
Curtis Gedak dd1db44639 Fix minor cylinder alignment rounding error (size < 1 cylinder)
Previously when creating a new partition on a device with 512
byte sectors with 7 MiB chosen and cylinder alignment, the
snap_to_cylinder logic would round up to 2 cylinders (~15.69
MiB), instead of the correct 1 cylinder (~7.84 MiB).
2011-01-15 14:46:18 -07:00
Curtis Gedak b176a96e28 Enhance to work with mount points defined by uuid or label 2010-12-09 14:58:03 -07:00
Curtis Gedak 3973b6961d Handle characters like spaces in mount points (#629592)
Use mntent C library to read mount point files such as
/etc/fstab, /etc/mtab, and /proc/mounts.

Closes bug #629592 - Unable to find Mount Point if it contains a
                     Space Character
2010-12-09 13:59:33 -07:00
Curtis Gedak 3be3a39a68 Move dmraid device logic outside of for loop
Since this logic did not depend on the for loop variable, it does
not make sense to have this within the for loop.
2010-12-08 16:03:21 -07:00
Curtis Gedak fd77e73c46 Refactor device parsing logic into Proc_Partitions_Info class
The reason for refactoring is to simplify the large GParted_Core
class, to help minimize disk reads, and to group the logic for
processing the file /proc/partitions into a single logical class.
2010-12-07 16:01:54 -07:00
Curtis Gedak 319255d3bc Refactor alternate_paths logic into new Proc_Partitions_Info class
This reason for refactoring is to simplify the large GParted_Core
class, to help minimize disk reads, and to group the logic for
processing the file /proc/partitions into a single logical class.
2010-12-07 11:49:50 -07:00
Curtis Gedak 3c35a7ff42 Fix incorrect dmraid partition path name (#634553)
Enhance code so that all calls to the ped_partition_get_path
function in the libparted library go through one
GParted_Core::get_partition_path method.

This one method makes the appropriate adjustments to the dmraid
partition path name as required.

Closes bug #634553 - ntfsresize fails on RAID array
2010-11-11 10:37:04 -07:00
Curtis Gedak 232800d6cd Skip move action because linux-swap contains no data (#589555)
Closes bug #589555 - Moving a swap partition needlessly copies
                     all "data" on it
2010-10-19 13:43:42 -06:00
Curtis Gedak b0e36132b0 Make btrfs support a normal part of gparted
Remove need to configure with the --enable-btrfs option in order
to include btrfs support in gparted.
2010-10-18 15:28:40 -06:00
Curtis Gedak 7dd6381c43 Add more translator comments requested in bug #631684 2010-10-15 14:50:58 -06:00
Curtis Gedak 08c78ba19d Add translator comments requested in bug #631684 2010-10-12 18:14:30 -06:00
Markus Elfring 1e2562adda Bug #539092: Deletion of unnecessary null pointer checks
A few null pointer checks were deleted because they were not needed any more.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
2010-10-06 12:24:51 -06:00
Seth Heeren ddf225728f erase_filesystem_signatures writes uninitialized data
tagged FIXME
2010-10-05 12:54:55 -06:00
Seth Heeren 71a811cfae leaked FS structures for unsupported partition types
FILESYSTEMS vector copies anyway
2010-10-05 12:54:55 -06:00