summaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* 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>
* lib/pager: cleanup and extend APIKarel Zak2016-08-261-4/+51
| | | | | | | | | * 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-1/+35
| | | | | | | | | | | | 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>
* losetup: add --nooverlap optionsKarel Zak2016-08-171-5/+9
| | | | | | | | | | | | | | | | | | | | | This patch introduces overlap detections and loop devices re-use for losetup(8). We already support this feature for mount(8) where it's enabled by default (because we mount filesystems and it's always mistake to share the same filesystem between more loop devices). Stanislav has suggested to enable this feature also for losetup by default. I'm not sure about it, IMHO it's better to keep losetup(8) simple and stupid by default, and inform users about possible problems and solutions in the man page. The feature forces losetup to scan all loop devices always when new one is requested. This maybe disadvantage (especially when we use control-loop to avoid /sys or /dev scans) on system with huge number of loop devices. Co-Author: Stanislav Brabec <sbrabec@suse.cz> Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: always check setenv(3) return valueSami Kerola2016-08-121-1/+2
| | | | | | At least glibc setenv(3) can fail when system runs out of memory. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* blkdev: guard against missing DIOCGDINFO on FreeBSD 11Franco Fichtner2016-08-111-2/+2
| | | | | DIOCGMEDIASIZE is supported and available since FreeBSD 5, it may make sense to kill the backwards-glue completely instead.
* libmount: ignore redundant slashesKarel Zak2016-08-081-28/+72
| | | | | | | | | | | | | | | ///aaa/bbb and /aaa/bbb/ are the same paths. This is important especially with NFS where number of slashes are not the same in the /proc/self/mountinfo and fstab or utab. The regular URI is euler://tmp but /proc contains euler:/tmp Reported-by: Ales Novak <alnovak@suse.cz> Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: one iteration to detect overlap and reuse loopdevKarel Zak2016-08-041-4/+18
| | | | | | | | | | The current code scans loopdevs to detect already used loop device and another scan to detect overlap. Let's use one scan only, for this purpose loopcxt_find_overlap() has been modified to return info (rc==2) about full size and offset match. Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/loopdev: cleanup sizelimit checkKarel Zak2016-08-041-9/+11
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* Implement loopcxt_check_conflict()Stanislav Brabec2016-08-031-0/+55
| | | | | | | Add a function that searches for a possible conflicting (i. e. overlaying loop device). Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
* Add sizelimit to internal APIStanislav Brabec2016-08-032-8/+20
| | | | | | | | | | | | | | Fully safe checks of loop device need to check sizelimit. To prevent need of two nearly equal functions, introduce sizelimit parameter to several internal functions: loopdev_is_used() loopdev_find_by_backing_file() loopcxt_is_used() loopcxt_find_by_backing_file() If sizelimit is zero, fall back to the old behavior (ignoring of sizelimit). Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
* misc: simplify if clauses [oclint]Sami Kerola2016-07-212-8/+4Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* tests: fix ttyutils testKarel Zak2016-07-151-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: try to find tty in get_terminal_name()Sami Kerola2016-07-041-2/+13
| | | | | | | | Try all standard terminal input/output file descriptors when finding tty name in get_germinal_name(). This should make all invocations of the function as robust as they can get. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* libcommon: add ISO_8601_GMTIME that will print UTC-0 timestampsSami Kerola2016-06-261-2/+12
| | | | | | | When timestamps are intented to be conversable back from string to binary it is best to stick with UTC-0 timezone. This is needed in utmpdump(1). Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: cleanup non-widechar compilationKarel Zak2016-06-031-1/+6
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/mbsalign: fix for non-widecharKarel Zak2016-06-031-10/+12
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/sysfs: be more smart for non-scsi devicesKarel Zak2016-06-021-1/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/ttyutils: use stdout for get_terminal_width()Karel Zak2016-06-021-2/+2
| | | | | | | | | We use the function to be sure with *output* width. Note that the current code (with STDIN) is broken because in some situations libsmartcols is not able to detect terminal width and fall back to default 80. Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: Fix various typosSebastian Rasmussen2016-05-319-16/+16
| | | | | | | Fix various typos in error messages, warnings, debug strings, comments and names of static functions. Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
* build-sys: add --disable-plymouth-supportKarel Zak2016-05-261-1/+4
| | | | | | | | The plymouth support depends on Linux specific SOCK_* flags and all the feature is probably unnecessary in some cases (non-plymouth distros, etc.) Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/timeutils: add strtime_short()Karel Zak2016-05-241-0/+38
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* include/timeutils: rewrite iso formatting functionsKarel Zak2016-05-241-34/+64
| | | | | | | | | - use buffers rather than allocate memory - support .usec and ,usec convention - use strftime for timezone (we need to care about daylight saving time) Signed-off-by: Karel Zak <kzak@redhat.com>
* include/timeutils: use pointer for time_tKarel Zak2016-05-231-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>