Commit Graph

41 Commits

Author SHA1 Message Date
Mike Fleetwood 83ecae4918 Refactor flags in method FileSystem::execute_command() (#754684)
Change the two optional boolean parameters into a single optional flags
parameter which uses symbolically defined names.  Makes reading the
execute_command() calls much easier to understand.  (Implemented as bit
field using the same technique as used for Glib::SpawnFlags [1]).

This changes the calls thus:

  execute_command(cmd, od)              -> (cmd, od)
  execute_command(cmd, od, false)       -> (cmd, od, EXEC_NONE)  // [2]
  execute_command(cmd, od, true )       -> (cmd, od, EXEC_CHECK_STATUS)
  execute_command(cmd, od, false, true) -> (cmd, od, EXEC_CANCEL_SAFE)
  execute_command(cmd, od, true , true) ->
                          (cmd, od, EXEC_CHECK_STATUS|EXEC_CANCEL_SAFE)

[1] SpawnFlags bitwise operators in
    /usr/include/glibmm-2.4/glibmm/spawn.h.

[2] False and EXEC_NONE are the default values for the optional third
    parameter before and after this change respectively and both mean
    the same.  This is being used in btrfs::resize() and being kept for
    now despite it being the default.

Bug 754684 - Updates to FileSystem:: and Utils::execute_command()
             functions
2015-09-21 10:11:19 -06:00
Mike Fleetwood d3e17f4484 Remove unused execute_command_timed() (#754684)
Use of execute_command_timed() was removed by this commit from
2013-02-22:
    52a2a9b00a
    Reduce threading (#685740)

Bug 754684 - Updates to FileSystem:: and Utils::execute_command()
             functions
2015-09-21 10:11:19 -06:00
Mike Fleetwood f6e4390aaf Add const qualifier to get_custom_text() member functions
The function never modifies any member variables so make it a const
member function.

(FileSystem::get_custom_text() is a virtual function so can't be made
static).
2015-05-19 10:34:59 -06:00
Mike Fleetwood b1dc9e69e3 Make partition busy detection method selectable per file system (#723842)
GParted's primary inbuilt busy detection method is "is the partition
mounted?".  A custom method is used for LVM2 PV because its not a
mounted file system.

Make busy detection selectable per file system type.

    .fs.busy = FS::NONE  (default)
        No busy detection.

    .fs.busy = FS::GPARTED
        Use internal GParted method which checks if the partition is
        mounted.

    .fs.busy = FS:EXTERNAL
        Call the file system type's member function is_busy().

LVM2 PV busy detection changes from a special case to just electing to
call the lvm2_pv::is_busy() method.  Linux Software RAID remains a
special case because it's only recognised, but not otherwise supported.

Bug #723842 - GParted resizes the wrong filesystem (does not pass the
              devid to btrfs filesystem resize)
2014-07-28 10:03:16 -06: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 2b51d87147 Make include guards unique (#539297)
Include guards need to be unique within GParted code and all included
library header files.
    http://en.wikipedia.org/wiki/Include_guard#Difficulties

Use this model for all include guards:
    #ifndef GPARTED_FILE_NAME_H
    #define GPARTED_FILE_NAME_H
    ...
    #endif /* GPARTED_FILE_NAME_H */

Closes Bug #539297 - Make include guards unique
2013-06-05 10:57:39 -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 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 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
Mike Fleetwood 795a92f5b2 Add file system specific remove() methods (#670171)
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
2012-08-30 13:47:45 -06:00
Mike Fleetwood 719e73e335 Query unallocated space for unmounted file systems (#499202)
Update file system specific implementations to set the size and free
space, thus allowing the unallocated space in the partition to be
calculated, for the following unmounted file systems:
    btrfs, ext2, ext3, ext4, fat16, fat32, jfs, nilfs2, ntfs, reiserfs,
    reiser4, xfs

Bug #499202 - gparted does not see the difference if partition size
              differs from filesystem size
2012-06-18 10:24:28 -06:00
Rogier Goossens 8735227dd7 Add support for custom text strings depending on the filesystem
Part 2 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 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
Mike Fleetwood 4ab3fe0ee7 Add helper functions for mounted file system resizing operations
There is a lot of commonality and code repetition for resizing of file
systems which can only be resized while mounted.  Resizing of btrfs, jfs
and xfs all follow the pattern: mkdir, mount, resize, umount and rmdir.
Copying an xfs file system also uses a similar pattern, but for the
source and destination xfs file systems simultaneously.

Add three helper functions to the FileSystem class which implement
common tasks, allowing mounted file system resizing to be implemented
more simply.

Also add a function to the Utils class which checks whether the kernel
supports a file system.  It handles the case of non-loaded modules,
which currently leads to reporting the growing of jfs and xfs as
unsupported.
2012-01-11 12:49:13 -07:00
Curtis Gedak ca30f986f7 Add virtual move method to FileSystem class
This is preparation work for the following bug report:
Bug #589555 - Moving a swap partition needlessly copies
              all "data" on it
2010-10-19 13:35:53 -06:00
Curtis Gedak 8cfb27b718 Cleanup file copyright entries
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.
2009-11-05 11:08:49 -07:00
Curtis Gedak 55952fe621 Renamed set_label and get_label methods to write_label and read_label respectively.
svn path=/trunk/; revision=957
2008-11-08 23:55:17 +00:00
Curtis Gedak 8d808c0b62 gparted-0.3.6 - code recreation from Source Forge
svn path=/trunk/; revision=810
2008-04-07 19:41:18 +00:00
Bart Hakvoort e3b4a7316b added support for reading volumelabels. Atm we only read ext2/3, but the
* 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)
2006-09-12 20:34:33 +00:00
Bart Hakvoort 889ab1232f changed progressfeedbackhandling a bit. Because this affected
* changed progressfeedbackhandling a bit. Because this affected
  OperationDetail i had to make changes in almost every file.
2006-08-20 09:33:54 +00:00
Bart Hakvoort d52b0286c9 fixed Pango markup problems in operationdetails restructured
* fixed Pango markup problems in operationdetails
* restructured OperationDetail
* renamed some enums for improved readability of the source
2006-07-29 08:27:28 +00:00
Bart Hakvoort d663c3c277 removed cylindersize buffering during resize from the filesystems. It is
* 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
2006-07-23 18:43:15 +00:00
Bart Hakvoort 29a7744fe2 improved errorhandling in Set_Used_Sectors() in the filesystemclasses
* improved errorhandling in Set_Used_Sectors() in the filesystemclasses
2006-02-25 12:25:18 +00:00
Bart Hakvoort 828d7a9e5b wrap mount/umount/swapon/swapoff instead of implementing it ourselves
* wrap mount/umount/swapon/swapoff instead of implementing it
  ourselves (#330641)
* moved execute_command() to Utils and made the filesystems use it. All
  in all this decreased the size of the binary with 10% and made stuff
  more readable.
2006-02-15 16:05:26 +00:00
Bart Hakvoort 52dfb1c364 correct partitiontype of destination is now set while copying resizing now
* correct partitiontype of destination is now set while copying
* resizing now return correct status (sometimes it would report
  succes even when some of the suboperationes failed)
* fixed some issues with resizing and cylindersizes.
2006-01-22 21:16:36 +00:00
Bart Hakvoort 045edbbe95 :spawn_sync instead of popen(). also made the filesystems call
* removed Execute_Command() and replaced it by execute_command().
  The latter uses Glib::spawn_sync instead of popen().
  also made the filesystems call execute_command rather than calling
  Glib::spawn_sync themselves.
2006-01-22 13:23:58 +00:00
Bart Hakvoort 97a9a5fa87 p
* 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
2006-01-19 19:15:15 +00:00
Bart Hakvoort 23aa549c7c :spawn_command_line_sync() + general cleanups in the set_used_sectors()
* replaced popen() with Glib::spawn_command_line_sync() + general
  cleanups in the set_used_sectors() functions.
2005-12-28 16:43:06 +00:00
Bart Hakvoort 4fc49c2760 merry christmas cleanups replaced popen() with
* merry christmas
* src/GParted_Core.cc,
  src/VBox_VisualDisk.cc,
  src/Win_GParted.cc: cleanups
* include/FileSystem.h,
  src/FileSystem.cc,
  src/ext2.cc,
  src/ext3.cc: replaced popen() with Glib::spawn_command_line_sync()
2005-12-24 23:55:54 +00:00
Bart Hakvoort 93300e2b32 use mkdir instead of wrapping CLI tool
* include/FileSystem.h,
  src/jfs.cc,
  src/xfs.cc: use mkdir instead of wrapping CLI tool
2005-12-14 15:15:51 +00:00
Bart Hakvoort 7e4efd3c2e rewrote quite some stuff to use an enum to indentify filesystems instead
* rewrote quite some stuff to use an enum to indentify filesystems
  instead of stringcomparisons.
2005-12-07 11:21:27 +00:00
Bart Hakvoort cc18d11ad5 hmmz, lots of shimmery internals.. Instead of using a boolean to indicate
* 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...
2005-11-27 00:57:11 +00:00
Bart Hakvoort 1382c7bc17 cleanups correct partitiontype is now set after creation or conversion.
* include/FileSystem.h: cleanups
* include/GParted_Core.h,
  src/GParted_Core.cc: correct partitiontype is now set after creation
  or conversion. (#322281)
2005-11-24 15:59:31 +00:00
Bart Hakvoort c87cba6ee5 Changed 'bool Create( const Glib::ustring & device_path, const Partition &
* The Filesystemclasses: Changed 'bool Create( const Glib::ustring & device_path, const Partition & new_partition )'
to 'bool Create( const Partition & new_partition )'. Since i now use external tools for all filesystems, the partitionpath will suffice.
2004-12-28 13:29:01 +00:00
Bart Hakvoort 8a0ed3b6ac added support for jfs (create, copy, grow) and hfs (create, copy) fixed a
* added support for jfs (create, copy, grow) and hfs (create, copy)
* fixed a bug in copying xfs filesystems.
* fixed a number of small bugs/annoying issues.
2004-12-14 22:49:44 +00:00
Bart Hakvoort f0eb17b8db Execute_Command() now returns exit status of executed command returnvalue
* include/FileSystem.h,
  src/FileSystem.cc: Execute_Command() now returns exit status of executed command
* the filesystemclasses: returnvalue (bool) is now set according to the return status of the command
2004-11-30 21:05:48 +00:00
Bart Hakvoort 038c5c5d99 P (special thanks to mantiena-baltix for bringing this issue to my
* Harddisks without disklabel are now properly initizalized and shown in the menu. When one tries to create a new partition on
  such a disk a dialog pops up with some blabla about disklabels and offers to create a disklabel. sweet :P (special thanks to mantiena-baltix
  for bringing this issue to my attention)
* fixed minor annoyance with refreshing detailed deviceinfo after a 'deep refresh'
2004-11-27 23:31:19 +00:00
Bart Hakvoort bd02bca613 P ). Resizing of ext2/3 works perfect now. I've even tested it on the
* Again way too many chances to create a detailed entry (i'm glad i'm the only dev atm :P ).
  Resizing of ext2/3 works perfect now. I've even tested it on the partition holding my SG seasons =)
  Implemented checking of filesystems (only internally used atm).
  Done some overall tweaking, finetuning etc.. release 0.0.7 is getting shape.
2004-11-21 21:49:38 +00:00
Bart Hakvoort 410ab30975 availability of 'tune2fs' command wasn't detected correctly. fixed make
* src/ext3.cc: availability of 'tune2fs' command wasn't detected correctly. fixed
* src/fat32.cc: make use of dosfs tools (mkdosfs -F32) instead of libparted's Fat-creator.
* po/POTFILES.in: added src/GParted_Core.cc
2004-11-17 14:12:18 +00:00
Bart Hakvoort 4ccf831ec7 P) It still needs a lot of love, but the foundations are laid =)
* Rewrote a large part of gparteds internal code. Filesystemssupport is now much more separated from the rest of gparted and
  adding support for other filesystems should be a piece of cake now (hope that's true :P)
  It still needs a lot of love, but the foundations are laid =)
2004-11-17 13:00:25 +00:00