summaryrefslogtreecommitdiffstats
path: root/include
Commit message (Collapse)AuthorAgeFilesLines
* libblkid: ignore private Stratis devicesTony Asleson2018-03-091-1/+1
| | | | | | | | [kzak@redhat.com: - tiny coding style changes] References: 20e1c3dc03399d6988ef35dedc1364cfc12e9263 Signed-off-by: Tony Asleson <tasleson@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: fix typos using codespellRuediger Meier2018-02-161-1/+1
| | | | | | Some more funny typos, please review carefully. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* 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>
* lib/exec_shell: cleanup function attributesKarel Zak2018-02-011-1/+6
| | | | | Reported-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* cal: Use ALTMON_* correctlyRafal Luzynski2018-01-221-0/+30
| | | | | | | | | | | cal: use ALTMON_* and _NL_ABALTMON_* constants to display months in a standalone form correctly. These constants have just been newly added to glibc. ALTMON_x has been used in BSD family since 1990s and has been accepted as the future POSIX extension. _NL_ABALTMON_* is exclusively a GNU extension but it is expected to be added to POSIX in future. More info: https://sourceware.org/bugzilla/show_bug.cgi?id=10871
* include/debug: introduce __UL_INIT_DEBUG_FROM_STRING()Karel Zak2018-01-171-7/+12
| | | | | | | Let's make it possible to use debug.h without environment variables. Suggested-by: J William Piggott <elseifthen@gmx.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* include/debug: improve debug messageKarel Zak2018-01-121-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* include/debug: print info when addresses suppressedKarel Zak2018-01-121-1/+3
| | | | | Suggested-by: Peter Cordes <peter@cordes.ca> Signed-off-by: Karel Zak <kzak@redhat.com>
* include/debug: don't print pointer address for SUID programsKarel Zak2018-01-123-16/+34
| | | | | | | | | | | | | | | | * introduce new flag __UL_DEBUG_FL_NOADDR to suppress pointer address printing * use __UL_DEBUG_FL_NOADDR when SUID * move ul_debugobj() to debugobj.h, and require UL_DEBUG_CURRENT_MASK to provide access to the current mask from ul_debugobj(). It's better than modify all ul_debugobj() calls and use the global mask as argument. * remove never used UL_DEBUG_DEFINE_FLAG Reported-by: halfdog <me@halfdog.net> Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/md5: use ul_/UL_ prefixKarel Zak2017-12-121-15/+10Star
| | | | | | | The symbols names are too generic. Addresses: https://github.com/karelzak/util-linux/issues/548 Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/sha1: use ul_/UL_prefix for symbolsKarel Zak2017-12-121-34/+15Star
| | | | | | | | Unfortunately, the symbols are visible in statically compiled libuuid and the names are too generic. Addresses: https://github.com/karelzak/util-linux/issues/548 Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/signames: remove unused functionSami Kerola2017-11-281-1/+0Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib/mbsalign: add mbs_invalid_encode()Karel Zak2017-11-221-0/+3
| | | | | | Like mbs_safe_encode(), but it does not care about control chars. Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: add missing includeKarel Zak2017-11-161-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: Add simple crc32c() functionJohn Groves2017-11-161-0/+9
| | | | | | | | Source: freebsd/sys/libkern/crc32.c This code is an unmodified fragment from the source. Will fixup comments / naming in next commit Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/timeutils: add common ISO timestamp masksJ William Piggott2017-11-101-9/+17
| | | | | | | | | | | | | | | | | | | | | | * Start the ISO format flags at bit 0 instead of bit 1. * Remove unnecessary _8601 from ISO format flag names to avoid line wrapping and to ease readability. * ISO timestamps have date-time-timzone in common, so move the TIMEZONE flag to bit 2 causing all timestamp masks to have the first three bits set and the last four bits as timestamp 'options'. * Change the 'SPACE' flag to a 'T' flag, because it makes the code and comments more concise. * Add common ISO timestamp masks. * Implement the ISO timestamp masks in all applicable code using the strxxx_iso() functions. Signed-off-by: J William Piggott <elseifthen@gmx.com>
* lib/timeutils: add get_gmtoff()J William Piggott2017-11-101-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This new function returns the GMT offset relative to its argument. It is used in this patch to fix two bugs: 1) On platforms that the tm struct excludes tm_gmtoff, hwclock assumes a one hour DST offset. This can cause an incorrect kernel timezone setting. For example: Master branch tested with tm_gmtoff illustrates the correct offset: $ TZ="Australia/Lord_Howe" hwclock --hctosys --test | grep settimeofday Calling settimeofday(1507494204.192398, -660) Master branch tested without tm_gmtoff has an incorrect offset: $ TZ="Australia/Lord_Howe" hwclock --hctosys --test | grep settimeofday Calling settimeofday(1507494249.193852, -690) Patched tested without tm_gmtoff has the correct offset: $ TZ="Australia/Lord_Howe" hwclock --hctosys --test | grep settimeofday Calling settimeofday(1507494260.194208, -660) 2) ISO 8601 'extended' format requires all time elements to use a colon (:). Current invalid ISO 8601: $ hwclock 2017-10-08 16:25:17.895462-0400 Patched: $ hwclock 2017-10-08 16:25:34.141895-04:00 Also required by this change: login-utils/last.c: increase ISO out_len and in_len by one to accommodate the addition of the timezone colon. Signed-off-by: J William Piggott <elseifthen@gmx.com>
* lib/timeutils: ISO_8601_BUFSIZ too smallJ William Piggott2017-11-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Although iso-8601 specifies years as 4 digits, it allows them to be wider. The current POSIX year width is limited by 'int tm_year' at 10 digits plus a negative sign. That, and the possibility of nanosecond time makes the widest POSIX iso-8601 time 41 characters. Plus the \0 string terminator yields a buffer size of 42. Before truncated output: /sbin/hwclock --utc --noadjfile --predict --date '-2147483765 years' -2147481748-09-25 20:29:45.0000 Patched: ./hwclock --utc --noadjfile --predict --date '-2147483765 years' -2147481748-09-25 20:17:21.000000-0456 ./hwclock --utc --noadjfile --predict --date '-2147483766 years' hwclock: invalid date '-2147483766 years' Comparable to coreutils 'date' command: date -Ins --date '-2147483765 years' -2147481748-09-25T19:49:31,578899297-0456 date -Ins --date '-2147483766 years' date: invalid date '-2147483766 years' The 'date' output illustrates the full 41 character POSIX iso-8601 Signed-off-by: J William Piggott <elseifthen@gmx.com>
* agetty: add support for /etc/issue.dKarel Zak2017-11-071-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | The /etc/issue file has been originally designed to inform users about the system (version, name, etc.). In last years is growing number of additional tools (containers, maintenance tools and interfaces, ...) and many admins and downstream maintainer want to add some tool specific hints to the issue file, but it mess to share one file between more packages and/or scripts. The solution is /etc/issue.d directory. The directory is extension to the standard system /etc/issue. The /etc/issue file has to exist, otherwise the directory will be ignored. It means "rm /etc/issue" (or --onissue) is still the way how keep our system silent independently on 3rd-party installed files in the /etc/issue.d directory. The content of the files in the directory are printed after content of the /etc/issue. The files are printed in version-sort order and .issue file extension is required (00-foo.issue 01-bar.issue ...). The change is backwardly compatible. Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/mangle: return size of the decoded bufferKarel Zak2017-11-011-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* Fix typo in carefulputc.hNik Nyby2017-10-251-3/+3
| | | | Signed-off-by: Nik Nyby <nikolas@gnu.org>
* lib/path: make path_set_prefix() independent on cpu_set_tKarel Zak2017-10-231-5/+4Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/signames: remove signame array from header fileKarel Zak2017-10-231-126/+3Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* signames: Make input char buffers constNiklas Hambüchen2017-10-141-1/+1
|
* kill: Extract signal names into signames.h/signames.cNiklas Hambüchen2017-10-142-0/+133
|
* losetup: Add support for logical block sizeStanislav Brabec2017-09-271-0/+3
| | | | | | | | | | | | | | | | | | | | Kernel since 4.14 supports setting of logical block size[1]. It allows to create loop devices that report logical block size different from 512. Add support for this feature to losetup. References: [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/block/loop.c?id=89e4fdecb51cf5535867026274bc97de9480ade5 [kzak@redhat.com: - fix loopcxt_get_blocksize() - remove lo_blocksize from loop_info64] Signed-off-by: Stanislav Brabec <sbrabec@suse.cz> Cc: Ming Lei <ming.lei@redhat.com> Cc: Hannes Reinecke <hare@suse.com> Cc: Omar Sandoval <osandov@fb.com> Cc: Jens Axboe <axboe@kernel.dk> Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: fix non-blkid compilationKarel Zak2017-09-191-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/pwdutils: add xgetlogin()Karel Zak2017-09-181-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* login: add xgetpwnam()Karel Zak2017-09-182-0/+11
| | | | 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>
* libuuid: add support for hash-based UUIDsPhilip Prindeville2017-09-052-0/+47
| | | | | | | | | Adding V3 and V5 UUIDs per RFC-4122. [kzak@redhat.com: - fix symbols file] Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* rfkill: make programming style to match util-linux projectSami Kerola2017-08-301-0/+4
| | | | | | | | Use the usual facilities, add translation strings, move global variables at the beginning of the file, make usage() look as expected, add standard command-line option parsing. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* fdisk: use strutils to trim whitespace from inputVaclav Dolezal2017-08-291-1/+1
| | | | Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
* include: move pamfail.h to auth.cSami Kerola2017-08-052-27/+0Star
| | | | | | | This removes one small header file, and makes inline function to static to only file it is used in. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* build: use --runstatedir instead of --localstatedirAndreas Henriksson2017-07-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* partx: move partx.h to include/Karel Zak2017-07-142-0/+63
| | | | | | Let's make the ioctls usable also for libfdisk. Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: don't use CDROM_GET_CAPABILITY ioctl for DM devicesKarel Zak2017-07-121-1/+1
| | | | | | | | | For some reason kernel commit e980f62353c697cbf0c4325e43df6e44399aeb64 add extra warning when the ioctl is used for DM devices. It seems we can avoid this ioctl when the device has dm/uuid. Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1469532 Signed-off-by: Karel Zak <kzak@redhat.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>
* 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>