summaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* lsblk: use internally sysfs devnamesKarel Zak2015-05-291-2/+4
| | | | | | | It seems better to keep the strange sysfs devnames internally and translate to real devnames only on output or when we read from /dev. Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/sysfs: rename devname functions, cleanupKarel Zak2015-05-281-9/+25
| | | | | | | | | | | | | | | | | | Well, I don't have mental power to use function names like sysfs_devname_to_dev_name() so this patch renames to sysfs_devname_sys_to_dev() sysfs_devname_dev_to_sys() It also cleanups usage of the functions. We have to be sure that sysfs.c code returns regular devnames. The existence of the sysfs devnames (with '!') should be completely hidden in sysfs specific code. Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/sysfs: Fix /dev to /sys node name translationStanislav Brabec2015-05-281-2/+6
| | | | | | | | | | | | | | | d0dc6c1 introduced translation of /sys names to /dev names, as required by the kernel linux/drivers/base/core.c: device_get_devnode(). But there are other places of code that use /dev names in /sys. They need reverse translation from '/' to '!'. For example, fdisk -l returns empty list since a22c6eb for device nodes in subdirectories (used e. g. by cciss driver). Introduce yet another helper sysfs_dev_name_to_devname() and use it where appropriate. Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
* Fix /sys to /dev node name translationStanislav Brabec2015-05-261-0/+2
| | | | | | | | | | | | | | linux/drivers/base/core.c: device_get_devnode() defines a translation of '!' in sysfs nodes to '/' in /dev nodes. The same translation has to be done to properly support device nodes with slash (e. g. device nodes of cciss driver and several other drivers). Introduce new helper sysfs_devname_to_devno() and use it where appropriate. Fixes for example lsblk -f on devices using cciss driver. Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
* lib/strv: add new functions (from systemd)Karel Zak2015-05-154-1/+495
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/strutils: fix string_add_to_idarray() int vs. size_tKarel Zak2015-04-221-3/+2Star
| | | | | | | | | | | | | | | | | | | | The function uses "int" as argument, but for array size (and index) is better to use unsigned type (size_t). If we mix "size_t" in util (e.g. fdisk) and "int" in lib/strutils.c then result is unexpected behavior on ppc64. # sfdisk --list -o DEVICE,START,SIZE /dev/sdb Disk /dev/sdb: 50 MiB, 52428800 bytes, 102400 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 32768 bytes Disklabel type: gpt Disk identifier: 3B8559DB-33AF-43E9-BEFC-C331D829B539 lt-sfdisk: libfdisk/src/label.c:178: fdisk_label_get_field: Assertion `id > 0' failed. The patch cleanup all code to use size_t everywhere. Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/sysfs.c: use fcntl(..F_DUPFD_CLOEXEC) instead of dup(2)Cristian Rodríguez2015-04-141-1/+1
| | | | | "The two descriptors do not share file descriptor flags (the close-on-exec flag). The close-on-exec flag for the duplicate descriptor is off"
* lib/timer: use separate file for timersKarel Zak2015-03-062-38/+49
| | | | | | | | It seems that static builds require -lpthread for timer_* functions. It's better to keep it out of our libs (e.g. libmount) to avoid unnecessary dependence. Signed-off-by: Karel Zak <kzak@redhat.com>
* flock: fix timeout handler pointer usageKarel Zak2015-03-051-2/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* flock: improve timeout handlingSami Kerola2015-03-051-0/+34
| | | | | | | | | | | | Signal ALRM raised by the timer, and the timer only, will be considered as a timeout criteria. Secondly time interval is made to use monotonic clock. Documentation of ITIMER_REAL is unclear whether that time is affected various sources of clock skew, or does it even tick when system is suspended. Reviewed-by: Karel Zak <kzak@redhat.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib/colors: use libtinfo to check terminal capabilityKarel Zak2015-02-272-5/+44
| | | | | | | | | | | | | | | The current implementation assumes that all terminals supports colors and users are forcet to use terminal-colors.d/ to disable colors for some terminals. This patch checks for maximal supported colors for the current terminal and colors are automatically disabled for terminals like vt100. The patch moves lib/colors.c from libcommon.la to libtcolors.la to avoid collisions with another utils. Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: add --disable-colors-defaultKarel Zak2015-02-251-2/+11
| | | | | | | | The current util-linux is to have enabled colorized outputs by default, this default behavior is possible to change by new configure option --disable-colors-default. Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/strutils: extend parse_switch() to accept more optionsKarel Zak2015-02-241-6/+24
| | | | | | | * allow to specify more 0|1 pairs * allow to specify error message Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/strutils: move parse_switch() from setterm(1) to librarySami Kerola2015-02-241-0/+8
| | | | | | | To allow sharing the code with other utilities. Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/strutils: accept not just 'B' but also lowercase 'b' in a size suffixBenno Schulenberg2015-02-021-2/+2
| | | | | | | Just line 'M' and 'm' are accepted for mega, 'G' and 'g' for giga, 'S' and 's' for sectors, and so on. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* lib/sysfs: use ssize_t for sysfs_readlink() [coverity scan]Karel Zak2015-01-281-4/+3Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* docs: fix two "maybe be" duplications in program commentsBenno Schulenberg2015-01-261-5/+2Star
| | | | | | Also improve the grammar of the comments and some neighbours. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* build-sys: fix make checkincludes warningsSami Kerola2015-01-071-8/+4Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib: fix crc32 and crc64 interger overflows [AddressSanitizer]Sami Kerola2014-12-192-2/+5
| | | | | | | | | | lib/crc32.c:111:11: runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'size_t' (aka 'unsigned long') lib/crc64.c:101:12: runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'size_t' (aka 'unsigned long') Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib/mbalign: fix unsigned integer overflow [AddressSanitizer]Sami Kerola2014-12-191-1/+1
| | | | | | | | | This error was reported 155 times. lib/mbsalign.c:322:18: runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'size_t' (aka 'unsigned long') Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* docs: fix the grammar of the recent comment about commentsBenno Schulenberg2014-12-191-2/+3
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* terminal-colors.d: add note about comments to man pageKarel Zak2014-12-121-0/+4
| | | | | Reported-by: Jan Pokorný <jpokorny@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/sysfs: add subsystem and hotplug detectionKarel Zak2014-12-021-1/+152
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/colors: use static buffers when parse schemeKarel Zak2014-11-211-19/+29
| | | | | | | * use static buffers when parse scheme colors * cleanup deallocation on error in sequence parser Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/colors: fix double free on error pathAndreas Henriksson2014-11-191-3/+5
| | | | | | | | | | | | The error path was a bit unclear on the semantics. The seq argument would get freed but not the name argument. Then the caller frees them both when the function returns an error. This fixes the problem my making the function not touch the arguments unless we're going to return success. Also improve the description for this function to make it more obvious what the callers should expect. Addresses: CID#77487 (on scan.coverity.com for JIghtuse/util-linux) Signed-off-by: Andreas Henriksson <andreas@fatal.se>
* build-sys: move all around clock_gettime() to monotonic.cKarel Zak2014-11-192-25/+27
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: use monotonic time rater than gettimeofdayKarel Zak2014-11-181-0/+23
| | | | | | Based on patch Alexander Samilovskih <alexsamilovskih@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* tests: fix memory leak [AddressSanitizer]Sami Kerola2014-11-181-0/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib/loopdev: remove test programKarel Zak2014-11-042-154/+0Star
| | | | | | | All is already covered by losetup and mount. The test program has never been used in our regression tests. Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/loopdev: replace custom DBG() with include/debug.hKarel Zak2014-11-041-102/+88Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* docs: update info about env debug variablesKarel Zak2014-11-031-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* include/debug: fix typoKarel Zak2014-10-241-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* terminal-colors.d: add debug stuffKarel Zak2014-10-222-12/+63
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* terminal-colors.d: fix filter by nameKarel Zak2014-10-221-3/+2Star
| | | | | Addresses: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=766077 Signed-off-by: Karel Zak <kzak@redhat.com>
* textual: "ambivalent" applies to intentions, "ambiguous" to resultsBenno Schulenberg2014-10-011-1/+1
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* lslogins: free after error [coverity scan]Karel Zak2014-09-261-1/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* Merge branch 'misc' of git://github.com/kerolasa/lelux-utiliteetitKarel Zak2014-09-222-47/+0Star
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 'misc' of git://github.com/kerolasa/lelux-utiliteetit: textual: share crypt() error message in sulogin and newgrp newgrp: avoid use of obsolete getpass() function newgrp: use libc function to read gshadow if it is available setarch: use personality() system call when it is available setarch: reindent code hwclock: remove referal to deprecated keyboard interface eject: make open_device() and select_speed() to use struct eject_control eject: add struct eject_control to remove global variables mountpoint: simplify if statement mkfs.minix: fix couple compiler warnings mountpoint: add struct mountpoint_control last: improve code readability by renaming variable names last: make is_phantom() when kernel config does not include audit support lib: remove xgetpass() include: simplify fputc_careful() in carefulputc.h libuuid: add extern qualifiers to uuid/uuid.h system header
| * lib: remove xgetpass()Sami Kerola2014-09-192-47/+0Star
| | | | | | | | | | | | | | This function is not in use, and it has reference to obsoleted getpass(). Reference: http://man7.org/linux/man-pages/man3/getpass.3.html Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* | lib/swapprober: add missing header fileKarel Zak2014-09-221-0/+1
| | | | | | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* | swapon: split swapon-common.cKarel Zak2014-09-221-0/+48
|/ | | | | | | | | | | swapon - requires libmount and libblkid swapoff - requires libmount swaplabel - requires libblkid This patch add lib/swapprober.c with blkid stuff for swap. It allows to use and link libblkid only when necessary. Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/blkdev: report correct disk size on GNU/kFreeBSD. Thanks Tuco.Robert Millan2014-09-171-0/+4
| | | | Addresses-Debian-Bug: 592292
* lib/colors: add function to return color from schemeKarel Zak2014-08-131-7/+26
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/ismounted: make it more compatible with lsblk outputKarel Zak2014-08-011-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/sysfs: allow to write to sysfs attributesKarel Zak2014-08-011-6/+42
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/procutils: check fgets() return value [coverity scan]Karel Zak2014-07-171-0/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/loopdev: comparing an array to null is not useful [coverity scan]Karel Zak2014-07-171-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/colors: remove memory leakSami Kerola2014-07-171-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* docs: improve formatting and wording of a few man pagesBenno Schulenberg2014-07-141-32/+32
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* textual: fix some typosSami Kerola2014-07-131-1/+1
| | | | | | | Found with misspell-check version 2.0d. Reference: https://github.com/lyda/misspell-check Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib/ismounted: more robust buffer usage [clang-analyze]Karel Zak2014-07-011-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>