summaryrefslogtreecommitdiffstats
path: root/libfdisk/src/script.c
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: fix typosMarcos Mello2019-06-201-5/+5
|
* libfdisk: fix fdisk_script_get_table()Karel Zak2019-06-171-13/+19
| | | | | | Make sure we never return NULL and we reuse the table in code. Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: add fdisk_script_set_table()Karel Zak2019-06-171-13/+63
| | | | | | | | | | | | 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>
* docs: fix typos [codespell]Sami Kerola2019-02-181-1/+1
| | | | | Reference: https://github.com/codespell-project/codespell Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* 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: accept grain script headerKarel Zak2018-09-121-1/+23
| | | | | | | | | | | | 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: 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: 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: (script) be consistent in code with typesKarel Zak2018-01-121-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (script) support R (RAID) and V (LVM) shortcutsKarel Zak2018-01-091-0/+13
| | | | | Addresses: https://github.com/karelzak/util-linux/issues/560 Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: Fix uninitialized structureRoddy Shuler2017-11-031-1/+1
| | | | | | | | Without this, 'sfdisk -d' with certain filenames would lead to reading an 's' from the 'type' field in fdisk_reset_labelitem and cause a crash due to prematurely freeing the 'data.str' field. Signed-off-by: Roddy Shuler <roddy@endlessm.com>
* libfdisk: add fdisk_reassign_device()Karel Zak2017-07-101-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: fix reassigned values before old ones has been used [cppcheck]Sami Kerola2017-06-141-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libfdisk: update docsKarel Zak2017-05-231-3/+2Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: (docs) add missing 'since' tagsKarel Zak2017-05-231-0/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* sfdisk: support empty label use-caseKarel Zak2016-11-301-1/+19
| | | | | | | | | | | | | | | 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: (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>
* 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>
* 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: use table-length in dump for non-standard PTKarel Zak2016-05-181-8/+15
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: make table-length usage more robustKarel Zak2016-05-181-3/+8
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* sfdisk: Add support for altering GPT sizeSassan Panahinejad2016-05-181-2/+13
| | | | Adds a header option to alter the GPT table length
* libfdisk: fix ref.counting in fdisk_apply_script() [clang analyze]Karel Zak2016-03-301-4/+10
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: again fixing many printf format stringsRuediger Meier2016-03-071-10/+10
| | | | | | | | | | | | | | | | | | | 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>
* 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-4/+4
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* tests: fix compiler warnings [-Wmissing-prototypes]Ruediger Meier2016-02-231-4/+4
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* libfdisk: fix compiler warnings [-Wmissing-prototypes]Ruediger Meier2016-02-231-1/+1
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* libfdisk: add missing breakKarel Zak2016-02-091-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* sfdisk: add ESP shortcut also for Legacy MBRKarel Zak2016-02-081-0/+2
| | | | | References: https://github.com/karelzak/util-linux/issues/267 Signed-off-by: Karel Zak <kzak@redhat.com>
* sfdisk: add 'U' shortcut for ESPKarel Zak2016-02-011-0/+3
| | | | | | | | | echo -e ',512M,U\n,,L' | sfdisk --label gpt /dev/foo to make ESP system partition. References: https://github.com/karelzak/util-linux/issues/267 Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: cleanup assert() usageKarel Zak2015-08-041-8/+2Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: result of operation is garbage or undefined [clang analyze]Karel Zak2015-07-291-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: add JSON dump outputKarel Zak2015-06-151-10/+179
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: rename script functions to improve readabilityKarel Zak2015-06-151-6/+6
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: fix scriptk parser to support alone signsKarel Zak2015-04-221-6/+8
| | | | | | for example echo "- - - *" | sfdisk /dev/sda1 -N1 Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: fix script parser to support resize operationsKarel Zak2015-04-221-4/+26
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: add fgets() callback for scriptsKarel Zak2015-03-251-1/+55
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: add {first,last}-lba header to sfdisk scritpsKarel Zak2015-03-021-2/+21
| | | | | | | | | | | | | | | | | | | | | | The current sfdisk does not allow to create partition that starts before the default libfdisk First LBA (~1MiB). It means that # sfdisk --dump /dev/sda > foo # sfdisk /dev/sdb < foo does not work on systems where 1st partition does not start at offset 2048. This patch add new headers to scripts to inform libfdisk about different First/Last LBA ranges. For example: label: gpt first-lba: 34 allows to override the library default. Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: support unknown partition types in sfdisk scriptsKarel Zak2015-01-281-2/+2
| | | | | Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1183234 Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: accept Start offset in {B,M,G..}iB in sfdisk scriptsKarel Zak2015-01-201-3/+10
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: fix some typosKarel Zak2015-01-131-3/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: add API docsKarel Zak2014-11-261-5/+8
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* agetty: fix typoKarel Zak2014-11-211-0/+12
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: fix script parser, add debug messagesKarel Zak2014-11-121-7/+26
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: cleanup parttype APIKarel Zak2014-10-151-2/+2
| | | | | | | * add reference counting * add functions to set allocated types Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: make it possible to use zero for size and startKarel Zak2014-10-151-3/+3
| | | | | | | | | | | | | | | | The zero may be valid size and start of the partition. This patch introduces: fdisk_partition_has_start() fdisk_partition_has_size() fdisk_partition_unset_size() fdisk_partition_unset_start() to make it possible to work with zero. The feature is internally implemented by magic constant ((type) -1) for undefined sizes and offsets. Signed-off-by: Karel Zak <kzak@redhat.com>