summaryrefslogtreecommitdiffstats
path: root/include/c.h
Commit message (Collapse)AuthorAgeFilesLines
* include/c: add errexec()Karel Zak2018-02-011-0/+6
| | | | | | | | | | | | | | | | The new errexec() macro consolidate and unify the way how util-linux tools react to failed exec()-like functions: * exit code 126 when program located, but not usable * exit code 127 when could not find program to exec The exit codes are compatible with coreutils. Note that all the change is located in c.h; the file exitcodes.h contains API specific (mkfs, fsck, ...) codes only. Addresses: https://github.com/karelzak/util-linux/pull/311 Signed-off-by: Karel Zak <kzak@redhat.com>
* hwclock: update usage()J William Piggott2017-09-051-1/+1
| | | | | | Improve usage strings for debug and version. Signed-off-by: J William Piggott <elseifthen@gmx.com>
* 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>
* 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>
* | 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>
* 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>
* 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>
* 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>
* include: move sys/sysmacros.h to c.hKarel Zak2016-03-081-0/+4
| | | | | | | The file is no portable (#ifdef HAVE_SYS_SYSMACROS_H is necessary), but needed on many places. It seems better to keep it in c.h. Signed-off-by: Karel Zak <kzak@redhat.com>
* include: provide MAP_ANONYMOUS on OSXRuediger Meier2016-02-181-0/+8
| | | | | | | Hope there are no side effect when defining _DARWIN_C_SOURCE globally. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* login, mount: fix __SC_GETPW_R_SIZE_MAX usageKarel Zak2015-12-151-0/+9
| | | | | | | | | | sysconf(_SC_GETPW_R_SIZE_MAX) returns initial suggested size for pwd buffer (see getpwnam_r man page or POSIX). This is not large enough in some cases. Yes, this sysconf option is misnamed (should be _SC_GETPW_R_SIZE_MIN). Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: add --disable-assertKarel Zak2015-08-041-0/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* include/c: Define F_DUPFD_CLOEXEC on kFreeBSD systems if missingGuillem Jover2015-06-081-0/+6
| | | | | | | The kernel of FreeBSD version 10 and higher supports this fcntl command, but the system libc, in this case glibc, might not yet know about it. Signed-off-by: Guillem Jover <guillem@hadrons.org>
* include/c: define UL_ASAN_BLACKLIST address_sanitizer function attributeSami Kerola2014-12-191-0/+17
| | | | | | | | The UL_ASAN_BLACKLIST allows AddressSanitizer to be switched off for functions that cannot be checked. Reference: http://dxr.mozilla.org/mozilla-central/source/mfbt/Attributes.h Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libfdisk: fix bug in cmp_numbers() and partitions sortingKarel Zak2014-12-041-1/+1
| | | | | Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1170191 Signed-off-by: Karel Zak <kzak@redhat.com>
* libfdisk: fix cfdisk freespace analyzeKarel Zak2014-12-041-0/+8
| | | | | | | | | The problem is how fdisk_partition_cmp_start() compare numbers, the function returns result from "a->start - b->start", unfortunately the numbers are uint64, but function returns "int". Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1170191 Signed-off-by: Karel Zak <kzak@redhat.com>
* include: fix compiler warningsSami Kerola2014-10-011-5/+5
| | | | | | | | | | | | | | | | | This change has motivation to make -Wall -pedantic compiler options to spit a little bit less noise, which with luck will increase change to notice real issues. Multiple of these: warning: ISO C forbids braced-groups within expressions [-Wpedantic] And nearly 300 times reported: include/c.h:75:41: warning: struct has no named members [-Wpedantic] #define UL_BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); })) Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* include/c: do not gettextize a wordless stringBenno Schulenberg2014-05-061-1/+1
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* include/c: remove a duplicate includeBenno Schulenberg2014-05-061-10/+7Star
| | | | | | Also tweak some comments. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* include/c.h: add macro to print definitions as stringSami Kerola2014-05-041-0/+9
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* include/c.h: prefer nanosleep() over usleep()Karel Zak2014-01-241-5/+12
| | | | | | | | | | | | | | Let's use nanosleep() although if usleep() exists. The nanosleep function does no interact with signals and other timers. The patch introduces xusleep() as replacement to libc (or our fallback) usleep(). Yes, we don't want to use struct timespec + nanosleep() everywhere in code as nano-time resolution is useless for us. The patch also enlarges delays in some busy wait loops. It seems enough to try read/write 4x per second. Signed-off-by: Karel Zak <kzak@redhat.com>
* include/xalloc: add warn_unused_result to allocation functionsKarel Zak2013-07-091-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* include/c: add macro UL_CLOEXECSTRKarel Zak2013-04-031-0/+8
| | | | | | ... to make "e" for fopen() portable to systems without O_CLOEXEC. Signed-off-by: Karel Zak <kzak@redhat.com>
* docs: arch is gone, use delpart as usage() function exampleSami Kerola2013-03-261-1/+1
| | | | | | The arch.c was removed in commit 27abd809. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* sulogin: make usleep() workaround workWerner Fink2012-12-181-3/+7
| | | | | | Simply fix a compile problem found during debugging console.c Signed-off-by: Werner Fink <werner@suse.de>
* include/c: move usleep() fallback to c.hKarel Zak2012-10-221-0/+15
| | | | | | To make it available everywhere in code. Signed-off-by: Karel Zak <kzak@redhat.com>
* include/c: remove MAXHOSTNAMELEN macroKarel Zak2012-10-191-11/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* include/c: add get_hostname_max() inline functionSami Kerola2012-10-191-0/+18
| | | | | | | | | | | | Using sysconf(_SC_HOST_NAME_MAX) does not work everywhere. At such even header values for hostname length should be preferred, and if nothing else works guess the maxium being 64 bytes. Based-on-code-by: Karel Zak <kzak@redhat.com> CC: Mike Frysinger <vapier@gentoo.org> References: http://www.spinics.net/lists/util-linux-ng/msg07050.html Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* dmesg: add fileback for SEEK_DATAKarel Zak2012-07-241-0/+11
| | | | | Reported-by: Bernhard Voelker <mail@bernhard-voelker.de> Signed-off-by: Karel Zak <kzak@redhat.com>
* include/c: move fallback for MAXHOSTNAMELEN to c.hKarel Zak2012-05-291-0/+11
| | | | | Reported-by: Thomas Schwinge <thomas@codesourcery.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* include: [c.h] protect container_ofmaximilian attems2012-05-231-0/+2
| | | | | | | | | | fixes lots of warning noise: ../../../include/c.h:112:0: warning: "container_of" redefined [enabled by default] /usr/lib/klibc/include/stddef.h:52:0: note: this is the location of the previous definition Signed-off-by: maximilian attems <max@stro.at>
* losetup: make xgetpass more robustKarel Zak2012-01-171-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lists: add list sorting routineDavidlohr Bueso2011-12-161-0/+8
| | | | | | | | | | | | | | | | | We need a list sorting function, just to mention one example user that could benefit is the lib/tt code to sort columns. This patch adds list_sort() which uses the Merge Sort algorithm, behaving nicely in O(nlog(n)), heavily based on the kernel's implementation[1]. The private data (void *priv) passed to the comparison function as been removed to adopt a qsort(3)-like syntax, and IMHO we don't really need it anyways. [1]: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=lib/list_sort.c;h=d7325c6b103f0be078ff3672c35c468ed35738f1;hb=HEAD [kzak@redhat.com: - use size_t in list_sort()] Signed-off-by: Davidlohr Bueso <dave@gnu.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: check scanf %ms modifierKarel Zak2011-10-101-0/+9
| | | | | | | | | | | | Without the check libmount builds on systems that has older than 2.7 glibc are silently unsuccessful. The missing %ms modifier will, at least, result on such system missing output of findmnt and lsblk commands. If either %ms or %as modifiers are present the libmount build is disabled. Based on patch from: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: rename BUILD_BUG_ON_ZERO definitionSami Kerola2011-10-101-2/+2
| | | | | | | | | | | | Definition name is changed to UL_BUILD_BUG_ON_ZERO to avoid collision with a system header. ../include/c.h:72:1: warning: "BUILD_BUG_ON_ZERO" redefined In file included from /usr/include/sys/sysinfo.h:25, from dmesg.c:16: /usr/include/linux/kernel.h:34:1: warning: this is the location of the previous definition Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: use %m in format string instead of %s and strerror(errno)Petr Uzel2011-09-271-1/+1
| | | | Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
* Merge branch 'sys-utils' of https://github.com/kerolasa/lelux-utiliteetitKarel Zak2011-09-271-2/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 'sys-utils' of https://github.com/kerolasa/lelux-utiliteetit: (29 commits) docs: add non-return function and if shorthand tips build-sys: fixes to USAGE_* macros ipcrm: check IPC syscalls ipcrm: add --verbose option ipcmk: allow high speed ipc creation ipcrm: add --all option docs: add long options to ipcs.1 man page docs: add long options to ipcrm.1 man page docs: add long options to ipcmk.1 man page docs: add --version to setarch.8 docs: mention long options in ctrlaltdel.8 ctrlaltdel: add version & help options docs: mention long options in pivot_root.8 pivot_root: add version & help option ipcs: comment & white space clean up ipcs: include-what-you-use header check ipcs: add long options ipcrm: include-what-you-use header check ipcrm: refactor new and old main to share code ipcrm: exit if unknown error occurs ...
| * build-sys: fixes to USAGE_* macrosSami Kerola2011-09-171-2/+2
| | | | | | | | | | | | | | | | | | | | | | The USAGE_BEGIN_TAIL is removed as unnecessary. In between command specific options and --help & --version USAGE_SEPARATOR is inserted. For now the separator is empty line. The USAGE_MAN_TAIL is changed to take an argument. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* | include,c.h: include fcntl.h before check for O_CLOEXEC [smatch scan]Karel Zak2011-09-121-0/+1
|/ | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* arch: start using arch as a usage() exampleSami Kerola2011-08-281-0/+13
| | | | | | | The arch command is hijacked to be example of howto write usage as defined in Documentation/howto-usage-function.txt Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* include: [c.h] Include stdlib.h unconditionalymaximilian attems2011-08-021-1/+1
| | | | | | | No point in hiding it down in an ifdef maze, as it may get used by exit(3). Signed-off-by: maximilian attems <max@stro.at>
* include: [c.h] move up declaration of program_invocation_short_name before usagemaximilian attems2011-08-021-35/+35
| | | | | | | | | | | fixes: ../include/c.h: In function ‘errmsg’: ../include/c.h:111:26: error: ‘program_invocation_short_name’ undeclared (first use in this function) ../include/c.h:111:26: note: each undeclared identifier is reported only once for each function it appears in Signed-off-by: maximilian attems <max@stro.at>
* include: [c.h] add definition wrappers for old libc versionsDavidlohr Bueso2011-03-291-1/+11
| | | | | Signed-off-by: Davidlohr Bueso <dave@gnu.org> Signed-off-by: Karel Zak <kzak@redhat.com>