summaryrefslogtreecommitdiffstats
path: root/libfdisk/src/dos.c
Commit message (Collapse)AuthorAgeFilesLines
* 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-171-0/+4
| | | | | | | | | 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: 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: remove unused code [clang scan]Karel Zak2019-05-151-1/+0Star
| | | | 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>
* various: fix 'uninitialized when used' warnings [clang]Sami Kerola2019-02-181-1/+1
| | | | | | | 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: Accept negative numbers for last sector inputAwal Garg2018-07-311-2/+3
| | | | | | | | [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-231-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: fix compiler warning [-Wunused-parameter]Karel Zak2018-05-031-3/+1Star
| | | | | Reported-by: L A Walsh <lkml@tlinx.org> 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: (dos) fix max headsKarel Zak2018-01-021-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: extend API to provide label specific geometry rangesKarel Zak2018-01-021-0/+8
| | | | | | | 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>
* libfdisk: fix two potential memory errors.Vaclav Dolezal2017-08-241-2/+3
| | | | | | | | | | 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>
* libfdisk: (dos) use size-=1 when alignment not used laterKarel Zak2017-08-221-3/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: add fdisk_disable_dialogs()Karel Zak2017-07-191-2/+4
| | | | | | | | | | | | | | | 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: (dos) return EINVAL when delete unused partitionKarel Zak2017-07-191-2/+17
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (dos) accept start for log.partitions on templateKarel Zak2017-07-111-3/+9
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (dos) cleanup template based partitioningKarel Zak2017-07-111-25/+33
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (dos) be more verbose on partno -ERANGE errorKarel Zak2017-06-191-0/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (dos) fix primary/logical logic when follow templateKarel Zak2017-06-191-2/+2
| | | | | | | 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>
* libfdisk: initialize partno variable [coverity scan]Karel Zak2017-05-171-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: fix NLS supportKarel Zak2017-04-251-1/+0Star
| | | | | | | | | | | | | | | | | | | 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>
* libfdisk: allow to change an existing extended partitionPavel Butsykin2017-04-191-1/+1
| | | | Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
* libfdisk: fix potentially NULL pointer usageKarel Zak2017-03-131-14/+73
| | | | | Reported-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (dos) add ID related debug messagesKarel Zak2017-02-271-2/+7
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (dos) make it possible to create primary/logical by templateKarel Zak2017-02-171-3/+21
| | | | | | | | Let's check partition partno if specified to create logical or primary partition. Addresses: https://github.com/karelzak/util-linux/issues/204 Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: verify partno from templateKarel Zak2017-02-171-1/+1
| | | | | | | * verify partno from template when create a new partition * remove unnecessary l->ext_offset check Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (dos) debug what we read from first sectorKarel Zak2017-02-141-0/+6
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: change the way how apply user device propertiesKarel Zak2017-01-131-0/+3
| | | | | | | | | | | | | | | | The current code calls fdisk_apply_user_device_properties() after label probing, because we want to overwrite label geometry by user settings (e.g. -C -H -S fdisk options). Unfortunately, this way does not work if we need to use a different sector size, because label probing depends on sector size... So, the right way is to apply user setting to the fdisk context before we start to read from device, and overwrite geometry again after label is already read. Fortunately, this shit is necessary only rarely and for SUN and SGI disk labels. Addresses: https://github.com/karelzak/util-linux/issues/396 Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: spelling, always use "cannot" instead of "can not"Ruediger Meier2016-11-301-1/+1
| | | | | | Just to be consistent ... Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: simplify if clauses [oclint]Sami Kerola2016-07-211-14/+12Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: Fix various typosSebastian Rasmussen2016-05-311-8/+8
| | | | | | | Fix various typos in error messages, warnings, debug strings, comments and names of static functions. Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
* misc: again fixing many printf format stringsRuediger Meier2016-03-071-1/+1
| | | | | | | | | | | | | | | | | | | 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 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>
* misc: fix compiler warnungs (unsigned/signed)Ruediger Meier2016-02-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-231-2/+2
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* libfdisk: Detect out-of-space when adding new primary partitionIan Wienand2015-10-091-1/+4
| | | | | | | | | | | | | | | | | | | | | | 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>
* libfdisk: (gpt) reorder only when necessaryKarel Zak2015-09-021-2/+1Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* Fix trivial typosYuri Chornoivan2015-08-251-1/+1
|
* libfdisk: allow to change partition type for extended partitionsKarel Zak2015-07-301-10/+51
| | | | | Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1248115 Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: add new API to read label specific dataKarel Zak2015-06-111-21/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | * removes list() label operation from internal API The list() has been based on fdisk_info() it was useless for anything else than print on stdout... * add a new get_item() label operation and fdisk_get_disklabel_item() public API The new API provides abstract and pretty simple way how to get label specific disk label information, for example fdisk_get_disklabel_item(cxt, GPT_LABELITEM_ENTRIESLBA, &iterm); return LBA of the array with GPT entries. Note that this patch does not implement public functions to get data from the @item object. * removes get_id() label operation -- it's subset of the new get_item() * the new internal API is also used to implement backwardly compatible fdisk_list_disklabel() and fdisk_get_disklabel_id() Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (dos) fix cylinders calculationKarel Zak2015-06-101-10/+5Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: differentiate between +<sector> and +<size>{M,G,...}Karel Zak2015-06-101-5/+4Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: improve +0 partition sizeKarel Zak2015-06-081-27/+46
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (dos) fix tiny partitions calculationKarel Zak2015-06-081-0/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: don't resize in label driversKarel Zak2015-04-221-27/+0Star
| | | | | | The resize operation has to be implemented on upper layer. Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: support bootbits protection from (p)MBRKarel Zak2015-04-131-1/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (dos) retain existing boot flag when resizing a partitionKarel Zak2015-04-131-3/+5
| | | | | | Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1210912 Signed-off-by: Karel Zak <kzak@redhat.com> Co-Author: awilliam@redhat.com