summaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* lib/mbalign: report also size in bytesKarel Zak2014-04-151-10/+30
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/mbsalign: split mbs_safe_encode()Karel Zak2014-04-151-12/+33
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libsmartcols: rewrite test code to tree(1)-like utilKarel Zak2014-04-081-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/tt.c: Goodbye!Ondrej Oprala2014-04-032-998/+0Star
| | | | Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
* mcookie: use lib/randutilsSami Kerola2014-03-261-0/+22
| | | | | | | | | The mcookie should reuse existing code, and there is definitely no need to prefer /dev/random for this utility. See reference for explanation about later statement. References: http://www.2uo.de/myths-about-urandom/ Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib/colors: care about colors only on tty()Karel Zak2014-03-121-2/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/strutils: fix parse_size() return codeKarel Zak2014-03-111-1/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/colors: fix colors testKarel Zak2014-03-111-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/tt: keep track about output orderKarel Zak2014-03-111-1/+20
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/tt: add tt_line_get_userdata()Karel Zak2014-03-111-0/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/strutils: support dec.points in parse_size()Karel Zak2014-03-111-2/+43
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/strutils: use proper return codes in parse_size()Karel Zak2014-03-111-9/+14
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/mbalign: add mbs_safe_width() from tt.cKarel Zak2014-03-112-136/+136
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* include/tt: add function to convert table to stringKarel Zak2014-03-111-0/+26
| | | | | | | Note that open_memstream() is POSIX-1.2008, so it's possible than not all libc have already implemented this function. Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/tt: add reduce term width functionalityKarel Zak2014-03-111-0/+13
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/tt: add TT_FL_MAX to fill screenKarel Zak2014-03-111-2/+32
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/tt: add tb_get_nlines()Karel Zak2014-03-111-0/+13
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/tt: don't hardcode stdout as outputKarel Zak2014-03-111-13/+21
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/colors: support <name>.enable tooKarel Zak2014-03-112-18/+38
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/colors: add info to man pages, add terminal-colors.d.5Karel Zak2014-03-112-0/+27
| | | | | Co-Author: Ondrej Oprala <ooprala@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/colors: check for /etc/terminal-colors.d/[util].disableOndrej Oprala2014-03-111-4/+25
| | | | | | | | [kzak@redhat.com: - move paths to pathnames.h, - use static path buffer] Signed-off-by: Ondrej Oprala <ooprala@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/sysfs: make dirent d_type usage more robustKarel Zak2014-03-041-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/color: add colorscheme parserKarel Zak2014-02-101-2/+47
|
* losetup: wait for udevKarel Zak2014-01-241-5/+18
| | | | | | | | | | | | | On system with /dev/lop-control the udevd creates /dev/loopN nodes. It seems better to wait a moment after unsuccessful open(/dev/loopN) and try it to open again. The problem is pretty visible on systems where udevd also modifies permission for loopN devices, then open() fails with EACCES when losetup executed by non-root user (but user who is in "disk" group). Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1045432 Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/sysfs: fix scanf format string [coverity scan]Karel Zak2014-01-141-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/path: add path_strdup()Karel Zak2014-01-061-0/+13
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* textual: standardize some "cannot read" and "seek failed" error messagesBenno Schulenberg2013-10-091-4/+4
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* losetup: don't require 512-byte aligned offsetsKarel Zak2013-10-011-0/+6
| | | | | | | | | | | | | | | | Kernel aligns the device size, but the offset where the device starts is not required to be aligned. # losetup --offset 32 -f file.img is just fine, the final size of the look device will be (in sectors) (backing_file_size - offset) >> 9 so we have to do the same in userspace when we check for successful set capacity ioctl. Signed-off-by: Karel Zak <kzak@redhat.com>
* fdisk: add -L to colorize outputKarel Zak2013-09-161-4/+9
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/tt: add TT_FL_FREEDATAKarel Zak2013-09-161-1/+9
| | | | | | ... to call free() for line data. Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: add crc64()Karel Zak2013-09-112-0/+109
| | | | | | Based on bcache code from Rolf Fokkens. Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: rename time-util.c to timeutils.c, fix headersKarel Zak2013-09-102-2/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/strutils: optimalize {starts,ends}with()Karel Zak2013-09-101-66/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/time-util: move YYYYMMDDHHMMSS to common parserSami Kerola2013-08-291-0/+7
| | | | | | | | | Even while the YYYYMMDDHHMMSS time format it not magnificent it is best to make it to be part of the one, and only, time format parser. Proposed-by: Karel Zak <kzak@redhat.com> References: http://markmail.org/message/6baqt4ttkopu7ra6 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib/strutils: move *swith() functions to private librarySami Kerola2013-08-292-58/+67
| | | | | | | | Avoid code dublication in libmount and time-util. Proposed-by: Karel Zak <kzak@redhat.com> Reference: http://markmail.org/message/h7zexvqsieqngtmx Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib/time-util: copy time parsing functions from systemdSami Kerola2013-08-292-0/+389
| | | | | | | | The functions are copied nearly as-is. Coding style has been modified to match with util-linux project, while the functionality remains untouched. CC: Lennart Poettering <lennart@poettering.net> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* losetup: use loop-control to explicitly ask for deviceKarel Zak2013-08-061-0/+30
| | | | | | | | | | | | | | | | Now we use LOOP_CTL_GET_FREE ioctl to ask for free device, for example losetup -f foo.img Unfortunately, losetup(8) allows to ask for specified device losetup /dev/loop100 foo.img and in this case we assume that the device already exists in the system. This is incorrect, we should be able to use loop-control LOOP_CTL_ADD ioctl to ask for the specified device. Signed-off-by: Karel Zak <kzak@redhat.com>
* losetup: set errno for misaligned offsetsKarel Zak2013-07-191-7/+19
| | | | | References: https://bugs.archlinux.org/task/36189 Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/mbsalign: initializations values are never read [clang-analyzer]Sami Kerola2013-07-091-2/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib/loopdev: assigned value is never read [clang-analyzer]Sami Kerola2013-07-091-1/+0Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib/canonical: use realpath() from libcKarel Zak2013-07-011-151/+29Star
| | | | | | | .. after many many years it seems that we can follow libc code rather than duplicate realpath(3) implementation. Signed-off-by: Karel Zak <kzak@redhat.com>
* exec_shell: add a license and touch up func defMike Frysinger2013-07-011-1/+20
| | | | | | | | | | When this file was created, the standard license header was missed. Add it using the same one from unshare.c. The noreturn attribute is not needed since we include the header which has it on the prototype. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libmount: be robust for empty target/source stringsKarel Zak2013-06-171-2/+5
| | | | | | | | | | * lib/canonicalize.c: don't interpret empty strings as relative paths * libmount: more robust libmnt_table find function and debug messages References: https://bugzilla.novell.com/show_bug.cgi?id=825150 Signed-off-by: Karel Zak <kzak@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: remove unused codeSami Kerola2013-06-071-10/+0Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib/tty: fix get_terminal_name() usage, cleanup codeKarel Zak2013-05-281-3/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/tty: don't hardcode terminal fd in get_terminal_name()Karel Zak2013-05-131-2/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/loopdev: fix loopcxt_check_size() to work with blkdevsKarel Zak2013-05-131-1/+15
| | | | | | | | | | | | | | The loopcxt_check_size() is workaround for kernels < v3.9, kernel has been fixed by commit 541c742a7559eb65f0e36d3e2338c2ca532a3e61. The function sets loopdev size according to backing file size. The problem is that the backing file could be a block device where stat.st_size is zero, so we have to use blkdev_get_size() for block devices. Addresses: https://bugs.archlinux.org/task/35193 Reported-by: Dave Reisner <d@falconindy.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/colors: add colormode_or_err()Karel Zak2013-05-071-9/+15
| | | | | | ... to make the code easy to use in utils. Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/colors: add support for auto, always and never modesKarel Zak2013-05-062-2/+76
| | | | | | ... to implement --color[=<when>] Signed-off-by: Karel Zak <kzak@redhat.com>
* loopdev: sync capacity after setting itJeff Mahoney2013-04-093-6/+85
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I recently tried to mount an hfsplus file system from an image file with a partition table by using the loop offset and sizelimit options to specify the location of the file system. hfsplus stores some metadata at a set offset from the end of the partition, so it's sensitive to the device size reported by the kernel. It worked with this: But failed with this: /dev/loop0: [0089]:2 (<imagefile>), offset 32768, sizelimit 102400000 /dev/loop1: [0089]:2 (<imagefile>), offset 32768, sizelimit 102400000 /proc/partitions shows the correct number of blocks to match the sizelimit. But if I set a breakpoint in mount before the mount syscall, I could see: 102400000 102432768 The kernel loop driver will set the gendisk capacity of the device at LOOP_SET_STATUS64 but won't sync it to the block device until one of two conditions are met: All open file descriptors referring to the device are closed (and it will sync when re-opened) or if the LOOP_SET_CAPACITY ioctl is called to sync it. Since mount opens the device and passes it directly to the mount syscall after LOOP_SET_STATUS64 without closing and reopening it, the sizelimit argument is effectively ignroed. The capacity needs to be synced immediately for it to work as expected. This patch adds the LOOP_SET_CAPACITY call to loopctx_setup_device since the device isn't yet released to the user, so it's safe to sync the capacity immediately. [kzak@redhat.com: - port to the current git HEAD, - use uint64_t] Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: Karel Zak <kzak@redhat.com>