summaryrefslogtreecommitdiffstats
path: root/disk-utils/partx.c
Commit message (Collapse)AuthorAgeFilesLines
* partx: don't report ENXIO as error on -dKarel Zak2019-08-211-2/+1Star
| | | | | | | | | | | | | | | | | The errno ENXIO should be ignored, unfortunately the current code uses variable 'rc' for ioctl return code as well as for final del_parts() return value. So, failed ioctl (which should be ignored) affects all del_parts() status. # modprobe scsi_debug dev_size_mb=100 # partx -d --nr 1-1024 /dev/sdc; echo $? 1 The device dos not contains any partitions, so 0 return code is expected in this case. Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1739179 Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: consolidate version printing and close_stdout()Karel Zak2019-04-161-3/+2Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* partx: use new ul_path_* APIKarel Zak2018-06-211-4/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* partx: exit with error code when partition read failedAndreas Henriksson2018-06-181-1/+3
| | | | | | | | | | | | | | | | | | | Make sure partx exits with a non-0 return code when it runs into either code-path where getting the partition table failed (or wasn't even attempted because of previous error condition). Change was tested using: touch /tmp/foobar partx -s - /tmp/foobar Previously that was only printing an error/warning message and then exiting with 0, but after this change it exits with 1. Signed-off-by: Andreas Henriksson <andreas@fatal.se> Reported-by: Juan Céspedes <cespedes@debian.org> Addresses: https://bugs.debian.org/898426
* partx: add --output-all optionSami Kerola2018-05-031-1/+8
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: consolidate macro style USAGE_HELP_OPTIONSRuediger Meier2017-06-291-2/+2
| | | | | | | | | changed in include/c.h and applied via sed: sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c") sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c") Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: introduce print_usage_help_options()Ruediger Meier2017-06-271-2/+1Star
| | | | | | | | | | | | Consolidate --help and --version descriptions. We are now able to align them to the other options. We changed include/c.h. The rest of this patch was generated by sed, plus manually setting the right alignment numbers. We do not change anything but white spaces in the --help output. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: never use usage(stderr)Ruediger Meier2017-06-261-6/+8
| | | | | | | Here we fix all cases where we have usage(FILE*) functions. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: consolidate usage() "Available columns"Karel Zak2017-06-261-2/+1Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: consolidate smartcols error messagesKarel Zak2017-05-181-4/+4
| | | | | | ... just to keep translators happy Signed-off-by: Karel Zak <kzak@redhat.com>
* partx: add --list-types optionSami Kerola2017-05-031-1/+15
| | | | | | | Use libblkid as the source of truth what partition type names exist, and are supported. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: add static keyword to where needed [smatch scan]Sami Kerola2017-02-201-2/+2
| | | | | | | text-utils/rev.c:68:9: warning: symbol 'buf' was not declared. Should it be static? Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* docs: Fix word repetitionsYuri Chornoivan2017-02-131-1/+1
|
* partx: add --sector-size optionKarel Zak2017-01-131-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | /dev/sdc is 4K disk: # fdisk -l /dev/sdc Disk /dev/sdc: 100 MiB, 104857600 bytes, 25600 sectors ... Device Boot Start End Sectors Size Id Type /dev/sdc1 1024 25599 24576 96M 83 Linux let's use it as disk image: # dd if=/dev/sdc of=~/sdc.img # losetup -f ~/sdc.img old version: # partx --show /dev/loop0 NR START END SECTORS SIZE NAME UUID 1 1024 25599 24576 12M 6a4ba75b-01 new version: # partx --show /dev/loop0 --sector-size 4096 NR START END SECTORS SIZE NAME UUID 1 8192 204799 196608 96M 6a4ba75b-01 Addresses: https://github.com/karelzak/util-linux/issues/396 Signed-off-by: Karel Zak <kzak@redhat.com>
* Use --help suggestion on invalid optionKarel Zak2016-12-191-2/+1Star
| | | | | | | | The current default is to print all usage() output. This is overkill in many case. Addresses: https://github.com/karelzak/util-linux/issues/338 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>
* partx: fix --nr usageKarel Zak2016-03-221-14/+45
| | | | | Reported-by: Serge van den Boom <serge+util-linux@vdboom.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* Revert "include sysmacros.h where used"Karel Zak2016-03-081-1/+0Star
| | | | This reverts commit 46a40c018438b7b2b25083a5e5a4a21055a0c1e9.
* include sysmacros.h where usedMike Frysinger2016-03-081-0/+1
| | | | | | | | BSD/Linux systems stick major/minor/makedev in sysmacros.h. Newer Linux libraries have been moving away from including sysmacros.h implicitly via sys/types.h, so include it directly. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* lib: remove openat fallback functions (include/at.h)Ruediger Meier2016-03-071-2/+1Star
| | | | | | | | | | | | | | I have validated that we are still compatible at least back to - openSUSE 11.4 - SLE 11 - RHEL/CentOS 6 - OSX 10.10.x, (Xcode 6.3) - FreeBSD 10.2 Confirmed incompatibility: - OSX 10.9.x, (Xcode 6.2) Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: fix compiler warnungs (unsigned/signed)Ruediger Meier2016-02-231-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* lib/strutils: fix string_add_to_idarray() int vs. size_tKarel Zak2015-04-221-1/+2
| | | | | | | | | | | | | | | | | | | | The function uses "int" as argument, but for array size (and index) is better to use unsigned type (size_t). If we mix "size_t" in util (e.g. fdisk) and "int" in lib/strutils.c then result is unexpected behavior on ppc64. # sfdisk --list -o DEVICE,START,SIZE /dev/sdb Disk /dev/sdb: 50 MiB, 52428800 bytes, 102400 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 32768 bytes Disklabel type: gpt Disk identifier: 3B8559DB-33AF-43E9-BEFC-C331D829B539 lt-sfdisk: libfdisk/src/label.c:178: fdisk_label_get_field: Assertion `id > 0' failed. The patch cleanup all code to use size_t everywhere. Signed-off-by: Karel Zak <kzak@redhat.com>
* textual: grammarize and harmonize the stat error messageBenno Schulenberg2015-02-021-1/+1
| | | | | | | | | The message "stat failed %s" seems to say that stat() failed to do something, or failed to pass a test, but of course it means that the statting of something failed. So say so. Also make two very similar messages equal to this one. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* partx: simplify a --verbose progress messageBenno Schulenberg2015-01-121-1/+1
| | | | | Reported-by: Antonio Ceballos <aceballos@gmail.com> Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* partx: add --update to ul_excl_twq listKarel Zak2015-01-121-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* textual: add a docstring to most of the utilitiesBenno Schulenberg2015-01-061-0/+3
| | | | | | | | | This adds a concise description of a tool to its usage text. A first form of this patch was proposed by Steven Honeyman (see http://www.spinics.net/lists/util-linux-ng/msg09994.html). Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* libsmartcols: add debug messagesKarel Zak2014-06-061-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: clean up flags usageKarel Zak2014-04-031-4/+4
| | | | | | | | | * rename flags functions to scols_table_enable_* * rename *_no_foo() functions to _nofoo() * output formats are mutually exclusive, so don't use flags there * don't assume symbols in scols_new_table(), use scols_table_set_symbols() Signed-off-by: Karel Zak <kzak@redhat.com>
* partx: cleanup libsmartcols usageKarel Zak2014-04-031-11/+22
| | | | | | | * more carefully set data * care about return codes Signed-off-by: Karel Zak <kzak@redhat.com>
* partx: use libsmartcolsOndrej Oprala2014-04-031-29/+39
| | | | Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
* partx: make dirent d_type usage more robustKarel Zak2014-03-041-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* partx: use blkid_partlist_get_partition_by_partno()Karel Zak2014-01-151-32/+1Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* partx: fix --update ranges and out of order tablesScott Moser2014-01-141-25/+50
| | | | | | | | | | | | partx --update DEVICE NUMBER was broken in 2 cases: * if NUMBER != 1 * if the partition table was "out of order". Ie, where sda2 came after sda3. References: https://bugs.launchpad.net/ubuntu/+source/cloud-utils/+bug/1244662 Signed-off-by: Scott Moser <smoser@ubuntu.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* partx: correct three messagesBenno Schulenberg2013-10-081-4/+4
| | | | | | | | Properly describing the partition type, using a verb instead of a noun, putting the blank line after the command options, and using the correct argument for --output. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* partx: pluralize one messageBenno Schulenberg2013-10-081-1/+3
| | | | | Reported-by: Petr Písař <petr.pisar@atlas.cz> Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* partx: use TT_FL_FREEDATA for tt tableKarel Zak2013-09-161-15/+7Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* partx: check writing to a file descriptor was successfulSami Kerola2013-04-261-1/+3
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* partx: remove deprecated option from usage()Sami Kerola2013-04-051-1/+0Star
| | | | | | | The fact that -l, --list is deprecated will remain in manual page till unforeseeable future. Meanwhile the usage() can be made shorter. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* partx: make usage() translator friendlySami Kerola2013-01-251-13/+13
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* partx: add update commandPhillip Susi2012-12-191-3/+109
| | | | | | | Update the kernel partition table to match what is on disk. Remove any extra partitions and add any missing ones. Signed-off-by: Phillip Susi <psusi@ubuntu.com>
* partx: don't care about xasprintf() return codeKarel Zak2012-12-121-12/+8Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* partx: support -o +<attr> for adding attribute to output fieldsMilan Broz2012-07-261-5/+7
| | | | | Signed-off-by: Milan Broz <mbroz@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* partx: use err_exclusive_options()Karel Zak2012-07-261-7/+15
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* translation: unify file open error messagesSami Kerola2012-07-161-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* translation: unify stat error messagesSami Kerola2012-07-161-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* build-sys: move partx to disk-utils/Karel Zak2012-06-261-0/+881
Signed-off-by: Karel Zak <kzak@redhat.com>