summaryrefslogtreecommitdiffstats
path: root/include
Commit message (Collapse)AuthorAgeFilesLines
...
* misc: consolidate macro style USAGE_HELP_OPTIONSRuediger Meier2017-06-291-4/+2Star
| | | | | | | | | 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/+9
|\ | | | | | | | | | | | | | | | | | | | | | | * '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
| * lsmem: fix, using freed memoryRuediger Meier2017-06-291-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Simply avoiding strdup(). Error handling improved. This was the Clang Analyzer warning: Memory Error, Use-after-free sys-utils/lsmem.c:259:3: warning: Use of memory after it is freed err(EXIT_FAILURE, _("Failed to open %s"), path); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
| * lib/path: fix crash, pathbuf overflowRuediger Meier2017-06-271-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: $ lscpu -s "$(tr '\0' 'x' < /dev/zero | head -c 10000)" Segmentation fault (core dumped) After: $ lscpu -s "$(tr '\0' 'x' < /dev/zero | head -c 10000)" lscpu: invalid argument to --sysroot: File name too long Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* | docs: remove some old history from manpagesRuediger Meier2017-06-292-2/+2
|/ | | | | | | | We assume that users will have a kernel >= 2.6.0 and removel references to earlier kernels. There are still a few ones left. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: update --help content againRuediger Meier2017-06-271-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We change -h, --help display this help and exit -V, --version output version information and exit to -h, --help display this help -V, --version print version Some thoughts about this: * use "display" for --help because it matches better if we would add pager support (like git --help) * "print" for --version to be different * "this" for --help is important to make clear that running --help would not give you any better information than the one you see already * remove "information and exit" because it's bloat for the short-help, everybody knows what it does if it exists In the manpages we should use the old, longer but more correct descriptions, inclusive a reminder if --help/--version are only working when used as the only option. Note the term "version information" indicates that we don't only print a single version number. CC: J William Piggott <elseifthen@gmx.com> Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: introduce print_usage_help_options()Ruediger Meier2017-06-271-2/+12
| | | | | | | | | | | | 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: revert to the old USAGE_HELP stringsRuediger Meier2017-06-261-2/+2
| | | | | | | | | | | | | | This reverts the include/c.h part of cc7cb070. As discussed on ml. Our current strings are imported from coreutils and not too bad. Also the old strings are still hardcoded at many places. So let's revert the change, then consolidate these strings really everywhere and then think again whether and how we should change them. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: consolidate usage() "Available columns"Karel Zak2017-06-261-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* Merge branch '170622' of github.com:jwpi/util-linuxKarel Zak2017-06-261-1/+3
|\ | | | | | | | | | | | | | | * '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-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | * 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-261-5/+2Star
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | * '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
| * | lib: fix strutils.h, remove STRTOXX_EXIT_CODERuediger Meier2017-06-221-5/+2Star
| |/ | | | | | | | | | | | | | | | | 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: no more errtryh()Ruediger Meier2017-06-251-6/+0Star
|/ | | | | | | 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>
* hwclock: update --help content and grammarJ William Piggott2017-06-211-2/+2
| | | | | Reviewed-by: Karel Zak <kzak@redhat.com> Signed-off-by: J William Piggott <elseifthen@gmx.com>
* include: update pathnames.hJ William Piggott2017-06-211-24/+12Star
| | | | | | | | | | | | | | | | * use /dev/rtc0 (/dev/rtc was for the 'old' driver) * remove hwclock Award workaround and alpha cmos paths * relocate _PATH_BTMP from hwclock to login-utils * add a comment for _PATH_BTMP and fix other login-utils comments * add a comment for proc/cpuinfo * remove empty shutdown.c comment from 4d43977f Review changes * remove 'used in' comments * white space fixes Reviewed-by: Karel Zak <kzak@redhat.com> Signed-off-by: J William Piggott <elseifthen@gmx.com>
* hwclock: add usage() functions headingJ William Piggott2017-06-211-0/+1
| | | | | | | | | | | Make a functions heading, similar to the existing options heading. * include/c.h: define USAGE_FUNCTIONS * Documentation/boilerplate.c: add USAGE_FUNCTIONS * sys-utils/hwclock.c add functions header to usage() Reviewed-by: Karel Zak <kzak@redhat.com> Signed-off-by: J William Piggott <elseifthen@gmx.com>
* libfdisk: cleanup sun label checksum usuageRuediger Meier2017-06-131-1/+1
| | | | | | | | | | | | | | 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>
* lib/ttyutils: return terminal lines tooKarel Zak2017-06-121-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/colors: Fix bug where help text was not being translated.Sebastian Rasmussen2017-05-281-2/+2
| | | | This affected cfdisk, fdisk, sfdisk, cal, dmesg and hexdump.
* include/exitcodes: remove mount(8) exit codesKarel Zak2017-04-271-10/+0Star
| | | | | | All defined by libmount now. Signed-off-by: Karel Zak <kzak@redhat.com>
* Merge branch '170415' of github.com:jwpi/util-linuxKarel Zak2017-04-261-3/+4
|\ | | | | | | | | | | | | | | | | * '170415' of github.com:jwpi/util-linux: optutils.h: don't print non-graph characters hwclock: improve audit control hwclock: --set and --predict segmentation fault hwclock: make epoch functions alpha only hwclock: improve default function handling
| * optutils.h: don't print non-graph charactersJ William Piggott2017-04-191-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is no eloquent way to exclude/include arch dependent arguments from the ul_excl_t array. So when an arch dependent argument is left undefined err_exclusive_options() was printing out-of-bounds values. This commit cause them to be skipped instead. err_exclusive_options() shouldn't be printing out-of-bounds values in any case. Also change the error massage from 'options' to 'arguments' as some programs, like hwclock, distinguish between options and functions. Signed-off-by: J William Piggott <elseifthen@gmx.com>
* | libfdisk: fix NLS supportKarel Zak2017-04-251-2/+12
|/ | | | | | | | | | | | | | | | | | | 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>
* agetty: fix characters reorder in login promptKarel Zak2017-03-271-0/+4
| | | | | | | | | | | | | | The current agetty uses TIOCSTI ioctl to return already read chars from login name back to the terminal (without read() before tcsetattr() we will lost data already written by user). The ioctl based solution is fragile due to race -- we can return chars when terminal already contains another new chars. The result is reordered chars in login name. The solution is to use extra buffer for already read data. Reported-by: Michael Tretter <m.tretter@pengutronix.de> Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: add missing header fileKarel Zak2017-03-231-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* Merge remote-tracking branch 'jwpi/hwclock-date7'Karel Zak2017-03-232-0/+327
|\ | | | | | | | | | | | | | | * jwpi/hwclock-date7: lib: add parse-date documentation hwclock: use parse_date function build-sys: add parse-date.y lib: add parse-date.y
| * lib: add parse-date.yJ William Piggott2017-03-042-0/+327
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * include/timeutils.h Add parse-date API * lib/parse-date.y - new file Lib function that parses a date string into a timespec struct. Derived from gnulib-dd7a871 parse-datetime.y with these changes: * reduced to a single function API renamed to parse_date() * removed gnulib dependencies * removed debugging * converted to util-linux coding style * include/cctype.h - new file Like ctype.h only hard coded to the 'C' locale. Used by lib/parse-date.y. Derived from gnulib-dd7a871 c-ctype.h with these changes: * removed gnulib dependencies * converted to util-linux coding style * add requisite util-linux constants Signed-off-by: J William Piggott <elseifthen@gmx.com>
* | include: fix compiler warningSami Kerola2017-03-132-0/+6
|/ | | | | | | | | | | | | | ./include/optutils.h:12:18: warning: null pointer dereference [-Wnull-dereference] for (o = opts; o->name; o++) ~^~~~~~ In file included from libfdisk/src/dos.c:12:0: ./include/pt-mbr.h:25:47: warning: potential null pointer dereference [-Wnull-dereference] return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24); ~^~~ Well these should be impossible, so add assert() to catch possible bugs. 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>
* build-sys: add missing fileKarel Zak2017-02-161-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/mbsedit: add simple buffer editorKarel Zak2017-02-161-0/+32
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* hwclock: improve coding styleSami Kerola2017-02-051-0/+4
| | | | | | | | | Make string constants to be symbolical declarations. Use longer variable name for rtc and cmos function pointer values. Exclude code that is architecture specific with preprocessor directives. And remove message duplication. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib: add timegm() portability function to lib/timeutils.cSami Kerola2017-02-031-0/+4
| | | | | | | | | Local timegm() is a replacement function in cases it is missing from libc implementation. Hopefully the replacement is never, or very rarely, used. CC: Ruediger Meier <ruediger.meier@ga-group.nl> Reviewed-by: J William Piggott <elseifthen@gmx.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib/strutils: return end pointer by isdigit_string()Karel Zak2017-01-281-2/+6
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/list: remove LIST_HEAD macroKarel Zak2017-01-051-5/+0Star
| | | | | | | | | | | | | | | | | | | | | | | | | * the variable definition with hidden type is always horrible, for example: int func() { LIST_HEAD(foo); ... } the more readable is: int func() { struct list_head foo; INIT_LIST_HEAD(&foo); ... } * the name LIST_HEAD conflict with /usr/include/sys/queue.h * we use it only on two places in sulogin Signed-off-by: Karel Zak <kzak@redhat.com>
* Use --help suggestion on invalid optionKarel Zak2016-12-191-0/+6
| | | | | | | | 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>
* include/c.h: add errtryhelp()Karel Zak2016-12-191-0/+9
| | | | | | | | | | Add code to print: Try '<progname> --help' for more information. and exit. Signed-off-by: Karel Zak <kzak@redhat.com>
* agetty: remove obsolete HAVE_UPDWTMP fallbackRuediger Meier2016-12-071-2/+0Star
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* lib,strutils: add strtoux[16|32|64]_or_err functionsHeiko Carstens2016-11-091-0/+3
| | | | | | | Add helper functions which allow to parse hexadecimal numbers. Based on a patch from Clemens von Mann. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
* lib/crc32: prefix public functionsGustavo Zacarias2016-10-191-2/+2
| | | | | | | | | | | 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>
* lib/randutils: remove unnecessary functionKarel Zak2016-10-041-1/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/strutils: make left and right trims more robustSami Kerola2016-09-291-2/+7
| | | | | | | Do not follow null pointer, and stop going any further when ltrim_whitespace() is at the end of a string. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* debug: use const void * for ul_debugobj()Igor Gnatenko2016-09-211-1/+1
| | | | | | | | | | We don't modify data it's pointing out and we should not modify it. Also remove casting to void * as gcc will do it automatically (before we had to cast it explicitly to avoid warning on discarding 'const' qualifier). Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
* libsmartcols: support multi-line cells based on line breaksKarel Zak2016-09-061-1/+1
| | | | | | | | | | Now libsmartcols completely control when and how wrap long lines/cells. This is sometimes user unfriendly and it would be nice to support multi-line cells where wrap is based on \n (new line char). This patch add new column flag SCOLS_FL_WRAPNL. Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/randutils: add xsrand() and rand_get_number()Karel Zak2016-09-061-0/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/pager: cleanup and extend APIKarel Zak2016-08-261-1/+4
| | | | | | | | | * clean up function names * add functions to temporary redirect to the pager and then restore original terminal output Signed-off-by: Karel Zak <kzak@redhat.com>
* loopdev: Implememt loopcxt_set_status()Stanislav Brabec2016-08-171-0/+1
| | | | | | | | | | | | Implement stand-alone loopcxt_set_status(). It allows manipulation with some loop device parameters even if it is initialized. Its function is limited by the kernel implementation, and only a small subset of changes is allowed. For more see linux/drivers/block/loop.c:loop_set_status() Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
* include/closestream: define exit codesKarel Zak2016-08-161-2/+6
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* include/env: minor fixes and clean upsKarel Zak2016-08-161-1/+7
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>