summaryrefslogtreecommitdiffstats
path: root/libfdisk
Commit message (Collapse)AuthorAgeFilesLines
* libfdisk: (script) support shortcuts in the type= fieldKarel Zak2019-08-081-2/+7
| | | | | | | | | | | | | | | | | | | | The unnamed-field format supports partition type shortcuts: ",1MiB,L' but for named-field format it requires full type: (mbr) "size=1MiB,type=83" (gpt) "size=1MiB,type=0FC63DAF-8483-4772-8E79-3D69D8477DE4" This patch implements type shortcuts also for named-field format: "size=1MiB,type=L" to make it more user-friendly and unified. Addresses: https://github.com/karelzak/util-linux/issues/837 Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: refer to partx(8) rather than to kpartx(8)Karel Zak2019-08-061-1/+1
| | | | | Reported-by: Petr Pisar <petr.pisar@atlas.cz> Signed-off-by: Karel Zak <kzak@redhat.com>
* 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: don't use NTFS as MBRKarel Zak2019-07-171-1/+3
| | | | | | Same as 7c643ed2855058657798d9e8e80701023de14a08. Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: don't use FAT as MBRKarel Zak2019-07-172-5/+15
| | | | | | | | | The current libfdisk MBR detection is too weak, the result is that it reuses MBR from FAT. The correct behavior is to create a new MBR, wipe first sector (on write) and warn about obsolete FAT superblock. Reported-by: Mike Fleetwood <mike.fleetwood@googlemail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: fix variable shadowingSami Kerola2019-07-121-1/+1
| | | | | | | libfdisk/src/context.c:678:7: warning: declaration of ‘rc’ shadows a previous local [-Wshadow] Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libfdisk: fix typosMarcos Mello2019-06-204-14/+14
|
* libfdisk: add fdisk_assign_device_by_fd()Karel Zak2019-06-185-48/+99
| | | | | | | | It's possible that caller has the device already opened for some other task, so let's reuse the file descriptor. Requested-by: Lennart Poettering <lennart@poettering.net> Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: fix fdisk_script_get_table()Karel Zak2019-06-172-14/+20
| | | | | | Make sure we never return NULL and we reuse the table in code. Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (docs) add notes about fdisk_enable_wipe()Karel Zak2019-06-172-10/+24
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: add fdisk_script_set_table()Karel Zak2019-06-174-13/+69
| | | | | | | | | | | | This small change improves possibility to modify by script described PT and use script API in another tools as primary way to create partitions. All you need is to compose script by fdisk_script_set_header() and fdisk_script_set_table() and than apply by fdisk_apply_script(). Requested-by: Lennart Poettering <lennart@poettering.net> Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (docs) add reference to v2.33Karel Zak2019-06-072-0/+8
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: assert if self_pte() returns NULLSami Kerola2019-05-221-0/+4
| | | | | | | | | | The self_pte() can return NULL if partitions array is not large enough, but that should also be impossible and definitely a bug. libfdisk/src/dos.c:984:8: warning: potential null pointer dereference [-Wnull-dereference] libfdisk/src/dos.c:1031:8: warning: potential null pointer dereference [-Wnull-dereference] Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libfdisk: (bsd) improve checksum calculation [-Waddress-of-packed-member]Karel Zak2019-05-221-5/+12
| | | | | | | | Let's keep compilers and static analyzers happy. The idea is to use memcpy() to copy from buffer to variable and use all label as unsigned char rather than vectorize by unsigned short. Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: avoid memory leak [coverity scan]Karel Zak2019-05-151-1/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: avoid division by zero [clang scan]Karel Zak2019-05-151-2/+7
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: remove unused code [clang scan]Karel Zak2019-05-151-1/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: properly check return code of add_to_partitions_array() [coverity ↵Karel Zak2019-05-151-1/+2
| | | | | | scan] Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (dos) Use strtoul to parse the label-idJuerg Haefliger2019-02-251-1/+1
| | | | | | | Parsing of the label-id fails on 32-bit if the MSB is set. Fix that by using strtoul instead of strtol. Signed-off-by: Juerg Haefliger <juergh@canonical.com>
* libfdisk: (dos) rewrite fist/last free sector functionsKarel Zak2019-02-251-106/+169
| | | | | | | | | | | | | | The current code uses first[] and last[] arrays to specify partition ranges. This is unnecessary as we already have all in memory. The current code offers in first and last sector dialogs ranges without care about already used areas. This commit makes things more readable, more user-friendly and remove obscure first[] and last[]. Reported-by: 冰柯 <ziming_cool@126.com Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (dos) improve first unused sector for logical partitionsKarel Zak2019-02-181-1/+10
| | | | | | Make sure we probe within extended partition. Signed-off-by: Karel Zak <kzak@redhat.com>
* docs: fix typos [codespell]Sami Kerola2019-02-186-8/+8
| | | | | Reference: https://github.com/codespell-project/codespell Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* various: fix 'uninitialized when used' warnings [clang]Sami Kerola2019-02-182-2/+2
| | | | | | | This change fixes "warning: variable 'var' may be uninitialized when used here [-Wconditional-uninitialized]" warnings reported in various files. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libfdisk: sanity check, to prevent overlapping partitions from being partly ↵Fabian.Kirsch@dlr.de2019-02-181-2/+7
| | | | | | | | | | | | | | | | reported as free i noticed wrongly reported free space when looking with cfdisk on an USB drive prepared with the latest alpine *.iso[1]. Feel free to apply below patch, which fixed the issue for me. Greetings Fabian [1]: http://dl-cdn.alpinelinux.org/alpine/v3.9/releases/x86/alpine-extended-3.9.0-x86.iso Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: use list_add_tail() in more robust wayKarel Zak2019-02-181-0/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (gpt) add HiFive Unleashed bootloader partition UUIDsIcenowy Zheng2019-02-041-1/+5
| | | | | | | | | | The HiFive Unleashed SBC's bootloader seeks for GPT partitions with specific UUID for loading the next stage bootloader (ZSBL loads FSBL, and FSBL loads BBL). Add these partition type UUIDs. Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
* 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: add comment to fdisk_set_first_lba()Karel Zak2019-01-181-0/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: make partition types uses more robustKarel Zak2019-01-101-1/+5
| | | | | | | | * report failed partition type parsing * make sure partition types code (from user reply) for MBR is hex Reported-by: Jonny Grant <jg@jguk.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: fix printf format modifierRuediger Meier2018-10-041-1/+1
| | | | | | | | | libfdisk/src/script.c: In function ‘fdisk_script_read_context’: libfdisk/src/script.c:452:33: error: format ‘%zu’ expects argument of type ‘size_t’, but argument 4 has type ‘long unsigned int’ [-Werror=format=] snprintf(buf, sizeof(buf), "%zu", fdisk_get_grain_size(cxt)); ^ Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* libfdisk: fix OSX compiler warningRuediger Meier2018-10-041-3/+5
| | | | | | | libfdisk/src/context.c:1354:54: error: unused parameter 'cxt' [-Werror,-Wunused-parameter] const char *fdisk_get_devmodel(struct fdisk_context *cxt) Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* libfdisk: (docs) add missing functionKarel Zak2018-09-191-0/+1
| | | | 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: accept grain script headerKarel Zak2018-09-122-1/+24
| | | | | | | | | | | | The "grain" variable is used to calculate partitions alignment. The default is 1MiB (or minimal I/O size). The libfdisk provides API to overwrite this default, but this feature has been nowhere accessible for end-user. This patch support for "grain: <size>" in libfdisk scripts. Addresses: https://github.com/karelzak/util-linux/issues/688 Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: add fdisk_get_devmodel() and fdisk_get_devno()Karel Zak2018-08-305-0/+61
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* docs: use SPDX license namesKarel Zak2018-08-161-1/+1
| | | | | | | | | | Let's use standardized names for licenses. The names used by SPDX makes things more obvious at first glance. For complete list see: https://spdx.org/licenses/ Note, this commit does not change any license or so... Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: Accept negative numbers for last sector inputAwal Garg2018-07-319-7/+45
| | | | | | | | [kzak@redhat.com: - add note to the man page - add '-' to the dialog query - cleanup functions names and libfdisk.sym] Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: fix compiler warnings [-Wcast-qual]Karel Zak2018-07-233-6/+6
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: fix compiler warning [-Wmaybe-uninitialized]Karel Zak2018-07-181-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: reduce number of asprintf() calls, check return valueKarel Zak2018-07-041-14/+19
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: Fix multipath partition seperators for user-friendly namesKyleMahlkuch2018-07-041-1/+14
| | | | | | | | | | | | | | | | | | | | | | | | | 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.
* libfdisk: use \x<hex> to read/write partition nameKarel Zak2018-07-041-2/+6
| | | | | Addresses: https://github.com/karelzak/util-linux/issues/656 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>
* libfdisk: fix compiler warning [-Wunused-parameter]Karel Zak2018-05-035-15/+5Star
| | | | | Reported-by: L A Walsh <lkml@tlinx.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: improve JSON outputKarel Zak2018-04-051-22/+48
| | | | | | | * use fputs_quoted_json() for all data * fix use of variables separator Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (docs) fix section nameKarel Zak2018-03-211-1/+1
| | | | | | | The string "DOS (MBR)" generates filename with "(...)" which is unacceptable by kernel.org stuff. Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (docs) update yearKarel Zak2018-03-201-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: fix docs warningsKarel Zak2018-02-212-0/+14
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (docs) add missing docs blocksKarel Zak2018-02-213-22/+48
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>