summaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* lib/pager: repair build for non-Linux.Thomas Schwinge2012-05-291-1/+1
| | | | Signed-off-by: Thomas Schwinge <thomas@codesourcery.com>
* libmount: add MNT_ERR_LOOPDEVKarel Zak2012-05-281-0/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/tt: export tt_fputs_{quoted,nonblank} functionKarel Zak2012-05-221-4/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/strutils: create type specific strtoxx_or_err()Karel Zak2012-05-151-21/+74
| | | | | | | We need [un]signed int ([u]int32_t) on many places. It's also more readable and robust to use uintXX_t types than for example "long long". Signed-off-by: Karel Zak <kzak@redhat.com>
* include: move get_terminal_width() to ttyutils.hPetr Uzel2012-05-151-27/+1Star
| | | | Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
* include: rename writeall.h to all-io.hPetr Uzel2012-05-151-1/+1
| | | | Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
* lib/mangle: check for end of string on every iterationDave Reisner2012-05-151-4/+5
| | | | | | | | | Checking for the null byte at the end of the string only conditionally leads to segfaults, evidenced by mount helpers crashing on writes to /run/mount/utab. Simply check for the null on each iteration, and append a null byte to the mangled string before breaking. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
* libuuid: avoid double open and leaking fd (reworked)Petr Uzel2012-05-101-5/+3Star
| | | | | | | | | | | | | | This reverts commit 6126f7a53c57485a9a29ddd772765695f23c92e6 and fixes the double open and leaking descriptor in a different way, that is by using newly introduced function 'have_random_source()' to check whether good random source is available while deciding which uuid type to generate (random/time). This is better than calling random_get_fd() twice, passing the file descriptor down the stack and reusing it in next call to random_get_fd(). Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
* libuuid: avoid double open and leaking descriptorPetr Uzel2012-05-041-3/+5
| | | | | | | | | | | | | We are opening /dev/urandom twice in uuid_generate(): first to check if the file is available and then later __uuid_generate_random() again to actually get the random data. Moreover, descriptor from the first open is leaking. Fix by passign the descriptor down the stack and reusing it there. References: http://marc.info/?l=util-linux-ng&m=133406051131131&w=2 Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
* lib/strutils: add string_to_bitmask()Karel Zak2012-05-031-0/+43
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* include/tt: remove obsolete stuffKarel Zak2012-05-031-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/tt: check for non-printable chars for raw/export formatKarel Zak2012-04-261-3/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/tt: encode data for RAW and EXPORT formatKarel Zak2012-04-261-2/+30
| | | | | | | * all tt based utils will properly encode blank chars for raw output format and quotes for export output format Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/mangle: cleanup, add unhexmangleKarel Zak2012-04-261-18/+39
| | | | | | | | * use strchr() rather than for() * small refactoring in mangle code * add un-hex-mangle Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/fileutils: add get_fd_tabsize()Karel Zak2012-04-231-0/+24
| | | | | | as a fallback for the function getdtablesize() Signed-off-by: Karel Zak <kzak@redhat.com>
* Fix typos found by misspellingsBernhard Voelker2012-04-231-1/+1
| | | | | | | | | | | | | | | The tool misspellings (https://github.com/lyda/misspell-check) detected several typos. Command used: $ git ls-files | grep -v ^po/ | misspellings -f - * isosize: Fix typo in usage string. * configure.ac: Fix typo in help string of --enable-most-builds option. * fdisk: Fix typo in man page. * libblkid, blkid, mount: Likewise. * Fix various typos in docs and in source code comments. Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
* lib/pager: fix compiler warningsKarel Zak2012-04-231-4/+2Star
| | | | | | | | | | | pager.c: In function ‘start_command’: pager.c:82:7: warning: unused variable ‘err’ [-Wunused-variable] pager.c:49:25: warning: unused variable ‘fderr’ [-Wunused-variable] pager.c:49:15: warning: unused variable ‘fdout’ [-Wunused-variable] pager.c:48:25: warning: unused variable ‘need_err’ [-Wunused-variable] pager.c:48:15: warning: unused variable ‘need_out’ [-Wunused-variable] Signed-off-by: Karel Zak <kzak@redhat.com>
* lib: add pager functionalityDavidlohr Bueso2012-04-232-0/+216
| | | | | | | | | When some program' output exceeds the terminal's dimensions, it is a nice feature to call a pager that acts as calling 'less' to allow better user navigation. This patch adds this functionality, based on what perf and git have (ie: git log). Signed-off-by: Davidlohr Bueso <dave@gnu.org>
* lib: random utilitiesDavidlohr Bueso2012-04-102-0/+122
| | | | | | | | | | | | | | Add a random number(s) generator specific file. The intial functions are based on what libuuid provide. I did some modifications like avoid WIN32 checks - this is util-LINUX. [kzak@redhat.com: - move jrand_seed to lib/randutils.c - use TLS for jrand_seed (like original code from libuuid) - use size_t for buffer sizes - add close() to random_get_bytes] Signed-off-by: Davidlohr Bueso <dave@gnu.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/blkdev: fix compiler warning [-Wreturn-type]Karel Zak2012-04-101-1/+3
| | | | | | | ../lib/blkdev.c: In function ‘blkdev_get_geometry’: ../lib/blkdev.c:287:1: warning: control reaches end of non-void function [-Wreturn-type] Signed-off-by: Karel Zak <kzak@redhat.com>
* strutils: return success on test programDavidlohr Bueso2012-04-101-1/+1
| | | | Signed-off-by: Davidlohr Bueso <dave@gnu.org>
* fdisk: move kernel geometry into blkdevDavidlohr Bueso2012-04-101-0/+23
| | | | | | This is a more generic place for this ioctl. Signed-off-by: Davidlohr Bueso <dave@gnu.org>
* Merge branch 'eject'Karel Zak2012-04-051-2/+151
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * eject: (47 commits) tests: use eject --force eject: use BUILD_EJECT, move to sys-utils eject: clean up usage() eject: clean up man page eject: add --force option eject: check for hotplug/removable attribute eject: remove obsolete code, use EXIT_* macros tests: add umount-by-eject tests eject: improve work with partitioned devices lib/sysfs: improve sysfs_is_partition_dirent() eject: call umount <mountpoint> rather than <device> eject: use libmount to detect if cdrom is mounted eject: make the code robust eject: use SG_IO ioctl for scsi eject: support CDIOCEJECT ioctl eject: new close_tray code from Fedora eject: new auto_eject code from Fedora eject: add -X from Fedora eject: add --manualeject from fedora eject: clean up devname usage ...
| * lib/sysfs: improve sysfs_is_partition_dirent()Karel Zak2012-03-291-2/+22
| | | | | | | | | | | | ... to work with absolute disk device path too. Signed-off-by: Karel Zak <kzak@redhat.com>
| * sysfs: move blkid_devno_to_wholedisk to sysfs_devno_to_wholediskMichal Luscon2012-03-271-0/+129
| | | | | | | | Signed-off-by: Michal Luscon <mluscon@redhat.com>
* | lib/loopdev: more robust initializationKarel Zak2012-04-021-1/+2
| | | | | | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* | lib/strutils: add strtosize_or_err, clean upKarel Zak2012-03-301-37/+45
|/ | | | | | | | | | | | * add strtosize_or_err(), we use strtosize() + err() on many places * add STRTOXX_EXIT_CODE to overwrite the default EXIT_FAILURE * remove else-after-noreturn (e.g. if (foo) err(...); else err(...)) * clean up indent... Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: move obsolete lib/fsprobe to mount/Karel Zak2012-03-271-142/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* Revert "lib/canonicalize: always remove tailing slash"Karel Zak2012-03-261-10/+3Star
| | | | | | | | | | | | | | | | | | | It's overkill to modify unknown paths in a generic function like canonicalize_path(). for example: mount -t fuse 'sshfs#marty@thee:/' /media/thee will be canonicalized to mount -t fuse 'sshfs#marty@thee:' /media/thee and this obvious bug. Reported-by: Martin Panter <vadmium+floss@gmail.com> This reverts commit 28074a0952469aebf021821d95238cfb964d13ff.
* lib/tt: work more sensitive with large columnsKarel Zak2012-03-201-1/+7
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fileutils: differentiate xmkstemp and xfmkstempSami Kerola2012-03-181-13/+10Star
| | | | | | | | | | | | Let developer to choose, case by case, what sort of return value is best in her code. The xmkstemp() is for users who want file descriptor as return value of the function, xfmkstemp() will return FILE pointer. Proposed-By: Karel Zak <kzak@redhat.com> CC: Davidlohr Bueso <dave@gnu.org> Reference: http://marc.info/?l=util-linux-ng&m=133129570124003&w=2 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* xalloc: use xasprintf in all filesSami Kerola2012-03-181-2/+3
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib: add fileutils function collectionSami Kerola2012-03-182-0/+57
| | | | | | | | | The fileutils contains xmkstemp function will create temporary file safe and reusable manner. Reference: http://www.dwheeler.com/secure-programs/Secure-Programs-HOWTO.html#TEMPORARY-FILES CC: Davidlohr Bueso <dave@gnu.org> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lsblk: add inverse tree support (-s)Peter Rajnoha2012-03-071-2/+3
| | | | | | | | | | | $ lsblk --inverse -o NAME /dev/dm-0 NAME luks-10d813de-fa82-4f67-a86c-23d5d0e7c30e (dm-0) └─sda6 └─sda Signed-off-by: Peter Rajnoha <prajnoha@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* libblkid: fix sysfs context usageKarel Zak2012-03-061-3/+3
| | | | | Reported-by: Elan Ruusamäe <glen@delfi.ee> Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: enhance readability of the autotools filesSami Kerola2012-02-281-8/+16
| | | | | | | | Several horizontal lists are turned to vertical, and sorted to alphabetical order. Additionally spaces are converted to tabs where ever possible. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib/canonicalize: always remove tailing slashKarel Zak2012-02-241-3/+10
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* docs: corrections to FSF license files, and postal addressSami Kerola2012-02-241-3/+3
| | | | | | | | | | | | | | The COPYING and Documentation/licenses/COPYING* files are being replaced by files from GNU web site. http://www.gnu.org/licenses/gpl-2.0.txt http://www.gnu.org/licenses/lgpl-2.1.txt Postal addresses to FSF in other files are updated to match with the address in license files. Reference: http://lists.gnu.org/archive/html/freefont-announce/2005-04/msg00001.html Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* lib/strutils: move array bounds check in string_to_idarray() to appropriate ↵Chandan B Rajenda2012-02-231-2/+2
| | | | | | | | | | | place. string_to_idarray() will incorrectly exit with an error when the last element of the passed in array gets filled. However it should only exit with an error if there is more input. To fix this move the array bounds check. Signed-off-by: Chandan B Rajenda <chandan@linux.vnet.ibm.com> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
* lib/fsprobe: mar this internal API as deprecatedKarel Zak2012-02-131-0/+5
| | | | | | | | | | | | The fsprobe has been added many years ago to provide unified API for - built-in libblkid - e2fsprogs libblkid - udev libvolume_id these all is unnecessary as we strictly depends on built-in libblkid. Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/loopdev: remove dead assigment and null deferenceKarel Zak2012-02-021-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/loopdev: fix part scan detection codeKarel Zak2012-02-021-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/sysfs: fix handle leakKarel Zak2012-02-011-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/loopdev: fix possible dir leak on errorKarel Zak2012-02-011-0/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib/sysfs: fix possible fd leak on errorKarel Zak2012-02-011-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* losetup: make xgetpass more robustKarel Zak2012-01-171-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* lib,loopdev: remove duplicate includesKarel Zak2012-01-171-1/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: avoid duplicate loopdevsKarel Zak2012-01-161-1/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* losetup: move xgetpass() to lib/xgetpass.cKarel Zak2012-01-111-0/+46
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* loopdev: improve debug messagesKarel Zak2012-01-091-2/+10
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>