Commit Graph

189 Commits

Author SHA1 Message Date
Mike Fleetwood 3630b9c83b Rename methods in GParted_Core and Win_GParted classes (#741424)
class GParted_Core:
    label_partition() -> label_filesystem()

class Win_GParted:
    allow_label_partition()    -> allow_label_filesystem()
    activate_label_partition() -> activate_label_filesystem()

Bug 741424 - Add support for GPT partition names
2015-02-01 10:08:23 -07:00
Mike Fleetwood 8b4b73a8f3 Add supported_filesystem() predicate method (#738471)
Helper to check whether a recognised file system type is supported by
GParted or not.  Supported means there is an implementation class and
will appear in the File System Support dialog.

Make supported_filesystem() a static member function so that it can be
called without a class object so that GParted_Core::GParted_Core()
initialiser isn't called multiple times.  This requires FILESYSTEM_MAP
to become a static member variable too.

Bug #738471 - ReFS file system is not recognised
2014-10-30 09:55:01 -06:00
Mike Fleetwood e3a1b93a6d Pass by value to get_filesystem_object()
get_filesystem_object() takes a constant reference to a FILESYSTEM, but
FILESYSTEM is just an enumeration.  So that's a pointer to a constant
int.  Just pass by value instead.
2014-10-30 09:55:01 -06:00
Mike Fleetwood c1db9811e1 Use Autoconf check specifically for libparted-fs-resize (#734718)
Remove HAVE_LIBPARTED_3_1_0_PLUS definition and replace Autoconf
    check for libparted >= 3.1

Currently uses custom check which compiles an executable to check for
libparted version >= 3.1 to determine the availability of the library
parted-fs-resize and the need to include the header <parted/filesys.h>.

Change to use a direct Autoconf check to determine the availability of
the ped_file_system_resize() function in the parted-fs-resize library.
Remove inclusion of the header <parted/filesys.h> as it has always been
included via <parted/parted.h>, at least as far back as parted 1.8.0,
and even in parted 3.0 when ped_file_system_resize() and libparted file
system resize capability didn't exist.

Bug #734718 - Update Autoconf version specific libparted checks and
              defines to feature specific ones
2014-08-18 15:48:34 -06:00
Mike Fleetwood 3bea067596 Flush devices when scanning to prevent reading stale signatures (#723842)
While one partition is busy, reformat another partition from the command
line.  Afterwards parted/libparted still detects the original file
system and GParted shows errors from the file system specific tools
reporting the new file system doesn't exist.  Only limitation is that
the new new file system must be recognised by libparted (or by GParted's
fallback file system signature detection).

Case #1, File system reformatting:

    # parted /dev/sdb print
    Model: ATA SAMSUNG SSD UM41 (scsi)
    Disk /dev/sdb: 8012MB
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos

    Number  Start   End     Size    Type     File system  Flags
     1      1049kB  2149MB  2147MB  primary  ext2
     2      2149MB  4296MB  2147MB  primary  ext2
    # mount | fgrep sdb
    /dev/sdb1 on /mnt/1 type ext2 (rw)

    # mkfs.xfs -f /dev/sdb2
    # blkid /dev/sdb2
    /dev/sdb2: UUID="c31823a2-b81b-46fa-8246-0a59695e4834" TYPE="xfs"
    # parted /dev/sdb print
    Model: ATA SAMSUNG SSD UM41 (scsi)
    Disk /dev/sdb: 8012MB
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos

    Number  Start   End     Size    Type     File system  Flags
     1      1049kB  2149MB  2147MB  primary  ext2
     2      2149MB  4296MB  2147MB  primary  ext2
    # e2label /dev/sdb2
    e2label: Bad magic number in super-block while trying to open /dev/sdb2
    Couldn't find valid filesystem superblock.
    # dumpe2fs /dev/sdb2
    dumpe2fs 1.41.12 (17-May-2010)
    dumpe2fs: Bad magic number in super-block while trying to open /dev/sdb2
    Couldn't find valid filesystem superblock.

Case #2, Removing device from multi-device btrfs:

    # btrfs filesystem show /dev/sdb1
    Label: none  uuid: a05db434-efd5-4e8c-902f-05f89a88b610
            Total devices 2 FS bytes used 156.00KB
            devid    2 size 2.00GB used 512.00MB path /dev/sdb2
            devid    1 size 2.00GB used 240.75MB path /dev/sdb1

    # mount /dev/sdb1 /mnt/1
    # btrfs device delete /dev/sdb2
    # btrfs filesystem show /dev/sdb1
    Label: none  uuid: a05db434-efd5-4e8c-902f-05f89a88b610
            Total devices 1 FS bytes used 92.00KB
            devid    1 size 2.00GB used 714.25MB path /dev/sdb1
    # btrfs filesystem show /dev/sdb2

and GParted reports this error for partition /dev/sdb2:
    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 btrfs
    file system support:  btrfs-tools.

This is another case of libparted reading from the whole disk device
(/dev/sdb) yet the file system tools use the partition specific block
device (/dev/sdb2), and the Linux buffer cache not providing cache
coherency.  Previous scenario was fixed with:

    797f0b8eeb
    Flush device after wiping a file system (#688882)

This affects libparted 2.0 to 3.1 inclusive and is fixed by:

    http://git.savannah.gnu.org/cgit/parted.git/commit/?id=fb99ba5ebd0dc34204fc9f1014131d5d494805bc
    Revert "linux-commit: do not unnecessarily open partition device nodes"

Fix by calling ped_device_sync() to guarantee cache coherency for each
device during scanning.

Bug #723842 - GParted resizes the wrong filesystem (does not pass the
              devid to btrfs filesystem resize)
2014-07-28 10:03:16 -06:00
Mike Fleetwood 4b63e46a4e Fallback to reading mount command output instead of /etc/mtab (#723842)
With linux 3.5 and later, the device used to mount a btrfs file system
is updated in /proc/mounts when the previous mounting device is removed
from the file system.  Most recent distributions make /etc/mtab a
symbolic link to /proc/mounts.  However some still have /etc/mtab as a
plain file only updated by mount and umount, thus showing the old device
name which is no longer part of the file system.

On Ubuntu 13.10, which has /etc/mtab as a plain file managed by mount
and umount:

    # mkfs.btrfs /dev/sdb1
    # mount /dev/sdb1 /mnt/1
    # btrfs device add /dev/sdb2 /mnt/1
    # btrfs device delete /dev/sdb1 /mnt/1
    # sync
    # btrfs filesystem show /dev/sdb1
    # btrfs filesystem show /dev/sdb2
    Label: none  uuid: e47775a6-e5ad-4fb4-9ea4-1570aa5b4009
            Total devices 2 FS bytes used 28.00KB
            devid    2 size 2.00GB used 272.00MB path /dev/sdb2

    # fgrep btrfs /proc/mounts
    /dev/sdb2 /mnt/1 btrfs rw,relatime,space_cache 0 0
    # ls -l /etc/mtab
    -rw-r--r-- 1 root root 842 Apr 15 19:41 /etc/mtab
    # fgrep btrfs /etc/mtab
    /dev/sdb1 /mnt/1 btrfs rw 0 0

This causes GParted to report /dev/sdb1 as busy and mounted at /mnt/1
when it is no longer mounted.  This effects recent releases of Ubuntu,
13.04, 13.10 and 14.04.

Either /etc/mtab is a symlink and is identical to /proc/mounts or
/etc/mtab is a plain file with wrong information.  Fix by not reading
mounted file systems from /etc/mtab.

However old distributions only contain 'rootfs' and '/dev/root' device
names for the / (root) file system with '/dev/root' being a block device
rather than a symlink to the true device.  For example from CentOS 5.x:

    # fgrep ' / ' /proc/mounts
    rootfs / rootfs rw 0 0
    /dev/root / ext3 rw,data=ordered 0 0
    # ls -l /dev/root
    brw------- 1 root root 8, 3 Jun  4  2013 /dev/root

This prevents identification, and therefore busy detection, of the
device containing the / (root) file system.  Used to read /etc/mtab to
get the root file system device name.

    # fgrep ' / ' /etc/mtab
    /dev/sda3 / ext3 rw 0 0
    # ls -l /dev/sda3
    brw-r----- 1 root disk 8, 3 Jun  4  2013 /dev/sda3

As per commit:

    409096f739
    improved scanning for root mountpoint (/) ...

but, as discussed above, this contains an out of date device name after
the mounting device has been dynamically removed from a multi-device
btrfs, thus identifying the wrong device as busy.  Instead fall back to
reading mounted file systems from the output of the mount command, but
only when required.

    # mount | fgrep ' / '
    /dev/sda3 on / type ext3 (rw)

Bug #723842 - GParted resizes the wrong filesystem (does not pass the
              devid to btrfs filesystem resize)
2014-07-28 10:03:16 -06:00
Mike Fleetwood a086e115e5 Display mount points for multi-device btrfs file systems (#723842)
Linux can only show a single device name in /proc/mounts and /etc/mtab
for each mounted btrfs, even if it is a multi-device file system.  So
GParted only shows a mount point for one of the devices in the btrfs, no
matter how many devices are part of the file system.

    # mkfs.btrfs /dev/sdb1 /dev/sdb2
    # btrfs filesystem show /dev/sdb1
    Label: none  uuid: 36eb51a2-2927-4c92-820f-b2f0b5cdae50
            Total devices 2 FS bytes used 156.00KB
            devid    2 size 2.00GB used 512.00MB path /dev/sdb2
            devid    1 size 2.00GB used 240.75MB path /dev/sdb1
    # mount /dev/sdb1 /mnt/1
    # grep btrfs /proc/mounts
    /dev/sdb1 /mnt/1 btrfs rw,seclabel,relatime,ssd,space_cache 0 0

GParted only shows the mount point for /dev/sdb1 as /mnt/1, but nothing
for /dev/sdb2.

Make GParted report the same mount point for all devices included in a
multi-device btrfs file system.

Add btrfs specific get_mount_device() method to report the mounting
device, if any, for the btrfs file system in the occupying the device in
question.  Uses the existing cache of btrfs file system device
membership.  Also extract common code from GParted_Core::
set_mountpoints() into set_mountpoints_helper().

Bug #723842 - GParted resizes the wrong filesystem (does not pass the
              devid to btrfs filesystem resize)
2014-07-28 10:03:16 -06:00
Mike Fleetwood a0c0533e3e Add is_dev_mounted() to expose core partition is mounted test (#723842)
Add static member function GParted_Core::is_dev_mounted() so that other
modules can determine if a particular partition contains a mounted file
system or not.

Make it a static member function so that it can be called without
needing the gparted_core object.  Extend to make the group of
manipulated variables (mount_info, fstab_info) and manipulating
functions (init_maps(), read_mountpoints_from_file(),
read_mountpoints_from_file_swaps(), get_all_mountpoints()) static too.

Bug #723842 - GParted resizes the wrong filesystem (does not pass the
              devid to btrfs filesystem resize)
2014-07-28 10:03:16 -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
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 67115eeff2 Remove unused member variable GParted_Core::buf 2014-04-23 09:54:20 -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 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 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
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
Mike Fleetwood 6c33a8f5ca Remove unused function copy_filesystem_simulation()
The function is no longer used after commit:

    b9b4b2e55d
    Remove simulation pass ( read test ) on move
2013-03-25 10:06:40 -06:00
Mike Fleetwood e218ba3358 Refactor and rename GParted_Core::open/close_device_and_disk()
These functions in GParted_Core:
    open_device()
    open_device_and_disk()
    close_disk()
    close_device_and_disk()
call the following functions in the libparted API:
    ped_device_get()
    ped_disk_new()
    ped_disk_destroy()
    ped_device_destroy()
which don't open or close anything.  Instead they allocate and
deallocate PedDevice and PedDisk memory structures which describe block
devices and partition tables respectively.

Rename functions:
    open_device_and_disk()  -> get_device_and_disk()
    close_device_and_disk() -> destroy_device_and_disk()
and merge open_device() and open_device() as each only wrapped one
libparted function and was only called from a single place.
2013-03-25 10:06:39 -06:00
Mike Fleetwood 2b7e469473 Remove use of wipefs to clear file system signatures (#688882)
The wipefs command has the following significant limitations which were
worked around in previous commits:

1)  Wasn't available in the earliest distributions supported by GParted;

2)  Had to be called 3 times to erase vfat (fat16/32) signatures in all
    but the most recent versions.

This meant we had all the code to clear file system signatures without
using the wipefs command as well as extra complexity of using wipefs
too.  So just remove use of the wipefs command.

Bug #688882 - Improve clearing of file system signatures
2013-03-25 10:06:39 -06:00
Mike Fleetwood 6982f68e21 Workaround not so old wipefs only erasing 1 of 3 vfat signatures (#688882)
Before util-linux 2.21.0, released Feb 2012, wipefs only cleared one of
the three vfat (fat16/fat32) signatures it can be detected by each time
wipefs was run.  Also if a nilfs2 file system was created before all
three signatures were cleared the partition was still recognised as a
vfat file system, albeit a corrupted one, rather than as a nilfs2 file
system.

Old wipefs clearing vfat signatures:
    # wipefs --version
    wipefs from util-linux 2.20.1
    # wipefs -a /dev/sda7
    8 bytes were erased at offset 0x52 (vfat)
    they were: 46 41 54 33 32 20 20 20
    # wipefs -a /dev/sda7
    1 bytes were erased at offset 0x0 (vfat)
    they were: eb
    # wipefs -a /dev/sda7
    2 bytes were erased at offset 0x1fe (vfat)
    they were: 55 aa

New wipefs clearing vfat signatures:
    # wipefs --version
    wipefs from util-linux 2.21.2
    # wipefs -a /dev/sda12
    8 bytes were erased at offset 0x00000052 (vfat): 46 41 54 33 32 20 20 20
    1 bytes were erased at offset 0x00000000 (vfat): eb
    2 bytes were erased at offset 0x000001fe (vfat): 55 aa

Workaround by calling "wipefs -a" three times if the output indicated
only one vfat signature was cleared.

Bug #688882 - Improve clearing of file system signatures
2013-03-25 10:06:39 -06:00
Mike Fleetwood 3c75f3f5b1 Use wipefs to clear old signatures before creating new file systems (#688882)
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
2013-03-25 10:06:39 -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
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 52af838df2 Remove GParted_Core::fs (#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 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 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 ee49891611 Disallow resizing of LVM2 PVs which are members of exported VGs (#670171)
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
2012-08-30 13:47:46 -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
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 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 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
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
Joan Lledó ef37bdb7de Added support to lost data recovery using gpart 2011-01-29 14:58:02 -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 9bd8b14871 Create new method get_partition_path
This method will be used as an entry point to the libparted
function ped_partition_get_path
2010-08-17 10:36:00 -06:00
Curtis Gedak e62a23b5b5 Add partition alignment option to align to MiB (#617409)
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.
2010-05-20 10:00:14 -06:00
Curtis Gedak 896dab7192 Enhance copy_filesystem method to work with sector sizes
This change is in preparation for supporting sectors sizes > 512 bytes.
2010-04-26 11:43:59 -06:00
Curtis Gedak 74ecd2ed3f Set sector size and add to operation and dialog methods
This change is in preparation for supporting sectors sizes > 512 bytes.
2010-04-19 19:22:31 -06:00
Curtis Gedak 8fb40d843d Enhance copy methods for sector sizes > 512 bytes 2010-04-07 11:39:42 -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 301bd77312 Refactor some logic into separate settle_device method 2009-05-02 10:59:49 -06:00
Curtis Gedak eda5bf16aa Improved swap and dmraid mountpoint detection
svn path=/trunk/; revision=1097
2009-03-16 22:55:24 +00: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 2331bd0763 Added set and get thread status message methods.
Added thread status message updates in set_devices().

svn path=/trunk/; revision=943
2008-10-30 18:50:38 +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 7a413f6401 added libparted version string to details export.
* include/Dialog_Progress.h,
  include/GParted_Core.h,
  src/Dialog_Progress.cc,
  src/GParted_Core.cc,
  src/Win_GParted.cc: added libparted version string to details
  export.
2006-12-01 13:01:46 +00:00
Bart Hakvoort 5e2b8f9837 finally fixed problem with 'disappearing' devicenodes by using udevsettle
* include/GParted_Core.h,
  src/GParted_Core.cc: finally fixed problem with 'disappearing'
  devicenodes by using udevsettle (#352744)
2006-09-13 19:35:17 +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 79672a5298 make sure progressfraction stays between 0.0 and 1.0 implemented rollback
* 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 :)
2006-09-10 12:17:33 +00:00
Bart Hakvoort 59fe25882a declared char * buf global, so it can be initialized in copy_blocks().
* 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()
2006-09-08 09:33:02 +00:00
Bart Hakvoort f7ec213481 added test_overlap() perform a readonly testrun before the actual move if
* 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.
2006-09-07 20:31:05 +00:00
Bart Hakvoort bd4d110fdb parse /proc/partitions to find devices instead of using
* include/GParted_Core.h,
  src/GParted_Core.cc: parse /proc/partitions to find devices instead
  of using ped_device_probe_all()
2006-09-07 18:40:15 +00:00
Bart Hakvoort 7eb2a9cbb1 update ntfsbootsector after first sector has changed. This is necessary to
* 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
2006-09-04 19:18:44 +00:00
Bart Hakvoort 9cbfca1c6e check if dest >= src before starting a copy
* include/GParted_Core.h,
  src/GParted_Core.cc: check if dest >= src before starting a copy
2006-09-03 18:24:09 +00:00
Bart Hakvoort 95f563d13c more fixes related to moving..
* include/GParted_Core.h,
  src/GParted_Core.cc: more fixes related to moving..
2006-09-03 14:24:05 +00:00
Bart Hakvoort 34389f38e7 tried to fix a couple of errors with moving to the right with overlap
* 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 :)
2006-08-31 20:19:38 +00:00
Bart Hakvoort d23ca9d8ea ^) restructured resize_move() to be more robust. This will hopefully
* 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.
2006-08-27 08:41:25 +00:00
Bart Hakvoort 5060b1a07c improvements to probe and copy stuff.
* include/GParted_Core.h,
  src/GParted_Core.cc: improvements to probe and copy stuff.
2006-08-26 14:37:06 +00:00
Bart Hakvoort 649f26be9f fixed some issues with combi move+shrink on fat* and hfs* filesystems.
* 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.
2006-08-20 11:47:17 +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 8393f5ef6a created set_progress_info() (i actually planned on adding some time
* 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 ;) )
2006-08-15 18:33:56 +00:00
Bart Hakvoort 9576eb981e couple of cleanups in operationhandling and initalizing of p_filesystem.
* include/GParted_Core.h,
  src/GParted_Core.cc: couple of cleanups in operationhandling and
  initalizing of p_filesystem.
2006-08-13 13:31:57 +00:00
Bart Hakvoort ac53a7875f did some work on disabling of automounting of removable drives. The
* 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.
2006-08-09 19:20:20 +00:00
Bart Hakvoort b539a10ddc implemented some stuff to find a good blocksize to use for copy/move.
* 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.
2006-08-08 19:04:29 +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 8059d5f6d9 more work on moving/resizing sequence
* include/GParted_Core.h,
  src/GParted_Core.cc: more work on moving/resizing sequence
2006-07-23 16:51:38 +00:00
Bart Hakvoort f0d4890a92 added FIXME: decoupled libparted partition and filesystemresizing. This
* 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.
2006-07-23 09:58:45 +00:00
Bart Hakvoort dc883ee652 perform some checks before adding a new operation to the list. made
* 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
2006-07-20 19:14:44 +00:00
Bart Hakvoort cf59b71bf4 worked a bit on progressfeedback.. added FIXME
* include/GParted_Core.h,
  src/GParted_Core.cc: worked a bit on progressfeedback..
* include/Partition.h: added FIXME
2006-07-18 21:10:10 +00:00
Bart Hakvoort 8c5326e8b6 implemented snap to cylinder algorithm. Although the algorithm is very
* 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.
2006-07-17 20:54:41 +00:00
Bart Hakvoort 357e2d84bc lots of fixes and improvements (mostly move-related)
* lots of fixes and improvements (mostly move-related)
2006-07-11 18:13:27 +00:00
Bart Hakvoort b223e829ab renamed resize_partition to resize_move_partition to better reflect its
* include/GParted_Core.h,
  src/GParted_Core.cc: renamed resize_partition to
  resize_move_partition to better reflect its functionality.
2006-06-18 19:38:29 +00:00
Bart Hakvoort 8fecbac1d0 did more work on moving
* include/GParted_Core.h,
  src/GParted_Core.cc: did more work on moving
2006-06-18 19:27:52 +00:00
Bart Hakvoort afa792bf0c some more cleanups, should be finished now :)
* include/GParted_Core.h,
  src/GParted_Core.cc,
  src/Win_GParted.cc: some more cleanups, should be finished now :)
2006-06-18 08:50:17 +00:00
Bart Hakvoort 32dc8481c8 restructured the core a bit, over time it had become very messy.
* restructured the core a bit, over time it had become very messy.
2006-06-17 20:52:25 +00:00
Bart Hakvoort 2d7fb5700b more cleanups in the core and the fs'es (these changelogs are getting
* more cleanups in the core and the fs'es (these changelogs are
  getting boring ;^) )
2006-06-17 16:38:15 +00:00
Bart Hakvoort 08245cd08c cleanups in the core and the fs'es (resize)
* cleanups in the core and the fs'es (resize)
2006-06-17 14:44:17 +00:00
Bart Hakvoort 20d5650188 cleanups in the core and the fs'es (check/repair)
* cleanups in the core and the fs'es (check/repair)
2006-06-17 09:55:32 +00:00
Bart Hakvoort 682283ce89 cleanups in the core and the fs'es (create)
* cleanups in the core and the fs'es (create)
2006-06-17 08:56:24 +00:00
Bart Hakvoort b92ac20232 added movesupport, atm in experimental state and needs lots of cleaning.
* 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)
2006-05-31 20:03:49 +00:00
Bart Hakvoort 7ff0609962 made blocksize settable by the user.
* 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.
2006-05-27 19:51:55 +00:00
Bart Hakvoort 7bb7e8a84f Use ped_device_read and ped_device_write instead of 'dd' to copy
* 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 ;)
2006-05-23 21:17:34 +00:00
Bart Hakvoort 7f187d644c added column 'check' use halproperty 'storage.automount_enabled_hint'
* include/Dialog_Filesystems.h,
  src/Dialog_Filesystems.cc: added column 'check'
* include/GParted_Core.h,
  src/GParted_Core.cc: use halproperty
  'storage.automount_enabled_hint' instead of pmount to disable
  automounting.
2006-04-03 18:48:53 +00:00
Bart Hakvoort 3a918a337b improved disabling of automounting. It's still somewhat crude, but right
* 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
2006-04-02 21:26:27 +00:00
Bart Hakvoort 26da768ee0 an initial solution for the automount problem. I still need to add
* 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)
2006-04-02 18:03:37 +00:00
Bart Hakvoort e933473cfa added ufs filesystemclass
* include/Dialog_Filesystems.h,
  include/GParted_Core.h,
  include/Makefile.am,
  include/ufs.h,
  src/GParted_Core.cc,
  src/Makefile.am,
  src/ufs.cc: added ufs filesystemclass
2006-04-02 14:35:21 +00:00
Bart Hakvoort a044f0f88b let create_empty_partition() return a boolean instead of an integer.
* include/GParted_Core.h,
  src/GParted_Core.cc: let create_empty_partition() return a boolean
  instead of an integer.
2006-03-31 13:10:32 +00:00
Bart Hakvoort f5ea37e310 add 'flag management' (#330453)
* include/DialogManageFlags.h,
  include/GParted_Core.h,
  include/Makefile.am,
  include/Utils.h,
  include/Win_GParted.h,
  src/DialogManageFlags.cc,
  src/GParted_Core.cc,
  src/Makefile.am,
  src/Win_GParted.cc: add 'flag management' (#330453)
2006-03-31 10:49:27 +00:00
Bart Hakvoort 91c4ca2b45 fixed another minor memleak (yeah i'm playing with valgrind ;) )
* include/GParted_Core.h,
  src/GParted_Core.cc: fixed another minor memleak (yeah i'm playing
  with valgrind ;) )
2006-03-28 19:01:20 +00:00
Bart Hakvoort 99cebc81d3 lots of cleanups in operationhandling. This resulted in cleaner/less code
* lots of cleanups in operationhandling. This resulted in cleaner/less
  code and the fixing of some longstanding issues.
2006-03-24 19:08:41 +00:00
Bart Hakvoort ad9f2126e7 fixed issues with copying (see also #335004) cleanups + added FIXME added
* include/GParted_Core.h,
  src/GParted_Core.cc,
  src/Win_GParted.cc,
  src/ext2.cc,
  src/ext3.cc,
  src/fat16.cc,
  src/fat32.cc,
  src/jfs.cc,
  src/ntfs.cc,
  src/reiserfs.cc: fixed issues with copying (see also #335004)
* include/Operation.h,
  src/Operation.cc: cleanups + added FIXME
* include/Partition.h,
  src/Partition.cc: added clear_mountpoints()
* src/DrawingAreaVisualDisk.cc: added FIXME
2006-03-19 15:30:20 +00:00
Bart Hakvoort 6d8b169e73 changed the way devices and partitions store their devicepaths. Instead of
* 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)
2006-03-14 21:37:47 +00:00