Commit Graph

710 Commits

Author SHA1 Message Date
Karel Zak ec4b88b83d libfdisk: fix compiler warnings [-Wcast-qual]
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-23 11:39:13 +02:00
Karel Zak b9144a43c0 libfdisk: fix compiler warning [-Wmaybe-uninitialized]
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-18 10:00:18 +02:00
Karel Zak e6dfbd70ea libfdisk: reduce number of asprintf() calls, check return value
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-04 15:16:35 +02:00
KyleMahlkuch 7377518976 libfdisk: Fix multipath partition seperators for user-friendly names
The current code assumes "-part" is the only partition sepereator
but this is not true for some distros.

For example in Ubuntu 18.04 fdisk does not print the correct names for
mpatha:

~# ls -l /dev/mapper/mpatha*
lrwxrwxrwx 1 root root 7 Feb  1 04:39 /dev/mapper/mpatha -> ../dm-0
lrwxrwxrwx 1 root root 7 Feb  1 04:38 /dev/mapper/mpatha1 -> ../dm-4
lrwxrwxrwx 1 root root 7 Feb  1 04:38 /dev/mapper/mpatha2 -> ../dm-5
lrwxrwxrwx 1 root root 7 Feb  1 04:38 /dev/mapper/mpatha3 -> ../dm-6

~# fdisk -l /dev/mapper/mpatha
Device                   Boot     Start        End   Sectors  Size Id Type
/dev/mapper/mpatha-part1           2048  419432447 419430400  200G 83 Linux
/dev/mapper/mpatha-part2      419432448  838862847 419430400  200G 83 Linux
/dev/mapper/mpatha-part3      838862848 1258291199 419428352  200G 83 Linux

Instead of assuming a partition seperator of "-part" this patch uses
access to check the file system for a partition seperator of "p" or
the absense of a partition seperator. If neither of these work the patch
defaults to "-part" like we had before this patch.
2018-07-04 15:08:00 +02:00
Karel Zak 810b313688 libfdisk: use \x<hex> to read/write partition name
Addresses: https://github.com/karelzak/util-linux/issues/656
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-04 14:09:16 +02:00
Vaclav Dolezal bb09ebfe54 libfdisk: fix list_del after partition reset
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2018-05-09 17:29:32 +02:00
Karel Zak 01aec449f1 libfdisk: fix compiler warning [-Wunused-parameter]
Reported-by: L A Walsh <lkml@tlinx.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-05-03 10:40:37 +02:00
Karel Zak d881b77331 libfdisk: improve JSON output
* use fputs_quoted_json() for all data
* fix use of variables separator

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-04-05 12:38:22 +02:00
Karel Zak 314a214517 libfdisk: (docs) fix section name
The string "DOS (MBR)" generates filename with "(...)" which is
unacceptable by kernel.org stuff.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-03-21 15:49:32 +01:00
Karel Zak cd42d02ff2 libfdisk: (docs) update year
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-03-20 18:55:49 +01:00
Karel Zak ed930a9b89 libfdisk: fix docs warnings
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-21 13:23:08 +01:00
Karel Zak 9070c2e200 libfdisk: (docs) add missing docs blocks
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-21 13:12:12 +01:00
Karel Zak f92c9f3782 libfdisk: (docs) improve enums documentation
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-21 12:48:20 +01:00
Ruediger Meier 73afd3f8e8 misc: fix typos using codespell
Some more funny typos, please review carefully.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-02-16 11:12:52 +01:00
Ruediger Meier af1bc027db build-sys: remove redundant EXTRA_DIST files
The sources of AC_CONFIG_FILES (*.in) are automatically
distributed.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-01-22 11:16:49 +01:00
Ruediger Meier 4beacf105e build-sys: avoid using prog_DEPENDENCIES
Use EXTRA_prog_DEPENDENCIES to have the benefit
of automake's automatic prog_DEPENDENCIES.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-01-22 11:16:49 +01:00
Ruediger Meier 0da03d4490 build-sys: remove unneeded dependencies on bla.h.in
We have already automakes's automatic dependencies like
  bla.h.in -> bla.h -> foo.o -> bar.la

An explicit direct dependency bla.h.in -> bar.la
is redundant and useless anyways.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-01-22 11:16:49 +01:00
Ruediger Meier a459f2ec33 build-sys: automake is able to find headers in builddir ...
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-01-22 11:16:49 +01:00
Ruediger Meier 1d667d8849 build-sys: remove generated headers from dist tar ball
Headers should only be listed in either *_HEADERS or
*_SOURCES, especially when we want nodist_*_HEADERS.

Since all the generated headers are made by configure we
don't even need to use BUILT_SOURCES or other tricks.

Also see automake docs 9.4.1 Built Sources Example:
  case "Build bindir.h from configure"

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-01-22 11:16:49 +01:00
Karel Zak a15dca2f6d include/debug: introduce __UL_INIT_DEBUG_FROM_STRING()
Let's make it possible to use debug.h without environment variables.

Suggested-by: J William Piggott <elseifthen@gmx.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-17 13:58:29 +01:00
Karel Zak e92b6f68c4 libfdisk: (script) be consistent in code with types
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-12 12:04:16 +01:00
Karel Zak 6d00cfb233 include/debug: don't print pointer address for SUID programs
* introduce new flag __UL_DEBUG_FL_NOADDR to suppress pointer address printing

* use __UL_DEBUG_FL_NOADDR when SUID

* move ul_debugobj() to debugobj.h, and require UL_DEBUG_CURRENT_MASK
  to provide access to the current mask from ul_debugobj(). It's better
  than modify all ul_debugobj() calls and use the global mask as
  argument.

* remove never used UL_DEBUG_DEFINE_FLAG

Reported-by: halfdog <me@halfdog.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-12 11:01:26 +01:00
Karel Zak 9c76f85f9a libfdisk: allow to start freespace for zero
This is necessary for disk labels like SUN where whole disk is possible
to address by partitions.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-11 15:18:00 +01:00
Karel Zak f7606d2d9f libfdisk: (sun) fix n-1 bug and whole-disk
* set whole_disk variable if SUN_TAG_WHOLEDISK specified
* fix N-1 bug in add new partition according to template (script)

Addresses: https://github.com/karelzak/util-linux/issues/555
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-11 14:23:57 +01:00
Karel Zak 6ebc37854d libfdisk: (script) support R (RAID) and V (LVM) shortcuts
Addresses: https://github.com/karelzak/util-linux/issues/560
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-09 12:12:50 +01:00
Karel Zak af846e1ff9 libfdisk: (gpt) add VMware specific UUIDs
Addresses: https://github.com/karelzak/util-linux/issues/559
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-08 12:43:22 +01:00
Karel Zak 280b975475 libfdisk: (dos) fix max heads
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-02 16:50:31 +01:00
Karel Zak 2dd2880f12 libfdisk: extend API to provide label specific geometry ranges
Now fdisk provides DOS specific geometry ranges in expert menu.

Addresses: https://github.com/karelzak/util-linux/issues/556
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-02 16:43:22 +01:00
Karel Zak 760942e284 libfdisk: (gpt) use fdisk_warn() for failed name setting
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-20 12:31:10 +01:00
Vaclav Dolezal c116524184 libfdisk: return bytes processed from gpt_entry_set_name(), process rc
Made gpt_entry_set_name() return number of utf8 bytes processed on
success, so info message about change can be accurate.

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2017-12-19 10:48:13 +01:00
Vaclav Dolezal f069f6fe69 libfdisk: allocate enough bytes for ucs2 to utf8 encoding
Allocate 3*number_of_ucs2_characters bytes for utf8 output.

Also as we are using calloc there's no need to write terminating null
byte.

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2017-12-18 16:18:44 +01:00
Vaclav Dolezal 5be3df4afd libfdisk: gpt: properly encode string on rename
GPT partition name entry should be recorded as little endian UCS2, so I have
written proper conversion (assuming UTF8 input).

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2017-12-18 16:17:49 +01:00
Sami Kerola fcf841f8d3 misc: fix typos
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-28 14:39:13 +01:00
Mikhail Vorobyov 9e6ccaab5b libfdisk: (sun) enhance searching of free space
Potential partition start should be aligned to cylinders. So fdisk
wouldn't consider partition's last cylinder remains as eligible space
for new partition start.
2017-11-16 14:11:19 +01:00
Mikhail Vorobyov 45ce148778 libfdisk: (sun) move aligning of the first sector before availability check
So it will check a sector which would be actualy used as the first sector
of the partition.
2017-11-16 14:11:10 +01:00
Karel Zak 9a8a3b88dc libfdisk: (gpt) move backup header after device resize
Addresses: https://github.com/karelzak/util-linux/issues/532
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-14 13:51:48 +01:00
Roddy Shuler cfe4691c6f libfdisk: Fix uninitialized structure
Without this, 'sfdisk -d' with certain filenames would lead to
reading an 's' from the 'type' field in fdisk_reset_labelitem
and cause a crash due to prematurely freeing the 'data.str' field.

Signed-off-by: Roddy Shuler <roddy@endlessm.com>
2017-11-02 21:22:51 -07:00
Mikhail Vorobyov 27895be260 libfdisk: (sun) fix creation of whole disk partition
sun_add_partition() allowed the 1st sector to be 0 for the 3rd partition
only if that sector was free or if other partitions covered the whole
disk. Now it's always allowed for the 1st sector to be set to 0 for
the 3rd partition.

[kzak@redhat.com: - print info about "wholedisk" before "First sector" dialog for 3rd partition
                  - default to 0 for 3rd partition start sector]

Signed-off-by: Mikhail Vorobyov <m.vorobyov@cs.msu.ru>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-02 10:43:27 +01:00
Karel Zak e163adb83b build-sys: fix non-blkid compilation
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-19 13:48:52 +02:00
Karel Zak 9f20d80079 misc: cleanup UUID_STR_LEN definitions
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-15 13:25:32 +02:00
Philip Prindeville b443c1779e misc: replace magic number 37 with UUID_STR_LEN
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2017-09-05 11:49:21 +02:00
Vaclav Dolezal 504c594777 libfdisk: fix fdisk_reset_partition() leaking *_chs strings.
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2017-08-24 11:23:44 +02:00
Vaclav Dolezal 5cebb2ab33 libfdisk: fix two potential memory errors.
Fixes one leak and one unchecked allocation error.

[kzak@redhat.com: - don't call fdisk_ask_menu_get_result()
                    after failed fdisk_do_ask()]

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-08-24 11:21:59 +02:00
Karel Zak b428eb14a8 libfdisk: improve alignment debug mesagges
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-08-22 15:12:36 +02:00
Karel Zak 27c284b848 libfdisk: add --grain to mkpart sample
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-08-22 14:59:42 +02:00
Karel Zak adf09b5c38 libfdisk: add fdisk_save_user_grain()
Let's provide API for applications that don't want to use the default
1MiB grain. The new function allow to use "as minimal as possible" if
grain is set by fdisk_save_user_grain() to 512.

If the phy sector size (or minimal I/O size) is greater than specified
grain size than smallest possible setting is used.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-08-22 14:55:51 +02:00
Karel Zak 980cc4a182 libfdisk: (dos) use size-=1 when alignment not used later
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-08-22 14:54:27 +02:00
Karel Zak 1573e95514 libfdisk: improve "add partition" debug message
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-08-22 14:53:18 +02:00
Karel Zak 694a407de9 libfdisk: (gpt) fix size-1 error
If partition does not require alignment, then don't call LBA align
function and don't use size-=1 (fdisk_align_lba_in_range() returns
unmodified size and we call size=-1 more than once for the same size).

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-08-22 14:48:14 +02:00
Karel Zak dd3b72b3e9 libfdisk: add --nopartno to mkpart sample
* disable dialogs for the mkpart sample
* add --nopartno use-case to force libfdisk to use default partno(s)
* add test for this feature

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-08-01 13:51:27 +02:00
Karel Zak 537b4db151 libfdisk: allow to resize in unsorted partition table
The current code assumes that partition offsets (starts) are sorted.
This is usual situation, but unsorted partition table is also valid...

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-19 15:09:36 +02:00
Karel Zak 264ef9875a libfdisk: improve table print debugs
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-19 15:09:12 +02:00
Karel Zak ea36907965 libfdisk: support default partno in mkpart-fullspec sample
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-19 12:19:38 +02:00
Karel Zak 992f7cbae4 libfdisk: add fdisk_disable_dialogs()
The default (for historical reasons) is to use dialog driven partitioning.
It's possible to avoid dialogs by fdisk_partition template for
fdisk_add_partition().

Unfortunately in some case (mostly DOS driver) it's not enough, because
we need to distinguish between logical and primary partitions. If we know
that dialogs are unwanted then we can default to primary partition, etc.

This function simplify semantic of the library for non-interactive
programs.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-19 11:30:57 +02:00
Karel Zak e5e704630f libfdisk: (dos) return EINVAL when delete unused partition
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-19 10:34:03 +02:00
Ruediger Meier 18751601a8 libfdisk: fix warning -Wunused-function
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-07-18 11:08:28 +02:00
Ruediger Meier 21be08ac8c build-sys: don't use non-existing UUID_LIBS
We've added UUID_LIBS in f77a4d1087 but I don't see what it
was good for.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-07-18 11:06:53 +02:00
Ruediger Meier ac6a6b0d3c libfdisk: use fdisk_sector_t consistently and fix printf format strings
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-07-18 11:06:53 +02:00
Karel Zak 5ecd618511 libfdisk: use BLKPG_* ioctls on linux only
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-17 09:47:42 +02:00
Karel Zak 8ffa3b651d libfdisk: make fdisk compliant to UEFI/GPT specification on PMBR
The PMBR partition record should be StartingCHS=0x002000 (0/0/2)
and EndingCHS=0xFFFFFF (1023/255/63)

Addresses: https://github.com/karelzak/util-linux/issues/485
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-14 12:48:18 +02:00
Karel Zak c0eabc5382 libfdisk: remove whitespaces
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-14 11:36:22 +02:00
Karel Zak 1dd63a3b05 libfdisk: use BLKPG ioctls to inform kernel about changes
This patch introduces fdisk_reread_changes(). The function is
less invasive alternative to fdisk_reread_partition_table().

The new function uses BLKPG ioctls for modified partitions. The
another partitions are not affected. This solution allows to
successfully use fdisks on disk where some partitions are still use
(mounted). For example if you want to resize the last partition on the
device.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-14 11:34:55 +02:00
Karel Zak 0d034857f2 libfdisk: add comment
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-14 11:34:55 +02:00
Karel Zak b9da153254 libfdisk: add fdisk_device_is_used()
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-14 11:34:55 +02:00
Karel Zak 2db3cc4cf3 libfdisk: remove unnecessary fstat() call
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-14 11:33:30 +02:00
Karel Zak 6a1889b03b libfdisk: move fdisk_reread_partition_table() to another file
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-14 11:33:30 +02:00
Karel Zak 288acb4eee tests: don't use errno in output
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-12 12:34:22 +02:00
Karel Zak 167d7e9537 libfdisk: (dos) accept start for log.partitions on template
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-11 14:24:32 +02:00
Karel Zak f2b6a0c0f5 libfdisk: don't hardcode label type in samples
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-11 13:27:01 +02:00
Karel Zak 5fb427c8d2 libfdisk: add sample-fdisk-mkpart-fullspec
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-11 13:00:46 +02:00
Karel Zak 2cb4754276 libfdisk: (dos) cleanup template based partitioning
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-11 12:25:02 +02:00
Karel Zak 2469ba3677 libfdisk: add fdisk_reassign_device()
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-07-10 12:32:26 +02:00
Karel Zak c134c8b101 libfdisk: support logical partition resize
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-19 16:03:41 +02:00
Karel Zak 5ec4400dec libfdisk: allow to resize container
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-19 15:32:02 +02:00
Karel Zak 22f4c4641a libfdisk: add more debug messages to get-last-possible resize space
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-19 15:27:05 +02:00
Karel Zak 53625d1ae9 libfdisk: (dos) be more verbose on partno -ERANGE error
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-19 14:32:59 +02:00
Karel Zak ee9ba4fa5e libfdisk: (dos) fix primary/logical logic when follow template
This stupid bug has been introduced by e1cfb304 (v2.30) and it
disables to create extended partition by cfdisk :-(

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-19 11:41:02 +02:00
Sami Kerola 1b5042636f misc: fix reassigned values before old ones has been used [cppcheck]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-06-14 12:19:20 +02:00
Ruediger Meier 92e486f80e libfdisk: fix guid usage of packed struct gpt_entry
clang issued warnings like this:

../libfdisk/src/gpt.c:371:18: warning: taking address of packed member 'type' of class or structure 'gpt_entry' may result in an unaligned pointer value [-Waddress-of-packed-member]
        guid_to_string(&e->type, str);
                        ^~~~~~~

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-13 23:38:48 +02:00
Ruediger Meier 7f387c5c21 libfdisk: cleanup sun label checksum usuage
We are using now the formerly unused function sun_pt_checksum(). This
cleanup was motivated by clang compiler warning, see below. Also nice
that we are now always using uint16_t instead of short.

Warning was:

../libfdisk/src/sun.c:177:35: warning: taking address of packed member 'csum' of class or structure 'sun_disklabel' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
                while(ush < (unsigned short *)(&sunlabel->csum))

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-13 18:06:36 +02:00
Karel Zak 7dec8dfeca Merge branch 'master' of https://github.com/yurchor/util-linux
* 'master' of https://github.com/yurchor/util-linux:
  Fix minor typos
2017-06-02 11:13:39 +02:00
Ruediger Meier c0d7b11a3f build-sys: fix library order when linking
We got some errors on Alpine Linux where $LTLIBINTL is non-empty:

./.libs/libcommon.a(libcommon_la-blkdev.o): In function `open_blkdev_or_file':
lib/blkdev.c:282: undefined reference to `libintl_gettext
collect2: error: ld returned 1 exit status

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-01 03:16:48 +02:00
Sami Kerola 2e2cfdae79 libfdisk: fix variable shadowing
libfdisk/src/context.c: In function 'fdisk_assign_device':
libfdisk/src/context.c:549:7: warning: declaration of 'rc' shadows a previous local [-Wshadow]
libfdisk/src/context.c:542:10: note: shadowed declaration is here

[kzak@redhat.com: - add rc to debug message]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-29 12:18:08 +02:00
Yuri Chornoivan 0508f347c8 Fix minor typos 2017-05-24 00:22:20 +03:00
Karel Zak f854eca369 libfdisk: update docs
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-23 14:22:04 +02:00
Karel Zak 8d3e3e6b4d libfdisk: (docs) add missing 'since' tags
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-23 14:02:14 +02:00
Karel Zak 199f8cd3b5 libfdisk: don't use errno after close()
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-17 12:43:48 +02:00
Karel Zak 274e6f6f8f libfdisk: use memcpy() for non-terminated string [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-17 12:29:50 +02:00
Karel Zak 3fdbf0ee09 libfdisk: initialize partno variable [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-17 12:28:07 +02:00
Karel Zak 0a48e2370d libmount: check fstat() return code [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-17 12:28:07 +02:00
Karel Zak 059ad53815 libfdisk: don't print uninitialized variable [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-17 12:28:07 +02:00
Karel Zak 29f2e825d8 libfdisk: add fdisk_partition_has_wipe()
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-09 14:30:02 +02:00
Karel Zak 7095232d21 libfdisk: fix NLS support
The current libfdisk code uses gettext() to translate strings. It
means it follows the default text domain (as set by textdomain(3)
usually in the main program). This is useless for public shared
library.

We have call private bindtextdomain() and use dgettext() with private
domain name to be independent on the main program. For this purpose
include/nls.h supports UL_TEXTDOMAIN_EXPLICIT to use dgettext().

Note that libfdisk will continue to use util-linux.po, rather than
keep the texts in the separate file.

The nls.h has to be included only from fdiskP.h to be sure that
nls.h works as expected for the library.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-25 17:05:09 +02:00
Karel Zak 02a376f2ee libfdisk: (gpt) rename to gpt_entry_is_used()
The current function name is inconsistent with the rest of the code.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-19 14:00:07 +02:00
Pavel Butsykin e6b4209d95 libfdisk: allow to change an existing extended partition
Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
2017-04-19 10:25:39 +02:00
Ruediger Meier c8df4b17d4 misc: fix some printf format strings
Fix compiler warnings seen on Linux/i586 and OSX/travis.

  #type            #format   #cast
   unsigned long    %lu       -
   uint64_t         PRIu64    -
   fdisk_sector_t   %ju       (uintmax_t)

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-04-10 15:40:58 +02:00
Karel Zak 52f35f1ecc libfdisk: (gpt) fix ents zeroize
The gpt->ents is "unsigned char" buffer now. We need to use bytes, no
number of entries...

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-06 13:39:44 +02:00
Karel Zak bbb574a293 libfdisk: (gpt) update nparts_max
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-06 13:04:09 +02:00
Karel Zak a8294f401f libfdisk: (gpt) care about SSIZE_MAX for read(2)
read(2) behavior is undefined if you want to read more  than SSIZE_MAX
bytes. Let's be paranoid and check for this...

Reported-by: Ruediger Meier <sweet_f_a@gmx.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-06 12:13:46 +02:00
Karel Zak 9e320545bb libfdisk: (gpt) make entries array size calculation more robust
* use the same function everywhere
* keep calculation based on size_t

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-05 18:40:56 +02:00