Commit Graph

30 Commits

Author SHA1 Message Date
Mike Fleetwood 8979913a3f Remove "../include/" from GParted header #includes
It made the code look a little messy, is easily resolved in the build
system and made the dependencies more complicated than needed.  Each
GParted header was tracked via multiple different names (different
numbers of "../include/" prefixes).  For example just looking at how
DialogFeatures.o depends on Utils.h:

    $ cd src
    $ make DialogFeatures.o
    $ egrep ' [^ ]*Utils.h' .deps/DialogFeatures.Po
     ../include/DialogFeatures.h ../include/../include/Utils.h \
     ../include/../include/../include/../include/../include/../include/Utils.h \
     ../include/../include/../include/Utils.h \

After removing "../include/" from the GParted header #includes, just
need to add "-I../include" to the compile command via the AM_CPPFLAGS in
src/Makefile.am.  Now the dependencies on GParted header files are
tracked under a single name (with a single "../include/" prefix).  Now
DialogFeatures.o only depends on a single name to Utils.h:

    $ make DialogFeatures.o
    $ egrep ' [^ ]*Utils.h' .deps/DialogFeatures.Po
     ../include/DialogFeatures.h ../include/Utils.h ../include/i18n.h \
2016-12-12 13:15:34 -07:00
Mike Fleetwood 1dc8a0c628 Rename Device::add_path() to set_path() (#767842)
To reflect that there is only a single path in the Device object now.
Also get rid of the now unneeded optional parameter which was only
relevant when there was a vector of paths.

Bug 767842 - File system usage missing when tools report alternate block
             device names
2016-08-06 09:47:58 -06:00
Mike Fleetwood 902afaa010 Simplify Device object to a single path (#767842)
Background

GParted stored a list of paths for Device and Partition objects.  It
sorted this list [1][2] and treated the first specially as that is what
get_path() returned and was used almost everywhere; with the file system
specific tools, looked up in various *_Info caches, etc.

[1] Device::add_path(), ::add_paths()
[2] Partition::add_path(), ::add_paths()

Mount point display [3] was the only bit of GParted which really worked
with the path list.  Busy file system detection [4] just used the path
provided by libparted, or for LUKS /dev/mapper/* names.  It checked that
single path against the mounted file systems found from /proc/mounts,
expanded with additional block device names when symlinks were
encountered.

[3] GParted_Core::set_mountpoints() -> set_mountpoints_helper()
[4] GParted_Core::set_device_partitions() -> is_busy()
    GParted_Core::set_device_one_partition() -> is_busy()
    GParted_Core::set_luks_partition() -> is_busy()

Having the first path, by sort order, treated specially by being used
everywhere and virtually ignoring the others was wrong, complicated to
remember and difficult code with.  As all the additional paths were
virtually unused and made no difference, remove them.  The "improved
detection of mountpoins, free space, etc.." benefit from commit [5]
doesn't seem to exist.  Therefore simplify to a single path for Device
and Partition objects.

[5] commit 6d8b169e73
    changed the way devices and partitions store their device paths.
    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..

This patch

Simplify the Device object from a vector of paths to a single path.
Remove add_paths() and get_paths() methods.  Keep add_path() and
get_path() for now.

Bug 767842 - File system usage missing when tools report alternate block
             device names
2016-08-06 09:47:58 -06:00
Mike Fleetwood fae909897e Use PartitionVector class throughout the code (#759726)
Replace all occurrences of std::vector<Partition> with PartitionVector.

Bug 759726 - Implement Partition object polymorphism
2016-01-26 10:11:35 -07:00
Mike Fleetwood 4b72ecd44e Display device serial numbers (#751251)
Run "hdparm -I /dev/DISK" to get the hard drive serial number of
every device which has one and display it in the Device Information.
The displayed value can either be the actual serial number, "none" or
blank.  "none" means the device doesn't have a hard drive serial number,
such as for Linux software RAID arrays, BIOS fake RAID arrays or USB
flash drives.  Blank means something went wrong getting the serial
number.  Either it couldn't be found in the hdparm output or the hdparm
command wasn't installed.

Example real hard drive:
    # hdparm -I /dev/sda
    ...
    ATA device, with non-removable media
            Model Number:       SAMSUNG HM500JI
            Serial Number:      S1WFJDSZ123732
    ...

Example Linux software RAID array:
    # hdparm -I /dev/md127

    /dev/md127:
     HDIO_DRIVE_CMD(identify) failed: Inappropriate ioctl for device

On my desktop with 4 internal hard drives 2 Linux software RAID arrays
on those hard drives, 2 USB flash drives and 1 USB hard drive attached,
running hdparm 9 times added 0.07 seconds to the device refresh time.

Bug 751251 - Show serial number in device information
2015-07-01 10:22:47 -06:00
Mike Fleetwood 90e3ed68fc Shallow copy Device object into Operation object (#750168)
When Operation objects are created they take a copy of the Device object
to which the operation is to be applied.  The Device object includes a
vector of all the contained Partition objects currently on the device,
so these get copied too.

These additional deep copied Partition objects in the Operation object
are never accessed.  Therefore don't copy the contained Partition
objects when copying the Device object into the Operation object.

Bug 750168 - Reduce the amount of copying of partition objects
2015-06-10 10:44:33 -06:00
Mike Fleetwood 9b2c95bcd1 Make support of naming for other partition table types possible (#746214)
Previously partition naming had only been implemented for gpt.  Make the
code ready to support naming of the other partition table types for
which libparted supports naming.  Specifically: amiga, dvh, mac and
pc98 in addition to gpt.  Document issues found with some of these
partition table types, which can relatively easily been worked around.

Leave support of naming for partition table types other than gpt
disabled, mostly just to reduce ongoing testing effort, at least until
there is any user demand for it.

Bug 746214 - Partition naming enhancements
2015-03-25 10:02:42 -06:00
Michael Zimmermann 1f5841b4ad Add support for GPT partition names (#741424)
Embedded devices (Android) use GPT partition names to identify
partitions, instead of file system labels.  Add support for viewing and
changing them.

As partition names are used to provide unique identification they are
never copied when copying the contents of one partition to another.

Note that GNU/Linux uses file system labels, UUIDs or device names for
identification during the boot process and afterwards so while partition
names can be used, they are optional and purely for user information.

Bug 741424 - Add support for GPT partition names
2015-02-01 10:08:23 -07: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
Curtis Gedak 19d8f0dfc8 Add sector size to device display pane
Also add sector_size to Device class.  This is the start of an
enhancement to add support for devices with sector sizes other
than 512 bytes (#607165).
2010-02-20 15:12:26 -07:00
Bart Hakvoort 8d2e7dd26d replaced 'long' with 'Sector' to prefent overflows with really large
* include/Device.h,
  include/Dialog_Base_Partition.h,
  src/Dialog_Base_Partition.cc: replaced 'long' with 'Sector' to
  prefent overflows with really large devices.
2006-12-08 13:14:05 +00:00
Bart Hakvoort 1906a3ece8 overloaded == and != cleanups
* include/Device.h,
  src/Device.cc: overloaded == and !=
* src/Win_GParted.cc: cleanups
2006-03-15 21:44:24 +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
Bart Hakvoort 391ca32a2b in some places i still used MiB's instead of sectors to store sizes. this
* in some places i still used MiB's instead of sectors to store sizes.
  this has been fixed everywhere. Only the spinbuttons still use
  MiB's. I have a few ideas on how to solve this, but i'll take it up
  with #usability first.
2006-02-25 10:09:30 +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 7052e18d79 replaced 'device_partitions' with 'partitions' use new Device::partitions
* 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.
2006-01-05 20:01:34 +00:00
Bart Hakvoort e5d2cb0eb7 Removed the ugly Get_Highest_Logical_Busy() from Device and added a
* include/Device.h,
  src/Device.cc,
  src/GParted_Core.cc,
  src/Win_GParted.cc: Removed the ugly Get_Highest_Logical_Busy() from Device and added a classvariable instead. This one is set in
  GParted_Core and used wherever needed. I also removed Device::busy, and used the new variable to check if a device is busy.
2004-12-27 18:56:57 +00:00
Bart Hakvoort 174f0cff77 Added cylsize to Device and made Operation contain a Device instead of
* Added cylsize to Device and made Operation contain a Device instead of only the path and lenght.
  This way i was able to dump Get_Cyl_Size in the Core. Besides that, i used cylsize in WinGparted and made a lot of
  cosmetic changes. Most of them were pretty useless, but hey, i'm bored ;)
2004-12-27 12:08:01 +00:00
Bart Hakvoort 286579d578 Every devicescan now tests on beforehand if the kernel is able to reread
* Every devicescan now tests on beforehand if the kernel is able to reread the partitiontable. If the kernel is unable to do
  this, i disallow most operations. This may seem weird and even a bad thing to do, but the fact is it protects
  the innocent user from a lot of potential damage. Till the linuxkernel is able to reread partitiontables no matter what, this seems
  to be the best option. Of course a dialog with information will popup whenever such a situation is encountered.
  In a next release i might consider adding an 'advanced mode' for users who know what they're doing.
2004-11-29 13:20:05 +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 4438e3264e Removed bool Get_Any_Busy() in favor of public bool busy which is set in
* include/Device.h,
  src/Device.cc: Removed bool Get_Any_Busy() in favor of public bool busy which is set in gparted_core.
  This also fixed a small bug with incorrect mountdetection of logical partitions.
  Also added a Reset() function to properly reset the contents of a device. to zero/empty .
* include/GParted_Core.h,
  src/GParted_Core.cc: 'busyness' of a device is now determined in get_devices().
  Renamed get_partitions() to set_device_partitions to reflect its proper function.
  When a new partition is created to contain a copied filesystem the size is now properly set. This fixes
  a very annoying bug which no one knew about except for me =) .
* src/Win_GParted.cc: use boolean busy from device instead of Get_Any_Busy() .
2004-11-19 11:55:38 +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
Bart Hakvoort 24dccdd8f3 instead of listing all partition in one list, logical partitions are now
* instead of listing all partition in one list, logical partitions are now stored in a sublist in extended partition object.
This makes partitionhandling in gparted more natural and transparant. It also allowed me to clean up this ugly Operation class ;)
2004-11-06 11:55:03 +00:00
Bart Hakvoort 9c328738c9 made 'deep-scan' optional in Read_Disk_Layout. Removed obsolete (already)
* include/Device.h,
  src/Device.cc: made 'deep-scan' optional in Read_Disk_Layout. Removed obsolete (already) commented function.
* include/Partition.h,
  src/Partition.cc: Took used sectors out of Set() and added a Set_Used() function instead. Also added Reset() .
* src/Dialog_Partition_New.cc: minor change to make use of the new Set() in Partition..
* include/Win_GParted.h,
  src/Win_GParted.cc: show pulsing progressbar while refreshing devices.
2004-10-11 10:23:24 +00:00
Bart Hakvoort 18b47725f8 enabled support for reiserfs 2004-10-06 15:32:40 +00:00
Bart Hakvoort d57a8eced7 removed unnecessary headerfiles 2004-10-02 13:18:25 +00:00
Bart Hakvoort 72f91cbc39 removed all stringstreams from the project (they were possibly responsible
* removed all stringstreams from the project (they were possibly responsible for rare chrashes in certain locales)
2004-10-02 09:39:16 +00:00
Bart Hakvoort a1dfbee2b3 cosmetics (mostly tabfixes)
* almost all files: cosmetics (mostly tabfixes)
2004-10-01 21:09:19 +00:00
Bart Hakvoort 26d433260d Initial revision 2004-09-19 20:24:53 +00:00