Previously the function erase_filesystem_signatures() was used to clear
file system signatures when a new partition was created and when an
existing partition was formatted with a file system. However this was
only available with libparted <= 2.4 and then only for the file systems
which libparted supports.
Having multiple different file system signatures on a partition leads to
misidentification of file system. For example creating a nilfs2 over
the top of a fat32 file system is detected as a fat32, not nilfs2. This
shows that old file system signatures must be cleared before a new file
system is created.
Fix by always using "wipefs -a /dev/PARTITION" command to clear all old
file system signatures rather than libparted API calls. Failure from
wipefs is only considered a warning so doesn't fail the file system
creation. (This doesn't yet fully meet the "MUST be cleared"
requirement above. Will be fully met later in this patchset). Output
from the wipefs command is displayed as a new sub-step which looks like
this:
v Format /dev/sda7 as xfs 00:00:05
> calibrate /dev/sda14 00:00:01
v clear old file system signatures in /dev/sda7 00:00:01 [NEW]
> wipefs -a /dev/sda7 [NEW]
> set partition type on /dev/sda7 00:00:02
v create new xfs file system 00:00:01
> mkfs.xfs -f -L "" /dev/sda7
Also signatures are only cleared immediately before a new file system is
written and not when an unformatted partition is created. This allows
recovery from accidental partition deletion by re-creating the deleted
partition as unformatted.
Bug #688882 - Improve clearing of file system signatures
Interested operations can now connect a signal to their OperationDetail
to be notified of a cancelation request. The internal copy/move code
will now cleanly stop on cancelation, allowing the partition to be
rolled back to its previous state. This makes canceling a move
perfectly safe.
After clicking cancel, the button changes to "Force Cancel" and is
disabled for 5 seconds. Operations that are safe to cancel will do so
and those that are not will continue to run. Clicking force cancel
asks operations to cancel, even if doing so is unsafe. For the
internal copy/move algorithm, canceling is always safe because an
error results in a rollback operation. Canceling the rollback is
unsafe. For external commands, filesystem modules may indicate
that the command is safe to cancel or not. Canceled commands will
be terminated with SIGINT.
As a result of the new safe cancel vs force cancel distinction, the
scary warning about cancl causing corruption has been moved to
after clicking the force cancel button.
Part of Bug #601239 - Please allow 'Cancel after current operation'
Have the copy code create a background thread to do the actual copying so
that it won't block the main loop.
Part of Bug 685740 - Refactor to use asynchronous command execution
Win_Gparted and Dialog_Progress were creating threads to perform most
functions in the background. Most of the time, the only reason the
threads blocked was to execute an external command. The external command
execution has been changed to spawn the command asynchronously and wait
for completion with a nested main loop. While waiting for completion,
the pipe output is captured via events. In the future, this will allow
for it to be parsed in real time to obtain progress information.
Those tasks in GParted_Core that still block now spawn a background thread
and wait for it to complete with a nested main loop to avoid hanging the
gui.
Part of Bug #685740 - Refactor to use asynchronous command execution
They were used like global variables. Now they are moved to the
functions that actually use them to make clearer how the data flow is.
Bug #683149 - Cleanup(?): Remove lp_device and lp_disk from GParted_Core
Each file system class can now choose how the size and free space of the
file system is determined when it is mounted.
.fs.online_read = FS::NONE (default)
Do nothing. Don't get the file system size and free space.
.fs.online_read = FS::GPARTED
Use internal GParted method which calls statvfs() system call on
the mounted file system.
.fs.online_read = FS::EXTERNAL
Call the file system's member function set_used_sectors(). This
is the same function as called when the file system is not
mounted. It can determine if the file system is mounted or not
by testing partition.busy and acting accordingly.
This means that determining the size and free space of active LVM2
Physical Volumes is no longer a special case. Instead the lvm2_pv class
just elects to have its set_used_sectors() method called for both the
active and deactive cases.
Bug #683255 - ext2: statvfs differs from dumpe2fs (x MB unallocated
space within the partition)
When an inactive LVM2 Volume Group is exported it makes it unknown to
the local system, ready for moving the member Physical Volumes to
another system, where the VG can be imported and used. In this state a
PV can't be resized.
# lvm pvresize /dev/sda10
Volume group Test-VG1 is exported
Unable to read volume group "Test-VG1".
0 physical volume(s) resized / 1 physical volume(s) not resized
# echo $?
5
Fix this by preventing resizing of such a PV. This has been coded in a
generic way using new function filesystem_resize_disallowed() to
determine whether a file system is allowed to be resized or not. For
a file system which can be resized, but is currently not allowed to be
resized, the behaviour is as follows:
1) Pasting into unallocated space is limited to creating a new
partition which is the same size as the copied partition.
2) Resizing the partition is disallowed, only moving the partition is
allowed.
3) Pasting into an existing partition will only copy the file system.
If the destination partition is larger a warning will report that
growing the file system is not currently allowed.
4) Checking a partition will also report a warning that growing the
file system is not currently allowed.
This is exactly the same behaviour as for a file system which does not
implement resizing, except for a different warning message.
Bug #670171 - Add LVM PV read-write support
This commit only adds a remove() method to every file system and an
optional call to it in the relevant operations. All remove() methods
are no operations and not enabled.
The remove() method provides explicit controlled removal of a file
system before the partition is deleted or overwritten by being formatted
or pasted into. When implemented, it appears as an extra step in the
relevant operation. The file system specific remove() method is
explicitly allowed to fail and stop the operations currently being
applied.
This is different to the existing erase_filesystem_signatures() which
wipes any previous file system signatures immediately before a new file
system is written to ensure there is no possibility of the partition
containing two or more different file system signatures. It never fails
or reports anything to the user.
NOTE:
Most file systems should NOT implement a remove() method as it will
prevent recovery from accidental partition deletion.
Bug #670171 - Add LVM PV read-write support
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)
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
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.
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
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.
Make align to MiB the default setting instead of align to cylinder.
Migrate logic for alignment to cylinder into its own method
snap_to_cylinder, and place common logic in snap_to_alignment.
Add alignment checks for situations where space is needed for Master
Boot Record or Extended Boot Record.
Adjust ranges on spin buttons according to required boot record space.
Copy fix for off by one sector (#596552) from
Dialog_Partition_New::Get_New_Partition to
Dialog_Base_Partition::Get_New_Partition
Enhance resize / move logic for checking locations of nearby logical
partitions to not depend on the partition ordering.
Note: This commit does not include limiting graphic movement according
to required boot record space.
Restore copyright entries by original author to those of his last
known repository commit titled "released gparted-0.3.4 on
LarryT's request." on Feb 25, 2007.
Add my own copyright entries for files in which I changed source
code. Files in which I only made spelling changes do not have my
copyright entry added.
* added support for reading volumelabels. Atm we only read ext2/3, but
the infrastructure for adding the other filesystems is in place.
It's simply a matter of finding the right commands and parsing the
output. (see #338528 for more info)
* src/Dialog_Progress.cc: make sure progressfraction stays between 0.0
and 1.0
* include/GParted_Core.h,
src/GParted_Core.cc: implemented rollback in case of failed move of
overlapping filesystems. Together with the readonly test moving
should be quite save now :)
* include/GParted_Core.h,
src/GParted_Core.cc: declared char * buf global, so it can be
initialized in copy_blocks(). This is a lot more efficient than
initializing it on every copy_block()
* include/Partition.h,
src/Partition.cc: added test_overlap()
* include/GParted_Core.h,
src/GParted_Core.cc: perform a readonly testrun before the actual
move if destination overlaps source.
* include/GParted_Core.h,
src/GParted_Core.cc: update ntfsbootsector after first sector has
changed. This is necessary to let windows boot correctly afterwards.
* src/ntfs.cc: added FIXME
* include/GParted_Core.h,
src/GParted_Core.cc: tried to fix a couple of errors with moving to
the right with overlap (thanks Larry for hunting ;) )
Although everything seems to work well i'm still not sure if
everything is 100% ok.
I guess everything could use some more testing, which is exactly
what i plan to do this weekend :)
* happy 24th birthday Johannes! :^)
* include/GParted_Core.h,
src/GParted_Core.cc: restructured resize_move() to be more robust.
This will hopefully tackle a couple of issues which came up during
the public testing.
* include/GParted_Core.h,
src/GParted_Core.cc: fixed some issues with combi move+shrink on
fat* and hfs* filesystems.
Also call wait_for_node() from commit() if 'node' was provided.
* include/GParted_Core.h,
src/GParted_Core.cc: created set_progress_info() (i actually planned
on adding some time remaining stuff, but xfiles is waiting ;) )
* include/GParted_Core.h,
src/GParted_Core.cc: did some work on disabling of automounting of
removable drives. The current method is not entirely to my liking
but it seems to work.
* implemented some stuff to find a good blocksize to use for
copy/move. Actually i'm not really happy with it, because probing
seems suboptimal, but it's better than nothing. As soon as i have
some time i should do some research on the subject to find a better
solution.
* include/FileSystem.h,
include/GParted_Core.h,
src/FileSystem.cc,
src/GParted_Core.cc,
src/ext2.cc,
src/ext3.cc,
src/ntfs.cc,
src/reiserfs.cc: removed cylindersize buffering during resize from
the filesystems. It is not needed anymore now we calculate the new
position before calling this.
Also added some extra progressfeedback in the core
* src/Win_GParted.cc: added FIXME:
* include/GParted_Core.h,
src/GParted_Core.cc,
src/fat32.cc: decoupled libparted partition and filesystemresizing.
This resulted in a much more consistent core. This also affected
several other aspects of resizing/moving in a positive way.
* include/GParted_Core.h,
src/GParted_Core.cc,
src/Win_GParted.cc: perform some checks before adding a new
operation to the list.
* src/Partition.cc: made get_length() a bit safer
* src/Win_GParted.cc,
include/GParted_Core.h,
src/GParted_Core.cc: implemented snap to cylinder algorithm.
Although the algorithm is very simple, it seems to work perfectly.
However, some additional testing is required.
* include/GParted_Core.h,
src/GParted_Core.cc,
src/ext2.cc: added movesupport, atm in experimental state and needs
lots of cleaning. only enabled for ext2, but should work for all
filesystems.
* src/DialogFeatures.cc: added alternating rowcolours (see #342682)
* include/Dialog_Partition_Copy.h,
include/GParted_Core.h,
include/OperationCopy.h,
include/Win_GParted.h,
src/Dialog_Partition_Copy.cc,
src/GParted_Core.cc,
src/OperationCopy.cc,
src/Win_GParted.cc: made blocksize settable by the user.
* Use ped_device_read and ped_device_write instead of 'dd' to copy
filesystems.
Modified progressdetails to provide more detailed feedback about a
process.
Basicly these were all changes to the infrastructure to make the
incorporation of the 'move-code' a bit easier.
( sorry, not in the mood to list all affected files ;)
* include/GParted_Core.h,
src/GParted_Core.cc: improved disabling of automounting. It's still
somewhat crude, but right now it's ok for some semi-public testing.
I'll do some cleanups tomorrow morning.
* src/Dialog_Progress.cc: added FIXME
* include/GParted_Core.h,
src/GParted_Core.cc: an initial solution for the automount problem.
I still need to add something to prevent just created partitions from
getting mounted. (see #324220 for more info)
* changed the way devices and partitions store their devicepaths.
Instead of holding a 'realpath' and a symbolic path we store paths
in a list. This allows for improved detection of mountpoins, free
space, etc..
Also fixed a nasty bug which showed up when you copy a partition
from one device to another. (thanks to mario for the report)
* include/GParted_Core.h,
include/TreeView_Detail.h,
src/GParted_Core.cc,
src/TreeView_Detail.cc: show greyed-out mountpoint of unmounted
partitions in the treeview as an improved way to identify
partitions. (#333027)
* src/Win_GParted.cc: cleanups
* include/GParted_Core.h,
src/GParted_Core.cc: catch libparted exceptions and display them in
the operationdetails if an operation has failed.
* src/Dialog_Progress.cc: small cosmetic change to the errordialog.
* include/GParted_Core.h,
src/GParted_Core.cc,
src/Win_GParted.cc: deal with the rare situation when 2 partitions
are mounted on the same mountpoint. (see also #330327)
* include/GParted_Core.h,
include/Partition.h,
src/Dialog_Partition_Info.cc,
src/GParted_Core.cc,
src/Partition.cc,
src/TreeView_Detail.cc: store flags in a list instead of a string.
* Makefile.am,
src/Makefile.am: cleanups
* include/GParted_Core.h,
include/Partition.h,
src/Dialog_Partition_Info.cc,
src/GParted_Core.cc,
src/Partition.cc,
src/TreeView_Detail.cc,
src/Win_GParted.cc: support partitions with multiple mountpoints
(see also #330327)
* added detailed progressfeedback. It still needs some polishing, but
is already far better then the old situation. And what's more, it's
finally threadsafe :p
* include/Device.h,
src/Device.cc: replaced 'device_partitions' with 'partitions'
* src/Win_GParted.cc: use new Device::partitions
* include/Partition.h,
src/Partition.cc: added 'realpath'
* src/Dialog_Partition_Info.cc: use Partition::realpath..
* include/GParted_Core.h,
src/GParted_Core.cc:use ped_partition_get_path() instead of
constructing it ourselves. (#325800)
Also use global maps for mountpoints and shortpaths to prevent
fileaccess from happening more then once per scan.
* happy new year ;)
* src/TreeView_Detail.cc: fixed some alignment issues
* include/GParted_Core.h,
src/GParted_Core.cc,
include/Operation.h,
src/Operation.cc,
include/Win_GParted.h,
src/Win_GParted.cc: removed confirmationdialogs for delete and
convert partitions (#319841).
Also renamed 'convert' to 'format' to reflect the actual
functionality.
* include/GParted_Core.h,
src/GParted_Core.cc: did some cleanups
* include/Operation.h,
src/Operation.cc: added get_index_extended to get the ext_index in a
uniform way instead of calculating it every time ourselves.
* include/Partition.h,
src/Partition.cc: added 'Glib::ustring mountpoint'
* include/GParted_Core.h,
src/GParted_Core.cc: implemented set_mountpoints() to set mountpoint
in partitions.
* include/Dialog_Partition_Info.h,
src/Dialog_Partition_Info.cc: use Partition::mountpoint instead of
finding it ourselves.
* include/Partition.h,
src/Partition.cc: from now on each partition has a reference to it's
device.
* src/Win_GParted.cc,
src/Dialog_Partition_New.cc: make use of new Set() from partition
* include/GParted_Core.h,
src/GParted_Core.cc: since ped_file_system_clobber() ignored reiser4
i've implemented a custom 'filesystem signature remover'.
Also made use of the fact a partition now knows on which device it
lives.
* src/Operation.cc: the get_string() didn't use
Get_Filesystem_String() and thus returned faulty strings. Also did
some cleanups.
* include/GParted_Core.h,
src/GParted_Core.cc: implemented a 'wait_for_node()' function after
reading http://bugs.gentoo.org/show_bug.cgi?id=102343. I couldn't
reproduce the bug myself, but i hope this wil solve it.
Also made 'set_partition_type()' return a boolean for improved
errorchecking.
* hmmz, lots of shimmery internals..
Instead of using a boolean to indicate support for certain
features i now use and enum (NONE, LIBPARTED, EXTENDED).
This allowed me to clean up some stuff that annoyed me ;)
Still.. the core could use a bit more love...
* include/FileSystem.h: cleanups
* include/GParted_Core.h,
src/GParted_Core.cc: correct partitiontype is now set after creation
or conversion. (#322281)
* src/Dialog_Filesystems.cc: fixed a11y thingy (#316108)
* include/GParted_Core.h,
src/GParted_Core.cc,
include/Dialog_Disklabel.h,
src/Dialog_Disklabel.cc,
src/Win_GParted.cc : get labeltypes from libparted instead of hardcoding them,
also changed some text (#315979)