summaryrefslogtreecommitdiffstats
path: root/libfdisk/src
Commit message (Collapse)AuthorAgeFilesLines
...
* libfdisk: cleanup labelitem initializationKarel Zak2016-10-273-2/+12
| | | | | | | | * use macro for label initialization * make sure we do not call fdisk_ref_labelitem() and fdisk_unref_labelitem() for non-allocated items Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: fix uninitialized fdisk_labelitemRuediger Meier2016-10-271-1/+1
| | | | | | | | | | | | | | | fdisk -l could crash randomly. Only seen on some i586 systems with certain exotic compiler options. The problem was that this item is later used in function fdisk_reset_labelitem() like this: if (li->type == 's') free(li->data.str); This may crash if item is randomly initialized. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* libfdisk: (script) make bootable flag parsing more robustKarel Zak2016-10-261-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: add trivial script testKarel Zak2016-10-261-0/+19
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: fix unsigned int usage for ctype.h functionsKarel Zak2016-10-261-2/+2
| | | | | Reported-by: "Yuriy M. Kaminskiy" <yumkam@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: make script token parser more robustKarel Zak2016-10-251-3/+29
| | | | | | | | | | * make sure token is terminated * skip closing quotes * allow extra space after quotes and before terminater * skip extra space after terminater Addresses: https://github.com/karelzak/util-linux/issues/367 Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: fix script Type= and Id= parsingKarel Zak2016-10-251-2/+1Star
| | | | | | | | The parser is not consistent and *case insensitive* Type= and Id= tokens are not expected on all places. Addresses: https://github.com/karelzak/util-linux/issues/367 Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (gpt) make attributes parser more robustKarel Zak2016-10-251-5/+14
| | | | | | | | * allow GUID: prefix only for numbers * require space or comma separator Addresses: https://github.com/karelzak/util-linux/issues/367 Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/crc32: prefix public functionsGustavo Zacarias2016-10-191-1/+1
| | | | | | | | | | | Make the publicly-visible crc32 library functions prefixed by ul_, such as crc32() -> ul_crc32(). This is because it clashes with the crc32() function from zlib. For newer versions of glib (2.50+) zlib and libblkid are required dependencies and otherwise results in build failure when building statically. Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
* docs: some random fixesKarel Zak2016-09-272-20/+20
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (docs) add missing version notesKarel Zak2016-09-272-2/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* debug: use const void * for ul_debugobj()Igor Gnatenko2016-09-211-2/+2
| | | | | | | | | | We don't modify data it's pointing out and we should not modify it. Also remove casting to void * as gcc will do it automatically (before we had to cast it explicitly to avoid warning on discarding 'const' qualifier). Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
* libfdisk: Distinguish between first LBA sector and partitionTobias Stoeckmann2016-08-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | An insufficient check leads to an invalid free space output, as seen here: $ dd if=/dev/zero of=cfdisk.iso bs=1M count=1 $ losetup -f cfdisk.iso $ echo w | fdisk /dev/loop0 $ echo '1,1' | sfdisk /dev/loop0 --append $ echo '3,' | sfdisk /dev/loop0 --append $ sfdisk --list-free /dev/loop0 Start End Sectors Size 1 2 2 1K $ _ In this case, libfdisk fails to notice that it tries to calculate space between two partitions, not between start of disk and first partition. Currently, the code tries to achieve that by checking the address of the last "partition", which is the first_lba block. Now if the first partition is merely 1 block in size, the "last" address is still equal to the first_lba block, which renders the check in libfdisk for the next partition invalid. I chose to use "nparts == 0" for this check, because the partitions are properly sorted before iterating over them. Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
* libfdisk: Fix assert error in free space handlingTobias Stoeckmann2016-08-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | An off-by-one issue exists in fdisk_get_freespaces. It can trigger an assert, as seen here: $ dd if=/dev/zero of=cfdisk.iso bs=1M count=1 $ losetup -f cfdisk.iso $ echo w | fdisk /dev/loop0 $ echo '1,2' | sfdisk /dev/loop0 --append $ echo '3,' | sfdisk /dev/loop0 --append $ sfdisk --list-free /dev/loop0 Aborted $ _ Problem here is an invalid "grain" processing. A grain is considered expected free space between partitions which can be required for proper alignment. Normally, it's 1 MB but in this case our iso is merely 1 MB so the grain is reduced to 1 byte. The if-condition in question checks for "last + grain <= pa->start" and therefore even triggers if there is no space between them (due to equal check). Eventually, the start block address is higher than the end block address which triggers the assert(). Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
* misc: simplify if clauses [oclint]Sami Kerola2016-07-212-17/+14Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libfdisk: cleanup fdisk_gpt_set_npartitions()Karel Zak2016-06-212-6/+18
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (gpt) be more careful with 64bit constantsKarel Zak2016-06-211-29/+27Star
| | | | | | | | It's probably more robust (and readable) to be explicit when we count with constant and 64bit numbers. Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=1344482 Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: Fix typo RequiredPartiton -> RequiredPartitionSebastian Rasmussen2016-05-311-1/+6
| | | | | | | | This typo fix is backwards compatible in that fdisk will accept both the GPT attribute RequiredPartition and RequiredPartiton with the typo. Update documentation and tests to all use the new attribute name. Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
* misc: Fix various typosSebastian Rasmussen2016-05-3117-83/+83
| | | | | | | Fix various typos in error messages, warnings, debug strings, comments and names of static functions. Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
* libfdisk: use table-length in dump for non-standard PTKarel Zak2016-05-183-9/+17
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: make table-length usage more robustKarel Zak2016-05-182-3/+10
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* sfdisk: Add support for altering GPT sizeSassan Panahinejad2016-05-181-2/+13
| | | | Adds a header option to alter the GPT table length
* libfdisk: Add support for altering GPT sizeSassan Panahinejad2016-05-183-0/+102
| | | | | | | | | | | | | | | | | | | | | 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>
* libfdisk: fix range checking for fdisk_set_last_lbaSassan Panahinejad2016-05-181-1/+1
|
* libfdisk: add API for work with labelitemsKarel Zak2016-05-127-7/+285
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: move fdisk_field_...() functions to field.cKarel Zak2016-05-124-52/+97
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: use fdisk_add_partition() for unused partnoKarel Zak2016-05-101-0/+5
| | | | | | | | | | | | 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>
* libfdisk: add fdisk_wipe_partition()Karel Zak2016-05-049-50/+323
| | | | | | | | | | | | | | | | | | | 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>
* libfdisk: don't offer zero length freespaceKarel Zak2016-04-251-5/+16
| | | | | Reported-by: Kay Sievers <kay@vrfy.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: remove duplicate codeKarel Zak2016-04-221-1/+1
| | | | | | | | 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>
* libfdisk: fix ref.counting in fdisk_apply_script() [clang analyze]Karel Zak2016-03-301-4/+10
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (gpt) reword two error messages with a sense of directionBenno Schulenberg2016-03-161-2/+2
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* libfdisk: (bsd) fix spelling in warning messageBenno Schulenberg2016-03-161-1/+1
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* build-sys: use AC_PROG_MKDIR_P and remove a few gnuismsRuediger Meier2016-03-131-1/+1
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: fix printf i386 compiler warningsRuediger Meier2016-03-121-1/+1
| | | | | | | | | | | | | | | 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>
* build-sys: fix if..endif for *_la_LDFLAGSKarel Zak2016-03-101-4/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: remove ifdef HDIO_GETGEORuediger Meier2016-03-072-4/+1Star
| | | | | | We don't use HDIO_GETGEO since e5b5a349. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* fdisk: sun, undef HAVE_QSORT_R for non-LinuxRuediger Meier2016-03-071-0/+5
| | | | | | | | | | | | 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>
* misc: again fixing many printf format stringsRuediger Meier2016-03-077-44/+53
| | | | | | | | | | | | | | | | | | | 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>
* misc: safer (and uniform) handling of return valueYuriy M. Kaminskiy2016-03-071-6/+2Star
| | | | | | When `rc` is `INT_MAX`, `rc + 1` result in signed integer overflow. Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: Fix order of C/H/S numbers outputAndreas Henriksson2016-03-071-4/+4
| | | | | | | | | 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>
* fdisk: fix warning, incompatible pointer types passing 'uint64_t *'Ruediger Meier2016-02-291-1/+2
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* build-sys: disable unused parameter warnings for some test progsRuediger Meier2016-02-231-1/+1
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: fix compiler warnungs (unsigned/signed)Ruediger Meier2016-02-236-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* misc: fix warnings "unused parameter" [-Wunused-parameter]Ruediger Meier2016-02-232-6/+6
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* libfdisk: fix warnings, "redundant redeclaration" [-Wredundant-decls]Ruediger Meier2016-02-231-6/+0Star
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* tests: fix compiler warnings [-Wmissing-prototypes]Ruediger Meier2016-02-235-9/+9
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* libfdisk: fix compiler warnings [-Wmissing-prototypes]Ruediger Meier2016-02-231-1/+1
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* libfdisk: fix missing symbolRuediger Meier2016-02-231-1/+1
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* build-sys: always add AM_CFLAGSRuediger Meier2016-02-231-0/+1
| | | | | | | | 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>