summaryrefslogtreecommitdiffstats
path: root/libfdisk/src/partition.c
Commit message (Collapse)AuthorAgeFilesLines
* libfdisk: improve partition copy on resizeKarel Zak2019-07-221-0/+6
| | | | | | | | It seems pretty fragile to copy also reference counting and reference to table list. Addresses: https://github.com/karelzak/util-linux/pull/822 Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: Fix double free of *_chs strings in fdisk_partitionVojtech Trefny2019-07-191-0/+4
| | | | | | | __copy_partition doesn't duplicate these strings which leads to occasional double free. Signed-off-by: Vojtech Trefny <vtrefny@redhat.com>
* libfdisk: avoid memory leak [coverity scan]Karel Zak2019-05-151-1/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* sfdisk: fix logical partition resize when start specifiedKarel Zak2019-01-311-3/+11
| | | | | Addresses: https://github.com/karelzak/util-linux/issues/745 Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: count gaps to possible size when resizeKarel Zak2018-09-171-1/+1
| | | | | | | | | The current code counts only partition sizes when it counts possible space, but we have gaps between the partitions. It seems better to count all based on offsets rather than sizes. Addresses: https://github.com/karelzak/util-linux/issues/693 Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: fix list_del after partition resetVaclav Dolezal2018-05-091-1/+1
| | | | Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
* misc: fix typos using codespellRuediger Meier2018-02-161-1/+1
| | | | | | Some more funny typos, please review carefully. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* libfdisk: fix fdisk_reset_partition() leaking *_chs strings.Vaclav Dolezal2017-08-241-0/+2
| | | | Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
* libfdisk: improve "add partition" debug messageKarel Zak2017-08-221-6/+9
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: allow to resize in unsorted partition tableKarel Zak2017-07-191-4/+10
| | | | | | | 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>
* libfdisk: add fdisk_disable_dialogs()Karel Zak2017-07-191-4/+6
| | | | | | | | | | | | | | | 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>
* libfdisk: add commentKarel Zak2017-07-141-0/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (dos) cleanup template based partitioningKarel Zak2017-07-111-0/+12
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: support logical partition resizeKarel Zak2017-06-191-1/+11
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: allow to resize containerKarel Zak2017-06-191-1/+8
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: add more debug messages to get-last-possible resize spaceKarel Zak2017-06-191-6/+21
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (dos) be more verbose on partno -ERANGE errorKarel Zak2017-06-191-4/+7
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (docs) add missing 'since' tagsKarel Zak2017-05-231-0/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: add fdisk_partition_has_wipe()Karel Zak2017-05-091-0/+13
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: fix potentially NULL pointer usageKarel Zak2017-03-131-0/+4
| | | | | Reported-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: verify partno from templateKarel Zak2017-02-171-1/+2
| | | | | | | * verify partno from template when create a new partition * remove unnecessary l->ext_offset check Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (docs) add missing version notesKarel Zak2016-09-271-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: Fix various typosSebastian Rasmussen2016-05-311-6/+6
| | | | | | | 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 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-041-5/+132
| | | | | | | | | | | | | | | | | | | 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>
* misc: again fixing many printf format stringsRuediger Meier2016-03-071-14/+17
| | | | | | | | | | | | | | | | | | | 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>
* libfdisk: fix partition move/resize codeKarel Zak2015-09-171-8/+18
| | | | | | | | | - 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>
* libfdisk: add more debug message to resize codeKarel Zak2015-09-171-4/+13
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (gpt) control ranges in set_partitionKarel Zak2015-09-171-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: cleanup assert() usageKarel Zak2015-08-041-5/+2Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: undefined or garbage value returned to caller [clang analyze]Karel Zak2015-07-291-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: keep FDISK_FIELD_CYLINDERS independent on context modeKarel Zak2015-05-111-2/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: allow to move start to first usable LBAKarel Zak2015-04-221-4/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: add warning to resize functionKarel Zak2015-04-221-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: support resize operation in fdisk_set_partition()Karel Zak2015-04-221-14/+227
| | | | | | | Note that the resize is not exported by API yet, the only way to use it is sfdisk-like scripts. Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (dos) retain existing boot flag when resizing a partitionKarel Zak2015-04-131-2/+1Star
| | | | | | Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1210912 Signed-off-by: Karel Zak <kzak@redhat.com> Co-Author: awilliam@redhat.com
* libfdisk: don't return empty strings from fdisk_partition_to_string()Karel Zak2015-03-271-5/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: fix fdisk_partition_get_parent() docsKarel Zak2015-02-191-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: add some docsKarel Zak2015-02-101-9/+83
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: add fdisk_partition_is_wholedisk()Karel Zak2015-02-101-0/+6
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: actually translate the human-readable name of the partition typeBenno Schulenberg2015-02-021-1/+1
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* libfdisk: make fdisk_partition_to_string() more robust [coverity scan]Karel Zak2015-01-291-5/+8
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdiskL add API to print SIZE field in bytesKarel Zak2015-01-191-8/+15
| | | | | | The patch also add --bytes to fdisk and fdisk. Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: cleanup gtk-docs warningsKarel Zak2015-01-131-3/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: fix bug in cmp_numbers() and partitions sortingKarel Zak2014-12-041-5/+5
| | | | | Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1170191 Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: remove 'end' from struct fdisk_partitionKarel Zak2014-12-041-11/+38
| | | | | | This struct member duplicate "start+size". Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: rename sector_t to fdisk_sector_tKarel Zak2014-12-041-5/+6
| | | | | | .. just to avoid too generic names for public API. Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: fix cfdisk freespace analyzeKarel Zak2014-12-041-1/+11
| | | | | | | | | The problem is how fdisk_partition_cmp_start() compare numbers, the function returns result from "a->start - b->start", unfortunately the numbers are uint64, but function returns "int". Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1170191 Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: add API docsKarel Zak2014-11-261-5/+7
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: cleanup fdisk_partition_to_string() commentKarel Zak2014-11-261-2/+4
|