summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)AuthorFilesLines
2013-05-28lib/tty: fix get_terminal_name() usage, cleanup codeKarel Zak1-3/+3
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-05-13lib/tty: don't hardcode terminal fd in get_terminal_name()Karel Zak1-2/+3
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-05-13lib/loopdev: fix loopcxt_check_size() to work with blkdevsKarel Zak1-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>
2013-05-07lib/colors: add colormode_or_err()Karel Zak1-9/+15
... to make the code easy to use in utils. Signed-off-by: Karel Zak <kzak@redhat.com>
2013-05-06lib/colors: add support for auto, always and never modesKarel Zak2-2/+76
... to implement --color[=<when>] Signed-off-by: Karel Zak <kzak@redhat.com>
2013-04-09loopdev: sync capacity after setting itJeff Mahoney3-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>
2013-04-09various: fix variable and function declarations [smatch scan]Sami Kerola1-2/+2
disk-utils/fsck.minix.c:511:9: warning: mixing declarations and code fdisks/sfdisk.c:982:5: warning: mixing declarations and code fdisks/sfdisk.c:1254:5: warning: mixing declarations and code fdisks/sfdisk.c:1564:5: warning: mixing declarations and code lib/mbsalign.c:279:7: warning: mixing declarations and code libblkid/src/devname.c:378:17: warning: mixing declarations and code libfdisk/src/alignment.c:219:9: warning: mixing declarations and code term-utils/wall.c:111:9: warning: mixing declarations and code text-utils/col.c:418:19: warning: non-ANSI function declaration of function 'flush_blanks' text-utils/col.c:553:12: warning: non-ANSI function declaration of function 'alloc_line' text-utils/rev.c:105:9: warning: mixing declarations and code text-utils/tailf.c:245:9: warning: mixing declarations and code Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-04-03lib: use O_CLOEXEC in libcommonKarel Zak9-24/+25
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-04-03lib/canonicalize: don't use /dev/mapper/<name> if the node does not existKarel Zak1-1/+3
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-27lsblk: fix hctl buffer usage [coverity scan]Karel Zak1-1/+2
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-20lib/mbsalign: correct license header from GPLv[23] to LGPLv2+Pádraig Brady1-2/+2
* lib/mbsalign.c: s/GPLv3/LGPLv2+/ * include/mbsalign.h: s/GPLv2/LGPLv2+/ * README.licensing: Remove mention GPLv3 as it's not actually used.
2013-03-18dmesg: more colors, more funKarel Zak1-1/+1
* colorize subsystem prefix * colorize time * colorize by keywords (now "segfault" only) Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-13lib/strutils: add strtotimeval_or_err()Karel Zak1-0/+10
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-12lib/procutils: add simple API to scan /proc/PID/*Karel Zak2-4/+128
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-12lib/procutils: test refactoringKarel Zak1-4/+16
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11lib/strutils: simplify strtosize(), return info about suffixKarel Zak1-37/+28
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11fdisk: add callback for ask-numbers APIKarel Zak1-0/+10
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-20Merge branch 'patch-1' of https://github.com/dtrebbien/util-linuxKarel Zak1-0/+7
* 'patch-1' of https://github.com/dtrebbien/util-linux: Implement mempcpy() in terms of memcpy() if mempcpy() is unavailable
2013-02-19lib/tty: don't truncate output on non-terminalsKarel Zak1-2/+8
for example: $ findmnt | cat $ lslocks > foo the output should not be truncated. Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-14unshare,nsenter: spawn shell by defaultZbigniew Jędrzejewski-Szmek2-1/+29
The behaviour mimics chroot. Possibly it would have been nicer to to query the password database in the new namepace and run the shell of the user there, but it's hard to do correctly. getpwuid() might need to load nss plugins, and the arch in the new namespace might be different (in case of NEWNS mounts), or the hostname might be different, etc. So in general it's not possible to do it reliably. Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
2013-02-06build-sys: test for secure_getenv() too.Cristian Rodríguez1-2/+3
In current glibc versions, internal __secure_getenv no longer exists and was replaced by secure_getenv() Signed-off-by: Cristian Rodríguez <crrodriguez@opensuse.org>
2013-02-06a pointer should not be compared to zero [coccinelle]Sami Kerola1-1/+1
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-02-06textual: spell and encode the name of Arkadiusz Miśkiewicz correctlyBenno Schulenberg1-1/+1
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-01-30Implement mempcpy() in terms of memcpy() if mempcpy() is unavailableDaniel Trebbien1-0/+7
2013-01-08include: cleanup copyright headersKarel Zak8-8/+38
We use the code from include/ and lib/ on many places, so use public domain if possible or LGPL for code copied from libs. Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-23sulogin: remove consoles.c from libcommonKarel Zak2-787/+0
- move struct chardata to include/ttyutils.h - move console.{h,c} to login-utils/sulogin-* (it's sulogin specific) - fix sulogin and agetty includes Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-19lib/ismounted: improve loopdev supportKarel Zak1-18/+9
... to make it usable for situations when the same backing file is mapped to more loop devices. Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-19lib/ismounted: basic support for loop devicesKarel Zak2-10/+35
# losetup -a /dev/loop0 /dev/loop0: [2053]:1048578 (/home/fs-images/filesystems/ext2.img) # findmnt /dev/loop0 TARGET SOURCE FSTYPE OPTIONS /mnt/test /dev/loop0 ext3 rw,relatime,data=ordered old version: ./test_ismounted /home/fs-images/filesystems/ext2.img not mounted new version: ./test_ismounted /home/fs-images/filesystems/ext2.img mounted on /mnt/test Reported-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-19lib/loopdev: fix loopdev_find_by_backing_file()Karel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-18sulogin: mount temporary /dev and /proc if not foundWerner Fink1-0/+73
This is very usefull if initrd can not loaded that is no /dev and no /proc is found. Also if the /etc/shadow and /etc/passwd is copied into the initrd the sulogin can be used in initrd even before /dev and/or /proc are mounted. Signed-off-by: Werner Fink <werner@suse.de>
2012-12-18sulogin: use the linked lists from list.h for consoles listWerner Fink1-30/+48
with this the double linked list feature from util-linux is used instead of the single linked list. [kzak@redhat.com: use list_last_entry() and list INIT macros] Signed-off-by: Werner Fink <werner@suse.de> Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-18include/list: add list_last_entry()Karel Zak1-3/+3
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-26lib/canonicalize: add canonicalize_path_restricted() to canonicalize without ↵Karel Zak1-0/+42
suid permisssions Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-23lib/path: add path_read_u64()Karel Zak1-0/+22
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-23lib/path: rename functions to be more explicitKarel Zak1-8/+10
... and to have names compatible with lib/sysfs.c Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-22lib/ttyutils: add get_terminal_name()Karel Zak1-2/+43
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-22lib/ttyutils: add test programKarel Zak2-0/+14
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-22lib/ttyutils: create .c fileKarel Zak2-0/+40
Well, now all tty stuff are incline functions in include/ttyutils.h. It's seems more elegant to create regular lib/ttyutils.c for libcommon and write test program. Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-12lib/loopdev: make loopcxt_get_device() more robustKarel Zak1-2/+2
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-09lib/console: fix possible fd leakKarel Zak1-1/+4
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-09lib/consoles: try another methods before go to fallbackKarel Zak1-10/+4
The current code goes immediately to the fallback section if any detection method fails. It seems better to try another methods before the fallback solution. Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-09lib/consoles: add debug messagesKarel Zak1-8/+59
- may be enabled by CONSOLES_DEBUG env. variable Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-09lib/consoles: TIOCGDEV code refactoringKarel Zak1-42/+67
- add missing scandev() otherwise TIOCGDEV make no sense - use this method independent on /proc/cmdline code Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-09lib/consoles: cmdline code refactoringKarel Zak1-72/+91
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-09lib/consoles: sysfs code refactoringKarel Zak1-37/+64
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-09lib/consoles: /proc/consoles code refactoringKarel Zak1-27/+55
- move to separate function - cleanup code - fix fscanf() usage to avoid buffer overflow Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-09lib/consoles: small cleanupKarel Zak1-9/+10
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-09lib/consoles: don't call perror()Karel Zak1-11/+26
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-09lib/consoles: add test programKarel Zak2-0/+32
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-09lib/consoles: remove global variable consolesKarel Zak1-19/+17
Signed-off-by: Karel Zak <kzak@redhat.com>