Commit Graph

511 Commits

Author SHA1 Message Date
Sebastian Rasmussen 9e93004171 misc: Fix various typos
Fix various typos in error messages, warnings, debug strings,
comments and names of static functions.

Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
2016-05-31 23:40:21 +02:00
Sebastian Rasmussen d35df4db5b docs: Fix various typos
Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
2016-05-31 23:40:21 +02:00
Karel Zak 747600537c libfdisk: use table-length in dump for non-standard PT
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-05-18 14:29:50 +02:00
Karel Zak a67054f9be libfdisk: make table-length usage more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-05-18 14:15:02 +02:00
Sassan Panahinejad d96153f8c8 sfdisk: Add support for altering GPT size
Adds a header option to alter the GPT table length
2016-05-18 13:56:25 +02:00
Sassan Panahinejad a18e726c66 libfdisk: Add support for altering GPT size
This is useful in two situations:

1. More than 128 partitions are required. Or

2. The partition table must be restricted in size, such as when a system
expects to find a bootloader at a location that would otherwise overlap the
partition table.

The gdisk partitioner supports this feature.

libfdisk is already capable of reading and writing partition tables of any
size, but previously could only create ones of 128 entries and could not
resize.

This change should be fairly safe, as it has no effect unless explicitly
activated.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-05-18 13:48:04 +02:00
Sassan Panahinejad 083c35b9f6 libfdisk: fix range checking for fdisk_set_last_lba 2016-05-18 13:46:35 +02:00
Karel Zak 40c9c3a6b7 libfdisk: add API for work with labelitems
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-05-12 14:37:29 +02:00
Karel Zak e4c5250dfb libfdisk: move fdisk_field_...() functions to field.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-05-12 12:21:59 +02:00
Karel Zak a3a125b922 libfdisk: use fdisk_add_partition() for unused partno
For example:

   sfdisk -N <parno>

may address unused partition. In this case we need to redirect from
fdisk_set_partition() to fdisk_add_partition() and follow default
setting (used all free space).

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-05-10 10:52:31 +02:00
Karel Zak 131e38a28e libfdisk: add fdisk_wipe_partition()
Now libfdisk provides functionality wipe disk device only ([s]fdisk
option --wipe).

This patch allows to probe for filesystems/RAIDs on newly created
partitions.  It means we can remove signatures before the partition
node (device) is created. This reduces udev events and it's
unnecessary to call wipefs for all partitions.  For example

  sfdisk --wipe=always --wipe-partitions=always /dev/sda <<<
  ...
  EOF

is a elegant way how to create new disk layout without any obsolete
filesystems/RAIDs.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-05-04 12:32:52 +02:00
Karel Zak b362a4cb98 libfdisk: don't offer zero length freespace
Reported-by: Kay Sievers <kay@vrfy.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-04-25 11:59:06 +02:00
Karel Zak deb1c90327 libmount: remove duplicate code
For petty long time we have strdup_to_struct_member() macro to avoid
duplicate code when strdup() strings in setter functions. Let's use it
for libmount.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-04-22 13:59:06 +02:00
Karel Zak 00e40d688a libfdisk: fix ref.counting in fdisk_apply_script() [clang analyze]
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-03-30 11:18:07 +02:00
Benno Schulenberg 614ddddfc1 libfdisk: (gpt) reword two error messages with a sense of direction
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-03-16 10:39:37 +01:00
Benno Schulenberg e906ab3c6a libfdisk: (bsd) fix spelling in warning message
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-03-16 10:39:36 +01:00
Ruediger Meier 18336d16d9 build-sys: use AC_PROG_MKDIR_P and remove a few gnuisms
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-13 21:48:09 +01:00
Ruediger Meier e1a15f8f68 misc: fix printf i386 compiler warnings
Still a few printf warnings found on i386 Linux:

libfdisk/src/alignment.c: In function 'fdisk_align_lba':
libfdisk/src/alignment.c:115:3: warning: format '%ju' expects argument of type 'uintmax_t', but argument 6 has type 'long unsigned int' [-Wformat]
sys-utils/lsns.c: In function ‘add_namespace’:
sys-utils/lsns.c:346:2: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘ino_t’ [-Wformat]
sys-utils/lsns.c: In function ‘add_process_to_namespace’:
sys-utils/lsns.c:362:2: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 6 has type ‘ino_t’ [-Wformat]
sys-utils/lsns.c: In function ‘add_scols_line’:
sys-utils/lsns.c:440:4: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘ino_t’ [-Wformat]

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-12 11:28:03 +01:00
Karel Zak 5bb1d22e8a build-sys: fix if..endif for *_la_LDFLAGS
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-03-10 13:54:15 +01:00
Ruediger Meier d9851e63fb libfdisk: remove ifdef HDIO_GETGEO
We don't use HDIO_GETGEO since e5b5a349.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-07 23:29:05 +01:00
Ruediger Meier 7a11addee8 fdisk: sun, undef HAVE_QSORT_R for non-Linux
Linux/glibc's qsort_r(3) has differently ordered arguments than BSD
implementations. For now we undef that quick and dirty.

The real fix would be to make configure check for qsort_r more
carefully (AC_CHECK_FUNCS with AC_LANG_WERROR). Moreover one could
add a wrapper to swap arguments, see
https://github.com/noporpoise/sort_r/blob/master/sort_r.h

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-07 23:28:48 +01:00
Ruediger Meier fdbd7bb940 misc: again fixing many printf format strings
This is again a huge patch regarding printf format strings to
fix compiler warnings seen on clang/OSX.

I'm trying to follow these rules strictly:

 #type      #format   #cast
 uintmax_t   %ju      -
 intmax_t    %jd      -
 uint64_t    PRIu64   -
 int64_t     PRId64   -
 size_t      %zu      -
 ssize_t     %zd      -
 ino_t       %ju      (uintmax_t)
 off_t       %jd      (intmax_t)

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-07 23:16:04 +01:00
Yuriy M. Kaminskiy 06fa581748 misc: safer (and uniform) handling of return value
When `rc` is `INT_MAX`, `rc + 1` result in signed integer overflow.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-03-07 15:11:06 +01:00
Andreas Henriksson a2ad58ac51 libfdisk: Fix order of C/H/S numbers output
While the header says C/H/S the actual numbers where printed as
C/S/H.

Addresses: http://bugs.debian.org/815847
Reported-by: "groups, freeman" <freeman_groups@reason.dyndns.org>
Signed-off-by: Andreas Henriksson <andreas@fatal.se>
2016-03-07 15:08:50 +01:00
Ruediger Meier 262c94c2c7 fdisk: fix warning, incompatible pointer types passing 'uint64_t *'
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-29 13:04:48 +01:00
Ruediger Meier 2013b33f40 build-sys: disable unused parameter warnings for some test progs
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 03:20:22 +01:00
Ruediger Meier b9710f1f08 misc: fix compiler warnungs (unsigned/signed)
These ones should be fixed:
libblkid/src/probe.c:393:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/probe.c:907:25: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libblkid/src/probe.c:1221:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:540:47: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1043:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1056:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1057:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1061:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/partitions/partitions.c:1199:27: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libblkid/src/partitions/partitions.c:1410:26: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libblkid/src/partitions/partitions.c:1431:25: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libblkid/src/superblocks/linux_raid.c:151:8: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
libblkid/src/superblocks/linux_raid.c:155:2: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
libblkid/src/superblocks/superblocks.c:375:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libblkid/src/superblocks/xfs.c:141:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libsmartcols/src/table.c:333:24: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libsmartcols/src/table.c:344:25: warning: signed and unsigned type in conditional expression [-Wsign-compare]
libsmartcols/src/table_print.c:753:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/ask.c:364:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/utils.c:33:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/context.c:435:56: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/context.c:730:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/script.c:557:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/dos.c:1791:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libfdisk/src/gpt.c:813:42: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
misc-utils/logger.c:408:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
disk-utils/partx.c:140:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
disk-utils/partx.c:551:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
disk-utils/partx.c:640:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 03:18:27 +01:00
Ruediger Meier 71177ab8f9 misc: fix warnings "unused parameter" [-Wunused-parameter]
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 03:18:24 +01:00
Ruediger Meier 63a7065b2c libfdisk: fix warnings, "redundant redeclaration" [-Wredundant-decls]
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 03:18:21 +01:00
Ruediger Meier 5fde1d9f06 tests: fix compiler warnings [-Wmissing-prototypes]
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 03:18:09 +01:00
Ruediger Meier 74272f00e1 libfdisk: fix compiler warnings [-Wmissing-prototypes]
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 01:27:34 +01:00
Ruediger Meier f3aca7ab21 libfdisk: fix missing symbol
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 01:25:41 +01:00
Ruediger Meier b0b54cc582 build-sys: always add AM_CFLAGS
We were missing our nice compliler warnings for many programs
and libs. See next commits how many trivial and non-trival
warnings have to be fixed.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 01:17:29 +01:00
Ruediger Meier b201f1d86c build-sys: always use global LDADD
This was a major showstopper when building on a system where
LTLIBINTL libs are needed (e.g. OSX). Maybe there are a few test
programs which wouldn't need LDADD ... never mind.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-23 01:16:58 +01:00
Karel Zak 45c9a3d27f Merge branch 'port-osx' of https://github.com/rudimeier/util-linux
* 'port-osx' of https://github.com/rudimeier/util-linux:
  include: fix sys/sysinfo.h
  libblkid: don't include endian.h
  lib: fix ismounted includes for FreeBSD
  lib: remove unused variable
  lsns: use xcalloc()
  include: remove unused mntent.h
  include: check for sys/sysmacros.h
  lib: define LOGIN_NAME_MAX fallback
  include: provide MAP_ANONYMOUS on OSX
  lib: rename strmode() and setmode()
  tests: fix ts_option helpers
  build-sys: fix [g]libtoolize version for OSX
  build-sys: check linker support for version scripts
  build-sys: portable usage of find command
  travis: minor cleanup
2016-02-19 11:30:53 +01:00
Karel Zak eae665f24b libfdisk: fix typo
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-18 14:23:37 +01:00
Karel Zak 6cbb7371b3 libfdisk: add API to control signatures wiping
Now libfdisk warns if another filesystem/RAID/PT signature is detected
on the device. It seems better and user-friendly to make it possible to
wipe the signatures when we write a new disk label to the device.

This patch adds to the library API

	fdisk_enable_wipe()
	fdisk_has_wipe()
	fdisk_get_collision()

to control this new feature. The device modification is done by
libblkid (the same we use in some mkfs-like utils).

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-18 12:58:12 +01:00
Ruediger Meier 3719bf8de9 build-sys: check linker support for version scripts
The macro AX_CHECK_VSCRIPT was taken from gnu autoconf archive.
http://www.gnu.org/software/autoconf-archive/

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-18 12:53:48 +01:00
Karel Zak f4a1d26609 libfdisk: add missing break
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-09 10:04:36 +01:00
Karel Zak 300e24a8ea sfdisk: add ESP shortcut also for Legacy MBR
References: https://github.com/karelzak/util-linux/issues/267
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-08 16:37:03 +01:00
Ruediger Meier 3fd1f7711e docs: fix typos found by codespell
Using "codespell" from https://github.com/lucasdemarchi/codespell

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-03 15:10:08 +01:00
Karel Zak d09c06baf4 sfdisk: add 'U' shortcut for ESP
echo -e ',512M,U\n,,L' | sfdisk --label gpt /dev/foo

to make ESP system partition.

References: https://github.com/karelzak/util-linux/issues/267
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-01 14:08:04 +01:00
Andrew Wilcox f136260aeb libfdisk: Add GPT type GUID for Itanium Linux root
References: http://www.freedesktop.org/wiki/Specifications/DiscoverablePartitionsSpec/
Signed-off-by: Andrew Wilcox <awilfox@adelielinux.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-12 10:35:11 +01:00
Ian Wienand 240ddd3a5f libfdisk: Detect out-of-space when adding new primary partition
I got a bit confused with the interaction below:

  Command (m for help): p
  Disk /dev/sda: 41 GiB, 43965677568 bytes, 85870464 sectors
    ...
  Device     Boot   Start      End  Sectors  Size Id Type
  /dev/sda1  *       2048  1026047  1024000  500M 83 Linux
  /dev/sda2       1026048 85868543 84842496 40.5G 8e Linux LVM

  Command (m for help): n
  To create more partitions, first replace a primary with an extended partition.

I knew I should have had two primary partitions available, but I did
not notice that the disk was seen as full (I was trying to grow it)

This change detects available primary partitions, and if so indicates
we are out of space, rather than out of partitions.

Signed-off-by: Ian Wienand <iwienand@redhat.com>
2015-10-09 13:07:41 +02:00
Karel Zak 7020de0be8 lib/crc32: don't require to modify GPT header
This patch introduces smart crc32 function that is able to exclude
specified. The advantage is that we does not have to modify GPT header
(set the current in-header crc field to zero) when we count crc32.

This allows to keep GPT header in read-only buffers and simplify code.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-09-24 09:26:42 +02:00
Karel Zak 83677b99cb libfdisk: fix partition move/resize code
- verify that the new partition fits to the area if the size of the
  has not been modified
- fix remaining space calculation (yes, brown-paper-bag bug..)
- offer also space before first partition as free space

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-09-17 13:22:11 +02:00
Karel Zak f2be8b3dfc libfdisk: add more debug message to resize code
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-09-17 12:04:23 +02:00
Karel Zak c949fa98d8 libfdisk: (gpt) control ranges in set_partition
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-09-17 11:44:08 +02:00
Karel Zak dd49c7d6d6 libfdisk: (gpt) reorder only when necessary
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-09-02 14:51:00 +02:00
Karel Zak 5cea5be05f libfdisk: (bsd) add note about non-written parental MBR
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-08-31 13:24:33 +02:00