summaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* misc: fix some warningsRuediger Meier2017-06-011-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sys-utils/prlimit.c: In function 'do_prlimit': sys-utils/prlimit.c:367:16: warning: format '%ju' expects argument of type 'uintmax_t', but argument 2 has type 'rlim_t {aka long long unsigned int}' [-Wformat=] printf("<%ju", new->rlim_cur); lib/plymouth-ctrl.c: In function 'open_un_socket_and_connect': lib/plymouth-ctrl.c:88:20: warning: passing argument 2 of 'connect' from incompatible pointer type [-Wincompatible-pointer-types] ret = connect(fd, &su, offsetof(struct sockaddr_un, sun_path) + 1 + strlen(su.sun_path+1)); ^ In file included from lib/plymouth-ctrl.c:35:0: /usr/include/sys/socket.h:314:5: note: expected 'const struct sockaddr *' but argument is of type 'struct sockaddr_un *' int connect (int, const struct sockaddr *, socklen_t); login-utils/last.c: In function 'list': login-utils/last.c:506:54: warning: pointer targets in passing argument 4 of 'dns_lookup' differ in signedness [-Wpointer-sign] r = dns_lookup(domain, sizeof(domain), ctl->useip, p->ut_addr_v6); ^ login-utils/last.c:291:12: note: expected 'int32_t * {aka int *}' but argument is of type 'unsigned int *' static int dns_lookup(char *result, int size, int useip, int32_t *a) ^~~~~~~~~~ In file included from sys-utils/hwclock-cmos.c:92:0: sys-utils/hwclock.h:67:32: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration extern double time_diff(struct timeval subtrahend, struct timeval subtractor); misc-utils/test_uuidd.c: In function 'create_nthreads': misc-utils/test_uuidd.c:187:19: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] proc->pid, (int) th->tid, th->index)); Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* build-sys: fix library order when linkingRuediger Meier2017-06-011-1/+1
| | | | | | | | | | We got some errors on Alpine Linux where $LTLIBINTL is non-empty: ./.libs/libcommon.a(libcommon_la-blkdev.o): In function `open_blkdev_or_file': lib/blkdev.c:282: undefined reference to `libintl_gettext collect2: error: ld returned 1 exit status Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* build-sys: ncurses headers cleanupKarel Zak2017-05-311-4/+11
| | | | | | | | | * assume ncursesw headers in ncursesw/ directory only * prefer long paths, <term.h> and <ncurses.h> should be last possibility * fix typos Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/colors: fix test compilationKarel Zak2017-05-311-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/colors: ncurses cleanupKarel Zak2017-05-302-9/+27
| | | | | | | | | * use proper paths to term.h * keep ncurses support optional * link with TINFO_LIBS (-ltinfo), or fallback to NCURSES_LIBS (-ltinfo -lncurses) * don't include unnecessary ncurses.h (term.h is enough) Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/loopdev: remove unnecessary headerKarel Zak2017-05-301-1/+0Star
| | | | | Reported-by: Assaf Gordon <assafgordon@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/parse-date: don't use xalloc in lib-like codeKarel Zak2017-05-121-3/+12
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: remove duplicate includesKarel Zak2017-05-121-1/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/mbsedit: fix typo in commentSami Kerola2017-05-101-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib/timer: add commentKarel Zak2017-04-281-0/+17
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/timer.c: prevent pathological race conditionRasmus Villemoes2017-04-261-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | flock(1) uses the timer facility to interrupt a blocking flock(2) call. However, in a pathological case (or with a sufficiently short timeout), the timer may fire and the signal be delivered after the timer is set up, but before we get around to doing the flock(2) call. In that case, we'd block forever. Checking timeout_expired right before calling flock(2) does not eliminate that race, so the only option is to make the timer fire repeatedly. Having the timer fire after we've returned from flock(2) is not a problem, since we only check timeout_expired in case of EINTR (also, this firing after return could also happen with the current code). There is currently one other user of setup_timer (misc-utils/uuidd.c), but in that case the signal handler simply exits. Future users of setup_timer obviously need to ensure that they can tolerate multiple signal deliveries. Choosing 1% of the initial timeout as the repeating interval is somewhat arbitrary. However, I put a lower bound of 0.01s, since setting the interval much smaller than this may end up effectively live-locking the process, handling a never-ending stream of signals. Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
* lib/timer.c: remove bogus SA_SIGINFO from timer_settime callRasmus Villemoes2017-04-261-1/+1
| | | | | | | | | The only valid flag for timer_settime is TIMER_ABSTIME, which we certainly don't want here. This seems to be harmless since timer_settime doesn't validate the flags parameter, TIMER_ABSTIME is universally 0x1, and no architecture has SA_SIGINFO == 1. Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
* parse-date: remove extraneous form feedJ William Piggott2017-04-101-2/+0Star
| | | | | | * lib/parse-date.y: Remove extraneous form feed (FF, 0x0C, ^L). Signed-off-by: J William Piggott <elseifthen@gmx.com>
* Merge branch '2017wk13' of https://github.com/kerolasa/lelux-utiliteetitKarel Zak2017-04-041-1/+0Star
|\ | | | | | | | | | | | | | | * '2017wk13' of https://github.com/kerolasa/lelux-utiliteetit: docs: improve agetty.8 manual page agetty: make --remote to forward --nohostname as -H to login lib/cpuset: stop changing variable that is not read agetty: remove variable that is set but not read
| * lib/cpuset: stop changing variable that is not readSami Kerola2017-04-011-1/+0Star
| | | | | | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* | lib/strutils: fix typos in huge size suffixesKarel Zak2017-04-031-3/+3
|/ | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* agetty: fix characters reorder in login promptKarel Zak2017-03-271-4/+0Star
| | | | | | | | | | | | | | 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>
* Merge branch '2017wk11' of git://github.com/kerolasa/lelux-utiliteetitKarel Zak2017-03-242-9/+9
|\ | | | | | | | | | | | | | | | | * '2017wk11' of git://github.com/kerolasa/lelux-utiliteetit: blkid: add control struct blkid: simplify version option handling tests: add static keyword where needed [smatch scan] tests: do not use plain 0 as NULL [smatch scan] libsmartcols: fix test variable shadowing
| * tests: do not use plain 0 as NULL [smatch scan]Sami Kerola2017-03-172-9/+9
| | | | | | | | | | | | Likewise commit 87918040658f2fa9b1bf78f1f8f4f5c065a2e3a3. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* | Merge remote-tracking branch 'jwpi/hwclock-date7'Karel Zak2017-03-233-0/+1647
|\ \ | |/ |/| | | | | | | | | | | * jwpi/hwclock-date7: lib: add parse-date documentation hwclock: use parse_date function build-sys: add parse-date.y lib: add parse-date.y
| * build-sys: add parse-date.yKarel Zak2017-03-042-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | * add lib/parse-date.y to build system * add necessary autotools stuff to generate .c on the fly (autotools are smart enough to add generated file to tarball) * check for bison version by ./autogen.sh * add non-wanted junk to .gitignore With some modification by J William Piggott with regard to moving the parse-date API into timeutils.h Signed-off-by: J William Piggott <elseifthen@gmx.com>
| * lib: add parse-date.yJ William Piggott2017-03-041-0/+1645
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* | lib/colors: assert rathen than overflow [-Wnull-dereference]Karel Zak2017-03-131-1/+4
|/ | | | | | | | lib/colors.c: In function 'colors_read_schemes': lib/colors.c:412:7: warning: potential null pointer dereference [-Wnull-dereference] Reported-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/idcache: add void to function declaration [smatch scan]Sami Kerola2017-02-201-1/+1
| | | | | | | lib/idcache.c:29:29: warning: non-ANSI function declaration of function 'new_idcache' Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: add static keyword to where needed [smatch scan]Sami Kerola2017-02-202-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>
* misc: do not use plain 0 as NULL [smatch scan]Sami Kerola2017-02-202-3/+3
| | | | | | | | | | 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>
* lib/mbsedit: add simple buffer editorKarel Zak2017-02-162-0/+223
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/randutils: glibc 2.25 has getrandom(2) declarationSami Kerola2017-02-131-1/+1
| | | | | | | Use correct header file to include the function. Reference: http://git.kernel.org/cgit/docs/man-pages/man-pages.git/commit/?id=2cbb6fb4e926e56dc3985b19ac02389321a0af5d Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* docs: Fix word repetitionsYuri Chornoivan2017-02-131-1/+1
|
* lib: add timegm() portability function to lib/timeutils.cSami Kerola2017-02-031-0/+19
| | | | | | | | | 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/+7
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: test_linux_version is Linux onlyKarel Zak2017-01-041-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/linux_version: fix code indentionKarel Zak2017-01-041-35/+35
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: use unique ifdefs for testsKarel Zak2017-01-0415-32/+32
| | | | | | | Let's use unique TEST_PROGRAM_<NAME> ifdefs to make build system more robust. Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/linux_version: add test for manual testingKarel Zak2017-01-022-0/+51
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/linux_version: fix stupid typoKarel Zak2017-01-021-1/+1
| | | | | | ... introduced by commit d404065a. Sorry. Signed-off-by: Karel Zak <kzak@redhat.com>
* Merge branch 'getrandom' of git://github.com/kerolasa/lelux-utiliteetitKarel Zak2016-12-221-16/+53
|\ | | | | | | | | * 'getrandom' of git://github.com/kerolasa/lelux-utiliteetit: lib/randutils: use getrandom(2) when it is available
| * lib/randutils: use getrandom(2) when it is availableSami Kerola2016-12-111-16/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | System call getrandom(2) is relatively new, available since kernel 3.17 but not supported by glibc 2.24. That in mind autotools is made to check availability of this function and keep old code as fallback. It is reasonable assume it will take years before the syscall(2) and fallback are unproblematic to remove. One might ask why bother using getrandom(2). Main reason is to avoid unnecessary system calls to achieve exactly same end result. That demonstrated with 'strace -c ./mcookie' showing 36 calls before, and 32 after this change. Secondly the getrandom(2) function got to kernel with promise it can be used to avoid file descriptor run down, and since uuidd uses random_get_bytes() it should fulfill it's promise here. Reference: http://man7.org/linux/man-pages/man2/getrandom.2.html Reference: https://lwn.net/Articles/606141/ Reviewed-by: Karel Zak <kzak@redhat.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* | docs: replace FTP by HTTPS in kernel.org URLsSébastien Helleu2016-12-191-1/+1
|/ | | | | | | The links to ftp://ftp.kernel.org/ are replaced by https://www.kernel.org/. Signed-off-by: Karel Zak <kzak@redhat.com>
* docs: various pages: Format pathnames as italic (.I)Michael Kerrisk2016-12-091-3/+3
| | | | | | | | | In the majority of pages, pathnames are formatted as Italic, which is the norm. However, there are several cases where they are formatted as bold. This patch fixes a number of those exceptions. Signed-off-by: Michael Kerrisk <mtk.man-pages@gmail.com>
* misc: spelling, always use "cannot" instead of "can not"Ruediger Meier2016-11-301-3/+3
| | | | | | Just to be consistent ... Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* lib,strutils: add strtoux[16|32|64]_or_err functionsHeiko Carstens2016-11-091-6/+38
| | | | | | | 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-9/+3Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/mbsalign: free buffer after error [coverity scan]Karel Zak2016-10-041-5/+6
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: support multi-line cells based on line breaksKarel Zak2016-09-061-3/+9
| | | | | | | | | | 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-3/+15
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/loopdev: Set errno in is_loopdev on errorTobias Stoeckmann2016-08-311-5/+6
| | | | | | | | | | | | | | The function is_loopdev does not set errno if the supplied string does not reference a valid loop device. Fix this to avoid an error message like this one: losetup: /: failed to use device: Success I prefer this one: losetup: /: failed to use device: No such device Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
* lib/pager: fix testKarel Zak2016-08-261-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/pager: restore signals setting by pager_close()Karel Zak2016-08-261-5/+23
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>