Commit Graph

25 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 d04826cc27 Use realpath() safely (#764369)
realpath(3) manual page says:

    BUGS
        The POSIX.1-2001 standard version of this function is broken by
        design, since it is impossible to determine a suitable size for
        the output buffer, resolved_path.  According to POSIX.1-2001 a
        buffer of size PATH_MAX suffices, but PATH_MAX need not be a
        defined constant, and may have to be obtained using pathconf(3).
        And asking pathconf(3) does not really help, since, on the one
        hand POSIX warns that the result of pathconf(3) may be huge and
        unsuitable for mallocing memory, and on the other hand
        pathconf(3) may return -1 to signify that PATH_MAX is not
        bounded.  The resolved_path == NULL feature, not standardized in
        POSIX.1-2001, but standardized in POSIX.1-2008, allows this
        design problem to be avoided.

The resolved_path == NULL feature of realpath() has existed as a Glibc
extension since realpath() was first added to Glibc 1.90, released in
June 1996.  Therefore it can be used unconditionally.

    https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=fa0bc87c32d02cd81ec4d0ae00e0d943c683e6e1

Bug 764369 - Use realpath() safely
2016-04-07 10:05:40 -06:00
Mike Fleetwood 1b55dfad5b Move DEV_MAPPER_PATH from DMRaid.h to Utils.h (#760080)
Renamed from DEV_MAP_PATH to DEV_MAPPER_PATH.  Moved so that the
constant is logically intended for use outside of the DMRaid class.

Also specifically make the string constant have external linkage, rather
than the default internal (static) linkage for constants, so that there
is only one copy of the variable in the program, rather than one copy in
each compilation unit which included DMRaid.h.  Namely DMRaid.cc and
GParted_Core.cc.

References:
[1] Proper way to do const std::string in a header file?
    http://stackoverflow.com/questions/10201880/proper-way-to-do-const-stdstring-in-a-header-file
[2] What is external linkage and internal linkage in C++
    http://stackoverflow.com/questions/1358400/what-is-external-linkage-and-internal-linkage-in-c/1358796#1358796

Bug 760080 - Implement read-only LUKS support
2016-01-29 13:41:40 -07:00
Mike Fleetwood 48d898ebfd Include Partition.h header everywhere it's used
Lots of files which use the Partition class relied on the declaration
being included via other header files.  This is bad practice.

Add #include "Partition.h" into every file which uses the Partition
class which doesn't already include it.  Header file #include guards are
specifically to allow this.
2016-01-26 10:11:35 -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
Curtis Gedak f768cbd1b4 Fix ignoring return value compiler warnings
Add code to handle situation where realpath might return a NULL value.
Prior to this change the compiler would complain with the following
message:

error: ignoring return value of ‘char* realpath(const char*, char*)’,
declared with attribute warn_unused_result
2011-07-18 13:31:54 -06:00
Curtis Gedak 87acba030c Remove all usage of kpartx to avoid partition entry duplicates
Usage of the kpartx package to create partition names has been
completely removed.  Hence kpartx is no longer even an optionally used
package by gparted.

This change is related to the following bug report:

Ubuntu launchpad bug 719129 - [Natty] Gparted duplicates dmraid
                              partition devices
https://bugs.launchpad.net/ubuntu/+source/gparted/+bug/719129
2011-02-22 14:40:02 -07:00
Curtis Gedak cf68fc0704 Enable to work with new dmraid and parted without dmraid support
Newer versions (dmraid-1.0.0-rc16?) of dmraid default to always
creating partition names by inserting the letter 'p' between the
device name and the partition number.  Since this is not
consistent with older versions of dmraid, add extra logic to
ensure that newer versions of dmraid do not insert this extra
letter 'p'.

Rename method get_udev_name to get_udev_dm_name and enhance to
retrieve the property DM_NAME.

Handle situation where parted, and hence libparted, has been
configured with --disable-device-mapper.  In this situation on
some distros the device name could be /dev/dm-0.  This results in
invalid partition names such as /dev/dm-0p1.  Add logic to decode
the actual /dev/mapper name.
2010-08-25 10:33:02 -06:00
Curtis Gedak c55a8de305 Remove dependency on kpartx for fake RAID support
With this patch the commands required to support motherboard BIOS
RAID, also known as fake RAID, are dmraid and dmsetup.

If the kpartx command is available, it will be used to maintain
device entries that follow the naming convention used by kpartx.

Closes Ubuntu launchpad bug 554582 - GParted does not list dmraid
devices
https://bugs.launchpad.net/ubuntu/+source/gparted/+bug/554582
2010-08-17 10:36:00 -06:00
Curtis Gedak 73e7f85a2f Create new method make_path_dmraid_compatible
This method will be used to ensure that the partition path
matches the name that would be created by the dmraid command.
2010-08-17 10:36:00 -06:00
Curtis Gedak cf4a962c73 Further improve dmraid device and name recognition 2009-10-14 11:09:23 -06:00
Curtis Gedak fa0b88c701 Improve logic for retrieval of device udev name 2009-09-30 16:25:19 -06:00
Curtis Gedak 78c3174694 Improve logic to recognize dmraid devices 2009-09-30 16:16:27 -06:00
Curtis Gedak d63c97ef42 Simplify logic to ensure dmraid_devices cleared before populating 2009-09-30 16:08:03 -06:00
Curtis Gedak 2a89d936d6 Remove get_dmraid_prefix method used to specify a single device
It appears that different dmraid versions handle specifying a
single dmraid device differently.

dmraid-1.0.0.rc14 uses a partial name only,
  such as "isw" or "isw_cjbdddajhi".
dmriad-1.0.0.rc15 uses a full name only,
  such as "isw_cjbdddajhi_Vol0".

To maintain compatibility with the broadest range of dmraid versions,
the ability to specify a single dmraid device is being removed.
2009-04-29 16:34:30 -06:00
Curtis Gedak 3f773c3ae8 Ensure kpartx is executed even if dmraid fails 2009-04-29 16:23:28 -06:00
Curtis Gedak 301f58c977 Remove temporary debugging information accidentally committed 2009-04-28 14:23:09 -06:00
Curtis Gedak 58c9336e9d Enhance get_dmraid_name to also check udev information if needed 2009-04-28 14:21:56 -06:00
Curtis Gedak 9816f5c18a Refactor some logic into separate get_udev_name method 2009-04-28 13:42:47 -06:00
Curtis Gedak 63980c0def Minor style change to place braces on a separate line 2009-04-27 15:17:45 -06:00
Curtis Gedak ce4de8b51e Improve dmraid device detection with checking udev if needed
Some distros appear to display /dev/dm-# device names with
libparted.  Since this fails a pattern match with the dmraid
device name, check with udev to see if a pattern match is
possible with the name returned from udevinfo or udevadm info.

For example:
     /dev/mapper/isw_cjbdddajhi_Vol0 is the device name
     /dev/dm-0 is a symbolic link pointing to the above device name
2009-04-26 16:45:53 -06:00
Curtis Gedak 6e287d1911 Updated translation and code comments
svn path=/trunk/; revision=1110
2009-03-27 16:58:31 +00:00
Curtis Gedak 5b9183ca26 Fixed error when resizing an extended partition
svn path=/trunk/; revision=1104
2009-03-23 18:51:33 +00:00
Curtis Gedak 946b462757 Enhanced dmraid partition deletion
svn path=/trunk/; revision=1098
2009-03-16 22:59:50 +00:00
Curtis Gedak 5865c92dc0 Added new class for dmraid support
svn path=/trunk/; revision=1092
2009-03-14 20:02:41 +00:00