summaryrefslogtreecommitdiffstats
path: root/libfdisk/src
Commit message (Collapse)AuthorAgeFilesLines
...
* misc: fix reassigned values before old ones has been used [cppcheck]Sami Kerola2017-06-142-2/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libfdisk: fix guid usage of packed struct gpt_entryRuediger Meier2017-06-131-10/+27
| | | | | | | | | | clang issued warnings like this: ../libfdisk/src/gpt.c:371:18: warning: taking address of packed member 'type' of class or structure 'gpt_entry' may result in an unaligned pointer value [-Waddress-of-packed-member] guid_to_string(&e->type, str); ^~~~~~~ Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* libfdisk: cleanup sun label checksum usuageRuediger Meier2017-06-131-26/+7Star
| | | | | | | | | | | | | | We are using now the formerly unused function sun_pt_checksum(). This cleanup was motivated by clang compiler warning, see below. Also nice that we are now always using uint16_t instead of short. Warning was: ../libfdisk/src/sun.c:177:35: warning: taking address of packed member 'csum' of class or structure 'sun_disklabel' may result in an unaligned pointer value [-Waddress-of-packed-member] while(ush < (unsigned short *)(&sunlabel->csum)) Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* Merge branch 'master' of https://github.com/yurchor/util-linuxKarel Zak2017-06-021-1/+1
|\ | | | | | | | | * 'master' of https://github.com/yurchor/util-linux: Fix minor typos
| * Fix minor typosYuri Chornoivan2017-05-231-1/+1
| |
* | build-sys: fix library order when linkingRuediger Meier2017-06-011-1/+1
| | | | | | | | | | | | | | | | | | | | We got some errors on Alpine Linux where $LTLIBINTL is non-empty: ./.libs/libcommon.a(libcommon_la-blkdev.o): In function `open_blkdev_or_file': lib/blkdev.c:282: undefined reference to `libintl_gettext collect2: error: ld returned 1 exit status Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* | 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: update docsKarel Zak2017-05-233-7/+26
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (docs) add missing 'since' tagsKarel Zak2017-05-233-3/+11
| | | | 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>
* libfdisk: use memcpy() for non-terminated string [coverity scan]Karel Zak2017-05-171-1/+1
| | | | 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>
* libmount: check fstat() return code [coverity scan]Karel Zak2017-05-171-2/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: don't print uninitialized variable [coverity scan]Karel Zak2017-05-171-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: add fdisk_partition_has_wipe()Karel Zak2017-05-093-0/+17
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: fix NLS supportKarel Zak2017-04-258-7/+14
| | | | | | | | | | | | | | | | | | | 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: (gpt) rename to gpt_entry_is_used()Karel Zak2017-04-191-21/+22
| | | | | | The current function name is inconsistent with the rest of the code. 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>
* misc: fix some printf format stringsRuediger Meier2017-04-101-1/+1
| | | | | | | | | | | Fix compiler warnings seen on Linux/i586 and OSX/travis. #type #format #cast unsigned long %lu - uint64_t PRIu64 - fdisk_sector_t %ju (uintmax_t) Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* libfdisk: (gpt) fix ents zeroizeKarel Zak2017-04-061-1/+1
| | | | | | | The gpt->ents is "unsigned char" buffer now. We need to use bytes, no number of entries... Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (gpt) update nparts_maxKarel Zak2017-04-061-0/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (gpt) care about SSIZE_MAX for read(2)Karel Zak2017-04-061-0/+5
| | | | | | | | read(2) behavior is undefined if you want to read more than SSIZE_MAX bytes. Let's be paranoid and check for this... Reported-by: Ruediger Meier <sweet_f_a@gmx.de> Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (gpt) make entries array size calculation more robustKarel Zak2017-04-051-30/+51
| | | | | | | * use the same function everywhere * keep calculation based on size_t Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (gpt) use size_t and gpt_get_nentries()Karel Zak2017-04-051-36/+48
| | | | | | | If possible use size_t for number of entries (partitions). It makes code more readable and without unnecessary casts. Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (gpt) don't access entries array directlyKarel Zak2017-04-051-129/+183
| | | | | | | | | | | We blindly assume that our sizeof(struct gpt_entry) is the same on-disk stored header->sizeof_partition_entry. It seems more correct would be to use sizeof specified by header to access the entries array items. This patch introduces gpt_get_entry() to avoid direct access to gpt->ents[]. Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: fix compiler warning [-Wsign-compare]Karel Zak2017-03-161-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: fix potentially NULL pointer usageKarel Zak2017-03-132-14/+77
| | | | | 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: add version to debug outputKarel Zak2017-02-271-0/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: add static keyword to where needed [smatch scan]Sami Kerola2017-02-201-1/+1
| | | | | | | text-utils/rev.c:68:9: warning: symbol 'buf' was not declared. Should it be static? Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: do not use plain 0 as NULL [smatch scan]Sami Kerola2017-02-201-1/+1
| | | | | | | | | | text-utils/tailf.c:69:21: warning: Using plain integer as NULL pointer Since many 'struct option' has used zero as NULL make them more readable in same go by reindenting, and using named argument requirements. Reference: https://lwn.net/Articles/93577/ Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* 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: (gpt) make sure it's GPT in public APIKarel Zak2017-02-171-3/+9
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: verify partno from templateKarel Zak2017-02-172-2/+3
| | | | | | | * 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: classify collision typeKarel Zak2017-02-145-4/+29
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: check for collisions when create new labelKarel Zak2017-02-144-50/+57
| | | | | | | | 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-102-9/+7Star
| | | | | | | 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>
* sfdisk: --quiet fixesKarel Zak2017-02-101-0/+1
| | | | | Addresses: https://github.com/karelzak/util-linux/issues/412 Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (gpt) add check for entries array sizeKarel Zak2017-01-251-0/+12
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (gpt) make calculations more robustKarel Zak2017-01-161-11/+13
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: apply label alignment propertiesKarel Zak2017-01-163-2/+18
| | | | | | 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-136-11/+20
| | | | | | | | | | | | | | | | 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: recount size when apply user device propertiesKarel Zak2017-01-131-1/+10
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: don't use blkdev ioctls for regular filesKarel Zak2017-01-135-9/+42
| | | | | | | | | | | | | $ 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: (sun) use self_label()Karel Zak2017-01-051-2/+2
| | | | 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>
* sfdisk: support empty label use-caseKarel Zak2016-11-303-1/+25
| | | | | | | | | | | | | | | By default sfdisk creates partition table when a first partition is specified, otherwise the device is not modified. This force users to create at least one partition. This commit allows to create empty label without partitions if "label: <name>" header line is specified by script. The commit also modifies "New situation:" output to list label name and label identifier. Addresses: https://github.com/karelzak/util-linux/issues/374 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: once again some printf format stringsRuediger Meier2016-10-271-1/+3
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>