summaryrefslogtreecommitdiffstats
path: root/misc-utils
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'patch-1' of https://github.com/aner-perez/util-linuxKarel Zak2017-09-151-1/+1
|\
| * Example for renaming foo? does not work as describedAner Perez2017-09-141-1/+1
| | | | | | Command for renaming foo? should add 2 zeros to make all the file names have 3 digits as described in the example results.
* | uuidparse:fix stack-buffer-overflow [asan]Karel Zak2017-09-151-3/+2Star
| | | | | | | | | | Reported-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* | misc: cleanup UUID_STR_LEN definitionsKarel Zak2017-09-151-2/+0Star
| | | | | | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* | logger: make stdin parsing more friendly to static analyzersKarel Zak2017-09-151-0/+2
|/ | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lsblk: small man page change in return codes descriptionKarel Zak2017-09-071-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* uuidgen: add more details to man pageKarel Zak2017-09-051-1/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* uuidgen: add support for hash-based UUIDsPhilip Prindeville2017-09-052-9/+162
| | | | Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
* misc: replace magic number 37 with UUID_STR_LENPhilip Prindeville2017-09-053-5/+2Star
| | | | Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
* wipefs: cleanup offsets list usage, fix -t filterKarel Zak2017-08-311-110/+99Star
| | | | | | | | | | | * move list with offsets specified by -o to the wipe_control struct * don't clone the list of offsets, just keep it simple and stupid * apply all filters (-o and -t) in get_desc_for_probe() * always return offset and len by get_desc_for_probe() and apply always use libblkid hide & step-back Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1486777 Signed-off-by: Karel Zak <kzak@redhat.com>
* look: use WORDLIST environment variable to find word listSami Kerola2017-08-212-1/+10
| | | | | | | | | | The WORDLIST is the same hunspell(1) and ispell(1) uses to achieve the same. Apparently aspell(1) does not work with files like traditional dict lists. Reference: https://github.com/hunspell/hunspell/blob/master/man/hunspell.1#L388 Reference: http://www.skrenta.com/rt/man/ispell.1.html Reference: http://aspell.net/man-html/Creating-an-Individual-Word-List.html#Creating-an-Individual-Word-List Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* uuidparse: nil uuid have all bits set to zeroSami Kerola2017-08-051-1/+4
| | | | | | | | The nil UUID is special form of UUID that is specified to have all 128 bits set to zero. Reference: https://tools.ietf.org/html/rfc4122#section-4.1.7 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* build: use --runstatedir instead of --localstatedirAndreas Henriksson2017-07-314-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The util-linux code was previously aligned to use @localstatedir@ and the util-linux build system was set to override the default to use /run. Current GNU Coding Standards introduced the @runstatedir@ variable for this purpose. Lets use that instead. The GNU default for @runstatedir@ is ${localstatedir}/run so util-linux still override the default to be /run to preserve the status quo from before. The only difference is that you'll now pass --runstatedir to override the location on the command line instead of --localstatedir. (FWIW, Debhelper in compat 11 will automatically start passing --runstatedir=/run to all autotools configured builds. It already passes --localstatedir=/var (to avoid it ending up with the GNU default /usr/local/var) which breaks the util-linux build system code that tries to default it to /run. This change will thus allow util-linux and debhelper to work better together and avoid the need for a package-specific override.) Relevant historic commits: * commit 07a16b9d1e5a48550a0d19abb9a900853433ffa2 "build-sys: change --localstatedir to /run" * commit 80c51185d50f00a2701f9379f10fc48a0f885dfc "uuidd: use run configured state directory" * commit 01c5b787947aeaffc7e56000827e3edefa357c59 "agetty: use configured run state directory" [kzak@redhat.com: - add $runstatedir fallback for autoconf < 2.70 - check for unmodified $localstatedir] CC: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Andreas Henriksson <andreas@fatal.se> Signed-off-by: Karel Zak <kzak@redhat.com>
* whereis: include native multiarch path in lib search pathsAndreas Henriksson2017-07-311-0/+5
| | | | | | | | | | | | | | | | | This includes atleast the native multiarch path in the paths to search. (Maybe also other multiarch paths should also be searched? But atleast this is a first step.) Before this change (on Debian): $ whereis libc libc: /usr/share/man/man7/libc.7.gz After this change: $ whereis libc libc: /usr/lib/x86_64-linux-gnu/libc.so /usr/lib/x86_64-linux-gnu/libc.a /usr/share/man/man7/libc.7.gz Addresses: https://bugs.debian.org/856968 Signed-off-by: Andreas Henriksson <andreas@fatal.se>
* misc: consolidate macro style USAGE_HELP_OPTIONSRuediger Meier2017-06-2919-37/+37
| | | | | | | | | 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>
* Merge branch 'path-fixes' of https://github.com/rudimeier/util-linuxKarel Zak2017-06-291-2/+1Star
|\ | | | | | | | | | | | | | | | | | | | | | | * 'path-fixes' of https://github.com/rudimeier/util-linux: hwclock: don't ifdef printf arguments setpriv: align --help tools: add segfault detection for checkusage.sh misc: avoid some dead initialization warnings lscpu: make clang analyzer happy lsmem: fix, using freed memory lib/path: add error handling to path_vcreate() lib/path: fix crash, pathbuf overflow
| * misc: avoid some dead initialization warningsRuediger Meier2017-06-291-2/+1Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Clang analyzer warnings: Dead store, Dead initialization: lib/mbsedit.c:154:8: warning: Value stored to 'in' during its initialization is never read char *in = (char *) &c; ^~ ~~~~~~~~~~~ misc-utils/findmnt-verify.c:129:14: warning: Value stored to 'cn' during its initialization is never read const char *cn = tgt; ^~ ~~~ Dead store, Dead increment: sys-utils/hwclock.c:1461:2: warning: Value stored to 'argv' is never read argv += optind; ^ ~~~~~~ Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* | uuidgen: improve --helpKarel Zak2017-06-291-6/+4Star
| | | | | | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* | wipefs: improve --helpKarel Zak2017-06-291-23/+19Star
| | | | | | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* | wipefs: use libsmartcolsKarel Zak2017-06-293-48/+250
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The old output is horrible and useless when more devices specified. The old format is also too tricky if more signatures detected. The new output uses one line for each signature, prefixed by device name. For example my workstation: # wipefs /dev/sda* /dev/sdb* DEVICE OFFSET TYPE UUID LABEL sda 0x1fe PMBR sda 0x37e4895e00 gpt sda 0x200 gpt sda1 0x1fe vfat F2BC-BFEC EFI sda1 0x0 vfat F2BC-BFEC EFI sda1 0x36 vfat F2BC-BFEC EFI sda2 0x438 ext4 c5490147-2a6c-4c8a-aa1b-33492034f927 BOOT sda3 0x438 ext4 196972ad-3b13-4bba-ac54-4cb3f7b409a4 HOME sda4 0x438 ext4 d834bc84-0089-4be1-9013-cd8bf35d5ffa ROOT sda5 0x438 ext4 e8ce5375-29d4-4e2f-a688-d3bae4b8d162 WINE sda6 0xff6 swap 210337c6-f8b5-4d65-aab5-a0f343fa9ad4 SWAP sdb 0x200 gpt sdb 0x1fe dos sdb1 0x438 ext4 6467a684-0d10-4f61-a301-67bb26934d90 This patch add --noheadings, --json and --output. Signed-off-by: Karel Zak <kzak@redhat.com>
* | uuidparse: se JSON table name on -JKarel Zak2017-06-291-1/+4
| | | | | | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* | wipefs: try another magic strings on -o and -tKarel Zak2017-06-281-4/+20
| | | | | | | | | | | | | | | | The commit 92296e9ba2bf95259520fa7537ff8edc2aa9edbc introduces "try all permutations for the same superblock". This feature has to be also available if -o and -t is specified. Signed-off-by: Karel Zak <kzak@redhat.com>
* | wipefs: add control structKarel Zak2017-06-281-66/+64Star
| | | | | | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* | wipefs: don't do step-back if <type> does not matchKarel Zak2017-06-281-5/+14
| | | | | | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* | wipefs: print all signature permutationsKarel Zak2017-06-282-8/+8
|/ | | | | | | | | | | | | The same FS/RAID/PT signature may be detected by more ways and on more places on the device. The libblkid returns only the first detected signature by default. This patch use blkid_probe_hide_range() to re-scan device for all possible permutations of the same signature. For example the default wipefs(8) output as well as --no-act output will contains primary as well as backup GPT signature now. Reported-by: Ruediger Meier <sweet_f_a@gmx.de> Signed-off-by: Karel Zak <kzak@redhat.com>
* Merge branch 'help-description' of https://github.com/rudimeier/util-linuxKarel Zak2017-06-2719-40/+21Star
|\ | | | | | | | | | | | | | | | | | | * 'help-description' of https://github.com/rudimeier/util-linux: misc: update --help content again login: add --help text blockdev: improve --help and man page misc: consolidate all --help option descriptions misc: introduce print_usage_help_options() misc: revert to the old USAGE_HELP strings
| * misc: consolidate all --help option descriptionsRuediger Meier2017-06-273-6/+4Star
| | | | | | | | | | | | | | | | Now we are always using the same text also for commands which had still hardcoded descriptions or where we can't use the standard print_usage_help_options macro. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
| * misc: introduce print_usage_help_options()Ruediger Meier2017-06-2717-34/+17Star
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* | uuidparse: fix getopt crashRuediger Meier2017-06-261-0/+1
|/ | | | | | | | | $ ./uuidparse --unknownopt Segmentation fault (core dumped) Hehe, this is the first real bug found by 'make checkusage'. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* Merge branch 'usage-part2' of https://github.com/rudimeier/util-linuxKarel Zak2017-06-2617-86/+104
|\ | | | | | | | | | | | | | | | | | | | | * 'usage-part2' of https://github.com/rudimeier/util-linux: misc: cosmetics, remove argument from usage(FILE*) misc: cosmetics, remove argument from usage(int) misc: never use usage(stderr) misc: never use usage(ERROR) misc: cleanup and fix --unknownopt issues flock, getopt: write --help to stdout and return 0 tools: add checkusage.sh
| * misc: cosmetics, remove argument from usage(FILE*)Ruediger Meier2017-06-269-27/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch is trivial and changes nothing, because we were always using usage(stdout) Now all our usage() functions look very similar. If wanted we could auto-generate another big cosmetical patch to remove all the useless "FILE *out" constants and use printf and puts rather than their f* friends. Such patch could be automatically synchronized with the translation project (newlines!) to not make the translators sick. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
| * misc: cosmetics, remove argument from usage(int)Ruediger Meier2017-06-261-4/+4
| | | | | | | | | | | | | | This patch is trivial and changes nothing, because we were always using usage(0). Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
| * misc: never use usage(stderr)Ruediger Meier2017-06-264-19/+28
| | | | | | | | | | | | | | Here we fix all cases where we have usage(FILE*) functions. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
| * misc: never use usage(ERROR)Ruediger Meier2017-06-262-11/+13
| | | | | | | | | | | | | | | | | | | | We are using better/shorter error messages and somtimes also errtryhelp(). Here we fix all cases where the usage function took an int argument for exit_code. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
| * flock, getopt: write --help to stdout and return 0Ruediger Meier2017-06-261-25/+23Star
| | | | | | | | | | | | | | | | | | | | ... and use errtryhelp() instead of usage(). Note in past "getopt --help" returned 2. But it is otherwise documented and was just a mistake IMO. See the unreachable exit(0) which was removed here: d1d03b54 Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* | uuidparse: add new commandSami Kerola2017-06-263-0/+431
|/ | | | | | | | | | | This command will analyze and print information about UUID's. The command is based on libuuid/src/uuid_time.c but modified to use libsmartcol. [kzak@redhat.com: - minor coding style changes] Reference: http://marc.info/?l=util-linux-ng&m=149735980715600&w=2 Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: consolidate usage() "Available columns"Karel Zak2017-06-263-3/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* Merge branch '170622' of github.com:jwpi/util-linuxKarel Zak2017-06-261-2/+1Star
|\ | | | | | | | | | | | | | | * '170622' of github.com:jwpi/util-linux: Docs: move option naming to howto-contribute.txt Docs: update howto-usage-function.txt Docs: add a comment for constants to boilerplate.c include/c.h: add USAGE_COMMANDS and USAGE_COLUMNS
| * include/c.h: add USAGE_COMMANDS and USAGE_COLUMNSJ William Piggott2017-06-241-2/+1Star
| | | | | | | | | | | | | | | | | | | | | | | | * login-utils/lslogins.c: all uses changed * misc-utils/findmnt.c: likewise * sys-utils/blkzone.c: likewise * disk-utils/sfdisk.c: likewise * sys-utils/lscpu.c: likewise * sys-utils/lsmem.c: likewise * sys-utils/wdctl.c: likewise Signed-off-by: J William Piggott <elseifthen@gmx.com>
* | Merge branch 'fix-exit-codes' of https://github.com/rudimeier/util-linuxKarel Zak2017-06-262-3/+6
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | * 'fix-exit-codes' of https://github.com/rudimeier/util-linux: misc: fix optutils.h related exit codes misc: fix xalloc.h related exit codes misc: fix more strutils related exit codes lib: fix strutils.h, remove STRTOXX_EXIT_CODE misc: fix some broken exit codes
| * | misc: fix xalloc.h related exit codesRuediger Meier2017-06-221-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Found by: grep -L "XALLOC_EXIT_CODE" $(grep -l "xalloc\.h" \ $(git grep -l "_EX_\|FINDFS_\|BLKID_EXIT\|EX_USAGE" -- "*.c")) Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
| * | lib: fix strutils.h, remove STRTOXX_EXIT_CODERuediger Meier2017-06-221-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | As discussed on the mailing list. We fix all places where the non-working define STRTOXX_EXIT_CODE was used. Regarding tunelp, also see 7e3c80a7. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
| * | misc: fix some broken exit codesRuediger Meier2017-06-221-2/+2
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | These tools have special exit codes. They got changed mistakenly. See: findfs 0e1fa6b6 fsck 658c0891 fsck.cramfs 922ec175 mkfs.cramfs 16154b1f tunelp 2ab428f6 FIXME: STRTOXX_EXIT_CODE doesn't work as it should. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* | misc: no more errtryh()Ruediger Meier2017-06-251-11/+14
| | | | | | | | | | | | | | Nowadays all our regular commands have --help options. test_uuidd does not use translations anyways. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* | whereis: add --help and --versionRuediger Meier2017-06-222-13/+41
| | | | | | | | | | | | | | We can use errtryhelp() now and never print usage to stderr. One may improve all these "bad usage" messages. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* | blkid: use errtryhelp instead of errtryhRuediger Meier2017-06-221-4/+4
| | | | | | | | | | | | We have a --help option and this is preferred. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* | uuidd: remove unused defineRuediger Meier2017-06-221-6/+0Star
|/ | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* wipefs: exit on failed eraseKarel Zak2017-06-211-1/+1
| | | | | | | | | | | | | | | | | The current behavior is to report error and continue, it seems strange: # blockdev --setro /dev/sdc # wipefs -a /dev/sdc wipefs: /dev/sdc: failed to erase xfs magic string at offset 0x00000000: Operation not permitted /dev/sdc: 4 bytes were erased at offset 0x00000000 (xfs): 58 46 53 42 ^^^^^^^^^^^ not true The patch calls err() to exit. Reported-by: Vratislav Podzimek <vpodzime@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: remove stray semicolonsSami Kerola2017-06-141-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: fix reassigned values before old ones has been used [cppcheck]Sami Kerola2017-06-142-5/+5
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>