Commit Graph

860 Commits

Author SHA1 Message Date
Curtis Gedak 6ea69b0ff8 Mark string "Force Cancel" for translation 2013-03-11 19:35:43 -06:00
Phillip Susi a92380b503 Pass Partition instead of just its path to FileSystem::copy()
Other operations get the Partition object and can look up the path or other
attributes they need.  The copy method should be no different.
2013-03-11 18:40:31 -06:00
Phillip Susi e4210ba08d Cleanup duplicate fs code
Many filesystems do not implement some of their methods, but had to provide
dummy implementations.  Remove all of the dummy implementations and instead
just provide one in the base FileSystem class.
2013-03-11 18:40:31 -06:00
Phillip Susi 4c249b4d65 Fix dialog progress details view size (#602635) (#662722)
The details view refused to use additional space, even after the window was
expanded, instead continuing to use the scrollbars.  Now resizing the
window will be allowed regardless of the state of the details expander, and
the details view will expand to use the extra space.  Also request enough
initial width to not need a horizontal scrollbar.

Closes:
Bug 602635 - list of tasks in apply dialog does not expand to the available
             vertical space

Bug 662722 - Increase default width of "applying..." dialog to include the
             "Details" status icons
2013-03-11 18:40:31 -06:00
Phillip Susi 38dc55d49c Combine duplicate code for ext[234]
There were separate modules for ext3 and ext4 even though there
were virtually no differences with ext2.  Remove the duplicate
modules and patch ext2 to serve as a common reference for all
three sub types.
2013-03-11 18:40:31 -06:00
Phillip Susi 7af47136ff Clean up OperationDetail timer initialization
The timer variables were not being properly initialized leading to bogus
time values sometimes being displayed.
2013-03-11 18:40:31 -06:00
Phillip Susi b1ede01506 Don't revert more than needed
After a move is canceled or fails, an attempt is made to revert the disk to
its previous state.  This was moving back all blocks that had already been
copied.  Many of the first blocks copied during a move do not overwrite
any valid data, and so do not need put back after an error, so don't bother
doing so.
2013-03-11 18:40:31 -06:00
Phillip Susi d62bf0a0f3 Check fs after reverting partition table
After a failed or canceled move, the move was reverted, and the filesystem
was fscked while the partition was still in the expanded state encompassing
the original and destination partitions, resulting in errors and
corruption.  Move fsck to after the partition table has been restored to
its original state.
2013-03-11 18:40:31 -06:00
Phillip Susi b9b4b2e55d Remove simulation pass ( read test ) on move
The simulation pass is unnecessary and just wastes more time when moving,
so get rid of it.
2013-03-11 18:40:31 -06:00
Phillip Susi 2a2d21c231 Bind ctrl-enter to apply-operations
Bind the keyboard accelerator key ctrl-enter to apply operations.
2013-03-11 18:40:31 -06:00
Phillip Susi 3dd769d955 Select unallocated partition by default (#667365)
After a refresh, instead of having no partition selected, default to the
largest unallocated partition.  This allows immediate creation of a new
partition in the unallocated space.

Closes Bug 667365 - Free space should be selected by default
2013-03-11 18:40:31 -06:00
Phillip Susi 9ad53d94a0 Bind Insert key to new partition
Add an accelerator key for Insert to trigger the new partition menu item.
2013-03-11 18:40:31 -06:00
Phillip Susi 723209e59f Flag mkfs and copy operations as safe to cancel (#601239)
Closes Bug #601239 - Please allow 'Cancel after current operation'
2013-03-11 18:40:31 -06:00
Phillip Susi 89de9a5026 Add proper cancel support (#601239)
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'
2013-03-11 18:40:31 -06:00
Phillip Susi bd9e16f22f Thread the internal copy algorithm (#685740)
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
2013-03-11 18:40:31 -06:00
Phillip Susi 52a2a9b00a Reduce threading (#685740)
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
2013-03-11 18:40:31 -06:00
Phillip Susi 2706f0174a Remove mtoolsrc file
fat16 and fat32 were creating a temp mtoolsrc file to configure the
command to reference a drive letter and ignore certain errors.  They have
been changed to pass this information via the command line and environment
instead.
2013-03-11 18:40:31 -06:00
Phillip Susi ddd92cf86a Switch Dialog_Progress to use Glib thread instead of pthread (#601239)
Dialog_Progress was using pthread_create() so that it could later
pthread_cancel() the thread.  pthread_cancel() is wildly unsafe and full
of errors.  Changed to use Glib's threads like the rest, and only cancel
between operations.  Because it can take some time to cancel, disable
the cancel button once it has been clicked once.

Bug 601239 - Please allow 'Cancel after current operation'
2013-03-11 18:40:31 -06:00
Phillip Susi 124342e979 Use a full fledged nested main loop while waiting and pulsing progress bars (#685740)
Win_Gparted and Dialog_Progress were looping on Gtk::Main::events_pending()
and iteration() with usleeps in between.  Use a full mainloop instead and
a proper timeout to trigger pulsebar updates instead of usleeps.

Part of Bug 685740 - Refactor to use asynchronous command execution
2013-03-11 18:40:31 -06:00
Phillip Susi f5a5c9cdb9 Remove gdk_threads_enter/exit (#685740)
Use of these functions is depreciated and making gtk calls in a background
thread still sometimes causes deadlocks or crashes.  Change ped exception
handler to instead use an idle function to force the main thread to display
the dialog box.

Part of Bug 685740 - Refactor to use asynchronous command execution
2013-03-11 18:40:31 -06:00
Curtis Gedak 34da790ef3 Fix move partition right to left shrinks partition 1 MiB (#695078)
When moving a MiB aligned primary partition from right to left, the
resulting partition was unexpectedly 1 MiB smaller in size.

From further testing, this occurred only if the move boundaries
overlapped the original partition boundaries.

In cases where the move did not overlap the original partition
boundaries, then the size remained the same.

Closes Bug #695078 - Move of MiB aligned partition right to left
                     yields unexpected shrink of 1 MiB
2013-03-04 18:32:01 +00:00
Curtis Gedak a0e0f1c5d9 Update copyright year 2013-02-21 10:43:14 -07:00
Jan Claeys cdb6cbfa80 Work around faulty "complete disks" detection in mkdosfs (#693955)
Add -I option to 'mkdosfs' command to work around faulty detection of
"complete disks" vs. "partitions".

Bug #693955 - mkdosfs detects "complete disk" vs. "partition" incorrectly

Thanks to Kano for reporting this!

(This will also be needed if GParted ever allows formatting a device without
partitioning it.)
2013-02-21 10:29:01 -07:00
Mathieu Dupuy b7393be268 Argument vector usage improvement (#689689)
Minor change to filling user_devices vector.

Closes Bug #689689 - argument vector filling improvement proposal
2013-01-12 14:07:48 -07:00
Curtis Gedak 81682eaf29 Provide credit in About dialog for contributions
Recognize contributions by Sinlu Bes.
2013-01-02 11:53:50 -07:00
Mike Fleetwood d0fec5e26f Remove redundant code trimming labels to length before use (#689318)
No longer need to trim fat16, fat32 and xfs labels as all labels are
limited to their maximum lengths during entry.

Bug #689318 - filesystem type specific support for partition name
              maximum length
2013-01-02 11:33:32 -07:00
Mike Fleetwood 18941e24d3 Avoid reading trailing junk for a reiser4 label (#689318)
For a reiser4 file system with exactly the maximum size 16 character
label, debugfs.reiser4 may include junk at the end of the label it
prints.  (It reads the label into a 16 character array and prints it as
a string, but there isn't a nul terminating character).

    # mkfs.reiser4 --yes --label abcdefghij123456 /dev/sda13
    # debugfs.reiser4 /dev/sda13 2> /dev/null | grep label:
    label:          abcdefghij123456!

Trim the read label to at most 16 characters.

Bug #689318 - filesystem type specific support for partition name
              maximum length
2013-01-02 11:33:32 -07:00
sinlu bes ecb1f57594 Make the partition label length dependent from the file system (#689318)
fixes Bug #689318 - filesystem type specific support for partition name
                    maximum length
2012-12-30 16:55:03 +00:00
Curtis Gedak de99c530d4 Remove SWRaid method as it is no longer needed (#678379)
Active Linux software RAID devices are detected in the
Proc_Partitions_Info method.  Hence the SWRaid method is no longer
required.

Removal of the SWRaid method fixes the problem with the error message:

  Could not stat device /dev/md/0 - No such file or directory

This fixes the problem because we no longer use "mdadm --examine
--scan" in an attempt to detect Linux software RAID devices.  The
mdadm command was returning device names such as /dev/md/0, which are
incorrect for GParted.

NOTE:  With this change, GParted no longer requires the mdadm command
       to detect Linux software RAID devices.

Closes Bug #678379 - Could not stat device /dev/md/0 - No such file or
                     directory
2012-12-05 09:51:50 -07:00
Curtis Gedak c600095912 Add regexp for Linux SW RAID devices in /proc/partitions (#678379)
Add regular expression to detect the device entry only (e.g., md127)
and not the partitions (e.g., md127p1).

Linux software RAID devices are listed in /proc/partitions as follows:

# cat /proc/partitions
major minor  #blocks  name
   9   127     523968 md127
 259     0     131072 md127p1
 259     1     262144 md127p2

Part of Bug #678379 - Could not stat device /dev/md/0 - No such file
                      or directory
2012-12-05 09:51:50 -07:00
Curtis Gedak f003b3c4f2 Tighten up regexp for HP Smart Array Devices
HP Smart Array Devices are listed in /proc/partitions as follows:

major minor  #blocks  name
 104     0  143338560 cciss/c0d0
 104     1     104391 cciss/c0d0p1
 104     2      24097 cciss/c0d0p2
 104     3  143203410 cciss/c0d0p3

The previous regular expression was too broad, and would match many
other forms, including Linux software RAID devices such as md127.

Linux software RAID devices are listed in /proc/partitions as follows:

major minor  #blocks  name
   9   127     523968 md127
 259     0     131072 md127p1
 259     1     262144 md127p2

This problem with the regexp was discovered while investigating a
problem with Linux software RAID device detection.

The regular expression has been tightened up to match the following
hardware RAID controllers:

  Compaq/HP Smartarray RAID controller
    E.g., device = /dev/cciss/c0d0, partition = /dev/cciss/c0d0p1
    (linux-x.y.z/Documentation/blockdev/cciss.txt)

  Compaq SMART2 Intelligent Disk Array controller
    E.g., device = /dev/ida/c0d0, partition = /dev/ida/c0d0p1
    (linux-x.y.z/Documentation/blockdev/cpqarray.txt)

  Mylex DAC960/AcceleRAID/eXtremeRAID PCI RAID Controllers
    E.g., device = /dev/rd/c0d0,  partition = /dev/rd/c0d0p1
    (linux-x.y.z/Documentation/blockdev/README.DAC960)

Related to Bug #678379 - Could not stat device /dev/md/0 - No such
                         file or directory
2012-12-05 09:51:50 -07:00
Curtis Gedak 83ccbce199 Fix logical partition grow overlaps extended partition end (#686668)
In certain situations with a mixture of partition alignments, the MiB
alignment option would try to set the end of a logical partition
beyond the end of the extended partition.  This, of course, is an
invalid partition geometry and the libparted library correctly reports
failure when this is attempted.

This enhancement to MiB alignment adds a check to see if the end of
the logical partition would be beyond the extended partition, and
adjusts the end of the logical partition if required.

Closes Bug #686668 - Growing logical partition overlaps end of
                     extended partition
2012-12-03 13:07:53 +00:00
Curtis Gedak fd96328920 Prevent file system grow when partition grow fails (#686668)
Prior to this enhancement, GParted ignored the status of the partition
grow operation, and attempted to grow the file system.

Now we check the status of the partition grow operation prior to
growing the file system.

Part of Bug #686668 - Growing logical partition overlaps end of
                      extended partition
2012-12-03 13:07:53 +00:00
Curtis Gedak c17959e200 Provide credit in About dialog for contributions
Recognize contributions by Matthias Gehre.
2012-11-30 13:32:31 -07:00
Mike Fleetwood f5c153099b Treat reiser4 label "<none>" as meaning blank (#688760)
A reiser4 file system with a blank label is displayed as "<none>" by
debugfs.reiser4 and therefore GParted too.

    # mkfs.reiser4 -y -L "" -f /dev/sda14
    # debugfs.reiser4 /dev/sda14 2> /dev/null | grep label:
    label:		<none>

Additionally when displaying the Partition Information the following
warning is written to the terminal:

    (gpartedbin:19609): Gtk-WARNING **: Failed to set text from markup
    due to error parsing markup: Error on line 1 char 23: Element
    'markup' was closed, but the currently open element is 'none'

Fix by just assuming "<none>" always means blank.  If someone really
does set the label to "<none>" it won't be displayed.  This is equlivant
to how btrfs and nilfs2 are already handled.

Closes bug 688760 - GParted displays blank resier4 label as <none>
2012-11-21 10:45:44 -07:00
Matthias Gehre 1f3b11748e Remove GParted_Core::p_filesystem (#683149)
Bug #683149 - Cleanup(?): Remove lp_device and lp_disk from GParted_Core
2012-11-11 11:47:59 +00:00
Matthias Gehre d2ced08355 Remove GParted_Core::partition_temp (#683149)
Bug #683149 - Cleanup(?): Remove lp_device and lp_disk from GParted_Core
2012-11-11 11:47:59 +00:00
Matthias Gehre a13bed6424 Remove GParted_Core::temp (#683149)
Bug #683149 - Cleanup(?): Remove lp_device and lp_disk from GParted_Core
2012-11-11 11:47:59 +00:00
Matthias Gehre 6a3b17adc0 Remove lp_partition from GParted_Core (#683149)
Bug #683149 - Cleanup(?): Remove lp_device and lp_disk from GParted_Core
2012-11-11 11:47:59 +00:00
Matthias Gehre 7dd46df954 Remove unnecessary close_device_and_disk()
1) lp_disk is not used and assigned NULL so doesn't need closing.
2) lp_device is already ped_device_open()ed and ped_device_close()d
within the above while loop.  lp_device will be set to NULL when the
while loop ends so this doesn't need closing either.  Hence
close_device_and_disk() is always passed with two NULL pointers and is a
no operation so can be removed.
2012-11-11 11:47:59 +00:00
Matthias Gehre 500f1bcd9b Remove lp_device and lp_disk from GParted_Core (#683149)
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
2012-11-11 11:47:59 +00:00
Mike Fleetwood 5ca702019e Recognise when Linux swap label is changed to blank (#685656)
Use swaplabel to read the Linux swap label so that 1) a blank label can
be read, and 2) to replace deprecated and removed vol_id.

Vol_id was deprecated in May 2009, superseded by blkid and soon
thereafter removed.  Swaplabel is available in util-linux 2.18 from Jun
2010.

If the swaplabel command is not available GParted falls back on reading
the label through the FS_Info cache which uses the blkid command.  If
the blkid command is also not available FS_Info cache will *NOT* return
any label and GParted will display blank.

Bug 685656 - GParted doesn't notice when file system label is changed to
             blank
2012-11-04 12:26:09 +00:00
Mike Fleetwood 686ec8f713 Make GParted recognise reading blank file system labels (#685656)
GParted doesn't notice when a file system label is changed to blank.
GParted first calls the file system specific read_label() method.  When
the label is blank read_label() correctly sets partition.label to the
zero length string.  Second GParted_Core::set_device_partitions() treats
the zero length string to mean that the label is unset and calls
FS_Info::get_label() to retrieve it from the cache of blkid output.
Blkid also doesn't notice when the file system label has been changed to
blank so reports the previous label.  Hence GParted displays the
previous file system label.

Fix by making label a private member variable of the class Partition and
providing access methods set_label(), get_label() and label_known()
which track whether the label has been set or not.  This only fixes the
fault for file systems which use file system specific commands to read
the label and when these tools are installed.  Otherwise GParted uses,
or has to fall back on using, the buggy blkid command to read the file
system label.

NOTE:
Many of the file system specific read_label() methods use a tool which
outputs more than just the label and use Utils::regexp_label() to match
leading text and the label itself.  If the surrounding text changes or
disappears altogether to indicated a blank label, regexp_label() doesn't
match anything and returns the zero length string.  This  is exactly
what is required and is passed to set_label() to set the label to blank.

Bug 685656 - GParted doesn't notice when file system label is changed to
             blank
2012-11-04 12:26:09 +00:00
Mike Fleetwood eaeaebb421 Remove old FIXME comment from reiserfs::read_label()
Traced debugreiserfs on a 10GiB reiserfs file system which was 100% full
full with nearly 900,000 files.  It read exactly three 4KiB blocks from
different offsets and the program never took more than 0.1 seconds.
2012-10-02 13:19:30 -06:00
Mike Fleetwood e7bfd52a4d Remove old #include <cerrno> from jfs and xfs modules
Use of errno disappeared from jfs and xfs when they switched to using
helper functions for file system resizing.
2012-10-02 13:19:30 -06:00
Mike Fleetwood 3828019030 Read file system size for mounted ext2/3/4 from superblock (#683255)
A user had a 190 MiB partition containing an old ext2 file system.  When
unmounted it was reported as filling the partition, but when mounted it
was reported as having 6% unallocated space.  The file system's inode
tables were approximately twice the size of those created by default
with the current mkfs.ext2 defaults.

To create an equivalent file system in a 190 MiB partition:
    mkfs.ext2 -N 97344 /dev/sda15

It turns out that for ext2, ext3 and ext4 file systems what was
described as intrinsic unallocated space during the development of
Bug #499202 is actually file system overhead.  When mounted the ext2/3/4
kernel code reports the size of the file system after subtracting the
overhead.  Overhead is made up of superblock backups, group descriptors,
allocation bitmaps and largest of all inode tables.  E2fsprogs tools
don't subtract this overhead when reporting the file system size.

References:

 *  The Second Extended File System, Internal Layout, by Dave Poirier
    http://www.nongnu.org/ext2-doc/ext2.html

 *  Linux ext2_statfs() function
    http://lxr.linux.no/#linux+v3.5.3/fs/ext2/super.c#L1311

Call the file system specific method for reading the usage of ext2, ext3
and ext4 file systems while mounted.  Make it read the file system size
from the on disk superblock to avoid subtraction of overhead and use the
statvfs() system call to return an up to date free space figure.

Bug #683255 - ext2: statvfs differs from dumpe2fs (x MB unallocated
              space within the partition)
2012-10-02 13:19:29 -06:00
Mike Fleetwood 01150758c3 Make mounted partition usage method selectable per file system (#683255)
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)
2012-10-02 13:19:29 -06:00
Mike Fleetwood e282b78b4a Switch to using debugfs.reiser4 to read the label
Vol_id command was deprecated in May 2009 and superseded by the blkid
command.  Replace the generic vol_id command with the file system
specific debugfs.reiser4 command to read the file system label.
Debugfs.reiser4 will exist as it's already required to read the file
system usage and UUID.
2012-09-28 16:45:43 -06:00
Mike Fleetwood 4f235ecb06 Update file system specific validation of RFC 4122 UUIDs
Use the new RFC 4122 none Nil UUID regular expression to validate the
UUID read in all the Linux native file system specific read_uuid()
methods.  No longer need to explicitly exclude "<none>" or all zeros Nil
UUID as the regular expression does this.
2012-09-28 16:45:43 -06:00
Mike Fleetwood aa16bf5451 Switch to using jfs_tune to read the UUID
Not necessary but use the simpler file system tune command rather than
the file system debug command where possible.  Also saves creating an
echo process.
2012-09-28 16:45:43 -06:00