summaryrefslogtreecommitdiffstats
path: root/libfdisk
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* Merge branch '2017wk11' of git://github.com/kerolasa/lelux-utiliteetitKarel Zak2017-03-241-4/+4
|\ | | | | | | | | | | | | | | | | * '2017wk11' of git://github.com/kerolasa/lelux-utiliteetit: blkid: add control struct blkid: simplify version option handling tests: add static keyword where needed [smatch scan] tests: do not use plain 0 as NULL [smatch scan] libsmartcols: fix test variable shadowing
| * tests: do not use plain 0 as NULL [smatch scan]Sami Kerola2017-03-171-4/+4
| | | | | | | | | | | | Likewise commit 87918040658f2fa9b1bf78f1f8f4f5c065a2e3a3. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* | 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: add sample-fdisk-mkpart binaryKarel Zak2017-02-173-0/+184
| | | | | | | | | | | | | | | | | For example: # sample-fdisk-mkpart --device /dev/sdc 1M 2M 3M - 5M # fdisk -l /dev/sdc ... Device Boot Start End Sectors Size Id Type /dev/sdc1 2048 4095 2048 1M 83 Linux /dev/sdc2 4096 8191 4096 2M 83 Linux /dev/sdc3 8192 14335 6144 3M 83 Linux /dev/sdc4 14336 204799 190464 93M 5 Extended /dev/sdc5 16384 26623 10240 5M 83 Linux Addresses: https://github.com/karelzak/util-linux/issues/204 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: (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-146-4/+30
| | | | 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-136-9/+43
| | | | | | | | | | | | | $ 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>
* docs: replace FTP by HTTPS in kernel.org URLsSébastien Helleu2016-12-191-1/+1
| | | | | | | The links to ftp://ftp.kernel.org/ are replaced by https://www.kernel.org/. 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>
* libfdisk: cleanup labelitem initializationKarel Zak2016-10-273-2/+12
| | | | | | | | * use macro for label initialization * make sure we do not call fdisk_ref_labelitem() and fdisk_unref_labelitem() for non-allocated items Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: fix uninitialized fdisk_labelitemRuediger Meier2016-10-271-1/+1
| | | | | | | | | | | | | | | fdisk -l could crash randomly. Only seen on some i586 systems with certain exotic compiler options. The problem was that this item is later used in function fdisk_reset_labelitem() like this: if (li->type == 's') free(li->data.str); This may crash if item is randomly initialized. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* libfdisk: (script) make bootable flag parsing more robustKarel Zak2016-10-261-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: add trivial script testKarel Zak2016-10-261-0/+19
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: fix unsigned int usage for ctype.h functionsKarel Zak2016-10-261-2/+2
| | | | | Reported-by: "Yuriy M. Kaminskiy" <yumkam@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: make script token parser more robustKarel Zak2016-10-251-3/+29
| | | | | | | | | | * make sure token is terminated * skip closing quotes * allow extra space after quotes and before terminater * skip extra space after terminater Addresses: https://github.com/karelzak/util-linux/issues/367 Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: fix script Type= and Id= parsingKarel Zak2016-10-251-2/+1Star
| | | | | | | | The parser is not consistent and *case insensitive* Type= and Id= tokens are not expected on all places. Addresses: https://github.com/karelzak/util-linux/issues/367 Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (gpt) make attributes parser more robustKarel Zak2016-10-251-5/+14
| | | | | | | | * allow GUID: prefix only for numbers * require space or comma separator Addresses: https://github.com/karelzak/util-linux/issues/367 Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/crc32: prefix public functionsGustavo Zacarias2016-10-191-1/+1
| | | | | | | | | | | Make the publicly-visible crc32 library functions prefixed by ul_, such as crc32() -> ul_crc32(). This is because it clashes with the crc32() function from zlib. For newer versions of glib (2.50+) zlib and libblkid are required dependencies and otherwise results in build failure when building statically. Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
* docs: some random fixesKarel Zak2016-09-273-20/+22
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (docs) add missing version notesKarel Zak2016-09-273-2/+8
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>