summaryrefslogtreecommitdiffstats
path: root/libfdisk/src/context.c
Commit message (Collapse)AuthorAgeFilesLines
* 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: don't use FAT as MBRKarel Zak2019-07-171-5/+11
| | | | | | | | | 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-201-4/+4
|
* libfdisk: add fdisk_assign_device_by_fd()Karel Zak2019-06-181-48/+94
| | | | | | | | 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: (docs) add notes about fdisk_enable_wipe()Karel Zak2019-06-171-9/+22
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (docs) add reference to v2.33Karel Zak2019-06-071-0/+4
| | | | 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: add comment to fdisk_set_first_lba()Karel Zak2019-01-181-0/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* 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: add fdisk_get_devmodel() and fdisk_get_devno()Karel Zak2018-08-301-0/+50
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (docs) add missing docs blocksKarel Zak2018-02-211-1/+1
| | | | Signed-off-by: Karel Zak <kzak@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: allow to start freespace for zeroKarel Zak2018-01-111-0/+2
| | | | | | | This is necessary for disk labels like SUN where whole disk is possible to address by partitions. Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: fix typosSami Kerola2017-11-281-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libfdisk: add fdisk_disable_dialogs()Karel Zak2017-07-191-0/+34
| | | | | | | | | | | | | | | 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: fix warning -Wunused-functionRuediger Meier2017-07-181-0/+2
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* libfdisk: use BLKPG_* ioctls on linux onlyKarel Zak2017-07-171-1/+13
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: remove whitespacesKarel Zak2017-07-141-3/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: use BLKPG ioctls to inform kernel about changesKarel Zak2017-07-141-0/+102
| | | | | | | | | | | | | This patch introduces fdisk_reread_changes(). The function is less invasive alternative to fdisk_reread_partition_table(). The new function uses BLKPG ioctls for modified partitions. The another partitions are not affected. This solution allows to successfully use fdisks on disk where some partitions are still use (mounted). For example if you want to resize the last partition on the device. Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: add fdisk_device_is_used()Karel Zak2017-07-141-0/+34
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: remove unnecessary fstat() callKarel Zak2017-07-141-4/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: move fdisk_reread_partition_table() to another fileKarel Zak2017-07-141-0/+41
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: add fdisk_reassign_device()Karel Zak2017-07-101-0/+36
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: fix variable shadowingSami Kerola2017-05-291-6/+8
| | | | | | | | | | | libfdisk/src/context.c: In function 'fdisk_assign_device': libfdisk/src/context.c:549:7: warning: declaration of 'rc' shadows a previous local [-Wshadow] libfdisk/src/context.c:542:10: note: shadowed declaration is here [kzak@redhat.com: - add rc to debug message] Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (docs) add missing 'since' tagsKarel Zak2017-05-231-3/+7
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: don't use errno after close()Karel Zak2017-05-171-2/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: check fstat() return code [coverity scan]Karel Zak2017-05-171-2/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: fix NLS supportKarel Zak2017-04-251-0/+2
| | | | | | | | | | | | | | | | | | | 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: classify collision typeKarel Zak2017-02-141-0/+15
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: check for collisions when create new labelKarel Zak2017-02-141-50/+2Star
| | | | | | | | We need to be sure that when create a new disklabel than the old label will be removed. Addresses: https://github.com/karelzak/util-linux/issues/410 Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: fix fdisk_set_wipe_area() callsKarel Zak2017-02-101-8/+4Star
| | | | | | | The function expects size in sectors rather than in bytes. Addresses: https://github.com/karelzak/util-linux/issues/410 Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: apply label alignment propertiesKarel Zak2017-01-161-0/+2
| | | | | | This fix changes from the previous patches. Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: change the way how apply user device propertiesKarel Zak2017-01-131-6/+2Star
| | | | | | | | | | | | | | | | 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>
* libfdisk: don't use blkdev ioctls for regular filesKarel Zak2017-01-131-1/+17
| | | | | | | | | | | | | $ fdisk <diskimage> open("sdc.img", O_RDONLY|O_CLOEXEC) = 3 ioctl(3, BLKSSZGET, 0x7ffcf51357c4) = -1 ENOTTY (Inappropriate ioctl for device) ioctl(3, BLKGETSIZE64, 0x7ffcf51357b0) = -1 ENOTTY (Inappropriate ioctl for device) ioctl(3, BLKGETSIZE, 0x7ffcf51356c8) = -1 ENOTTY (Inappropriate ioctl for device) ioctl(3, FDGETPRM, 0x7ffcf51356d0) = -1 ENOTTY (Inappropriate ioctl for device) ioctl(3, HDIO_GETGEO, 0x7ffcf5135790) = -1 ENOTTY (Inappropriate ioctl for device) Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: fix typoKarel Zak2016-11-021-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* 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>
* libfdisk: fix range checking for fdisk_set_last_lbaSassan Panahinejad2016-05-181-1/+1
|
* libfdisk: add fdisk_wipe_partition()Karel Zak2016-05-041-36/+21Star
| | | | | | | | | | | | | | | | | | | 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: fix compiler warnungs (unsigned/signed)Ruediger Meier2016-02-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* libfdisk: fix missing symbolRuediger Meier2016-02-231-1/+1
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* libfdisk: fix typoKarel Zak2016-02-181-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: add API to control signatures wipingKarel Zak2016-02-181-15/+89
| | | | | | | | | | | | | | | | | 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>
* libfdisk: cleanup assert() usageKarel Zak2015-08-041-2/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: support bootbits protection from (p)MBRKarel Zak2015-04-131-1/+32
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: fix possible mem leak [coverity scan]Karel Zak2015-01-281-1/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: make label names case insensitiveKarel Zak2015-01-191-4/+6
| | | | | | and support 'MBR' as alias to 'DOS'. Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdiskL add API to print SIZE field in bytesKarel Zak2015-01-191-0/+29
| | | | | | The patch also add --bytes to fdisk and fdisk. Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: fix some typosKarel Zak2015-01-131-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: rename sector_t to fdisk_sector_tKarel Zak2014-12-041-7/+7
| | | | | | .. just to avoid too generic names for public API. Signed-off-by: Karel Zak <kzak@redhat.com>