Commit Graph

325 Commits

Author SHA1 Message Date
Karel Zak 0f23ee0c85 include: cleanup copyright headers
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>
2013-01-08 15:10:17 +01:00
Karel Zak a73f59fa03 sulogin: remove consoles.c from libcommon
- 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-23 22:14:21 +01:00
Karel Zak 45ddc110ac lib/ismounted: improve loopdev support
... 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-19 14:34:01 +01:00
Karel Zak ca4f6229b0 lib/ismounted: basic support for loop devices
# 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-19 12:40:32 +01:00
Karel Zak 06f588f7d1 lib/loopdev: fix loopdev_find_by_backing_file()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-19 12:40:19 +01:00
Werner Fink ab6478ef2d sulogin: mount temporary /dev and /proc if not found
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-18 15:45:33 +01:00
Werner Fink cae29b3717 sulogin: use the linked lists from list.h for consoles list
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-18 15:02:35 +01:00
Karel Zak 59da1544ce include/list: add list_last_entry()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-18 15:00:03 +01:00
Karel Zak 33c5fd0c5a lib/canonicalize: add canonicalize_path_restricted() to canonicalize without suid permisssions
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-26 16:24:28 +01:00
Karel Zak 37a5c7ee41 lib/path: add path_read_u64()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-23 14:58:21 +01:00
Karel Zak ca01695b77 lib/path: rename functions to be more explicit
... and to have names compatible with lib/sysfs.c

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-23 14:58:21 +01:00
Karel Zak 1ef28920f8 lib/ttyutils: add get_terminal_name()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-22 14:40:14 +01:00
Karel Zak 5f247c8bcd lib/ttyutils: add test program
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-22 14:32:21 +01:00
Karel Zak 4e76adb0e1 lib/ttyutils: create .c file
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-22 14:26:41 +01:00
Karel Zak b481b622c5 lib/loopdev: make loopcxt_get_device() more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-12 12:10:52 +01:00
Karel Zak 874dbb9c92 lib/console: fix possible fd leak
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-09 12:59:33 +01:00
Karel Zak 27a76b7bd0 lib/consoles: try another methods before go to fallback
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-09 12:52:33 +01:00
Karel Zak b25343bbbc lib/consoles: add debug messages
- may be enabled by CONSOLES_DEBUG env. variable

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-09 12:48:33 +01:00
Karel Zak 6ea0921e16 lib/consoles: TIOCGDEV code refactoring
- 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-09 12:18:31 +01:00
Karel Zak 4fcee23da5 lib/consoles: cmdline code refactoring
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-09 11:52:11 +01:00
Karel Zak 615eada9b2 lib/consoles: sysfs code refactoring
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-09 11:17:23 +01:00
Karel Zak aded518ae1 lib/consoles: /proc/consoles code refactoring
- move to separate function
 - cleanup code
 - fix fscanf() usage to avoid buffer overflow

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-09 11:15:50 +01:00
Karel Zak 97909f6131 lib/consoles: small cleanup
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-09 10:30:14 +01:00
Karel Zak f0d6004ce7 lib/consoles: don't call perror()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-09 10:18:49 +01:00
Karel Zak 82d11fbd0f lib/consoles: add test program
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-09 10:12:35 +01:00
Karel Zak cf987d0aa7 lib/consoles: remove global variable consoles
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-09 10:06:23 +01:00
Karel Zak 6c7c1eaf2a lib/consolas: remove global variable concount, fix linked list
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-09 09:52:35 +01:00
Karel Zak 53e0a68806 lib/consoles: remove global variable initcp
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-08 17:25:09 +01:00
Karel Zak e0e5974fde lib/consoles: remove global variable comparedev
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-08 17:22:45 +01:00
Karel Zak 95226b5522 lib/consoles: minor clean ups
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-08 17:04:01 +01:00
Werner Fink 3a08f74f1d lib/consoles: add code to detect all system consoles
Signed-off-by: Werner Fink <werner@suse.de>
2012-11-08 15:55:48 +01:00
Karel Zak e21e6d265d build-sys: cleanup cpu_set_t usage
- make taskset depend on cpu_set_t
 - make cpuset.c optional for libcommon and lib/path.c

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-02 12:07:36 +01:00
Karel Zak 9f51089e7f misc: make readlink() usage more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-23 12:40:39 +02:00
Karel Zak a5dc4d2d95 lib/sysfs: add SCSI link functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-23 12:21:23 +02:00
Karel Zak 23a11c74a6 lib/sysfs: add functions for SCSI host attributes
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-23 12:18:57 +02:00
Karel Zak d0f7e5b4a0 include/sysfs: add SCSI host:channel:target:lun support
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-23 12:15:58 +02:00
Karel Zak c47681b4e4 lib/tt: don't ignore "extreme" columns if an free space is available
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-23 10:56:23 +02:00
Karel Zak df0f2ad763 lib/loopdev: check for /sys
The current loopdev code prefers /sys to get information about
loop devices. The old methods like scan /dev are fallback solution
only. Unfortunately, the code does not check if /sys is mounted.

Addresses: http://blog.flameeyes.eu/2012/10/sophistication-can-be-bad
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-17 11:51:10 +02:00
Karel Zak f4bf95926a lib/loopdev: improve debug messages
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-17 11:42:21 +02:00
Ondrej Oprala dfa68ad183 lib/color: add module for work with terminal colors
[kzak@redhat.com: - split from dmesg patch
                  - add more colors]

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-16 16:39:00 +02:00
Mike Frysinger 6c6f719688 md5: fix strict aliasing warnings
This is the same fix as was merged in gcc/binutils where this code
appears to originate from.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-10-10 11:23:24 +02:00
Peter Rajnoha 857db7f53c lib/sysfs: fix sysfs_devname_to_devno for dm partitions
Partitions mapped by device-mapper are not like real partitions where
there's a /sys/block/<parent>/<name>/dev sysfs path. We need to look
at /sys/block/<name>/dev like we do for any other non-partition devices.
The mapped partition is not found otherwise.

For example, this bug shows up in lsblk while specifying a device
on command line while that device is a dm mapping over a partition:
$lsblk
NAME             MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                8:0    0  128M  0 disk
`-test (dm-0)    253:0    0  128M  0 dm
  `-test1 (dm-1) 253:1    0  127M  0 part

Before this patch:
$lsblk /dev/mapper/test1
lsblk: dm-1: unknown device name

With this patch:
$lsblk /dev/mapper/test1
NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
test1 (dm-1) 253:1    0  127M  0 part
2012-09-21 12:21:30 +02:00
Ludwig Nussel 5cf05c7147 mount: losetup: remove obsolete encryption support
kernel cryptoloop is deprecated since ages and support for cryptoloop
in util-linux is incomplete/broken.
- no password hashing
- last 8 bit of key are always set to zero
- no binary keys possible (stops reading key at \n and \0)

In the past some Distros added the above features with patches. So
remove cryptoloop support from util-linux completely to make sure
people won't try using it.

Signed-off-by: Ludwig Nussel <ludwig.nussel@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-11 10:46:11 +02:00
Karel Zak 9d48340d44 lib/pager: robust work with file descriptors [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-07 13:29:55 +02:00
Karel Zak fee9431f97 lib/sysfs: more robust sysfs_opendir() [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-07 12:15:39 +02:00
Bernhard Voelker f31322a289 lib/sysfs: make sysfs_partno_to_devno better readable
Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
2012-08-14 18:22:04 +02:00
Karel Zak 778ad369f6 lib/sysfs; add sysfs_partno_to_devno()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-08-13 22:06:18 +02:00
Karel Zak f369387731 lib/mangle: remove unused variable
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-08-13 21:57:34 +02:00
Karel Zak a3b780532f lib/sysfs: expect p<N> suffix for partitions
... so for example lsblk(8) will see partitioned loop devices

loop0       7:0    0    80G  0 loop
├─loop0p1 259:0    0   100M  0 loop
└─loop0p2 259:1    0  79.9G  0 loop

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-08-13 21:11:37 +02:00
Karel Zak 096db1ead1 libmount: fix unmangle code
old version:
  /mnt/ugly/te\134st\134 -> /mnt/ugly/te\st\134

fixed version:
  /mnt/ugly/te\134st\134 -> /mnt/ugly/te\st\

Reported-by: Naja Melan <najamelan@autistici.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-08-13 16:35:03 +02:00