summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)AuthorFilesLines
2011-09-29lib: [strutils] add strtod_or_err() functionSami Kerola1-0/+24
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-27lib,loopdev: fix use of logical '&&' with constant operandFrancesco Cosoleto1-2/+2
Found by clang. Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
2011-09-27lib,path: use write_all()Heiko Carstens1-1/+2
From: Heiko Carstens <heiko.carstens@de.ibm.com> Since write() doesn't necessarily write the complete buffer with one call we better use write_all() which takes care of this. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-09-27chcpu: convert to use lib/path.cHeiko Carstens1-0/+26
Use the common path access functions. In order to simplify chcpu also implement and use path_writestr() which writes a string to the path specified. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-09-27lib,path: move path access functions from lscpu into lib/path.cHeiko Carstens1-0/+191
A couple of these functions already have been copied to chcpu.c, so it makes sense to move these functions into an own file. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-09-13lib: do not attempt to close(0) in sysfs_deinit()Petr Uzel1-0/+1
If the 'open' fails we 'goto err' which runs 'sysfs_deinit()' on a 'cxt' which hasn't been fully initialised. The 'dir_fd' is still 0, so sysfs_deinit calls "close(0)". Addresses: https://bugzilla.novell.com/show_bug.cgi?id=714151 Reported-by: Diego Ercolani <diego.ercolani@gmail.com> Analysed-by: Neil Brown <nfbrown@suse.com> Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2011-09-12libmount: potential null derefence [smatch scan]Karel Zak1-2/+3
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-10lib,cpuset: fix compiler warning [-Wuninitialized]Karel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-10chcpu,cpuset: reduce code duplication for cpu list parsingHeiko Carstens1-1/+6
Reduce code duplication and print better error message if an unsupported cpu number was passed. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-09-10lib,cpuset: enforce stricter parsing of cpu listsHeiko Carstens1-4/+8
The current cpulist_parse() function ignores extra non-parsable characters at the end of the to be parsed cpu list string. E.g. it would accept something like "0bla" and just set bit 0 in the cpu set. Since such a string is invalid implement stricter parsing that makes sure that everything of the string has been succesfully parsed. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-09-10lib,cpuset: fix stride handling in cpulist_parse()Heiko Carstens1-0/+2
If cpulist_parse() gets passed a cpu list with a stride value of 0 it will be stuck in an endless loop. E.g. the following cpu list will cause an endless loop: "0-2:0". Fix this by causing a parse error if the stride value is 0. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-09-10lib,cpuset: fix odd placed braces in cpulist_parse()Heiko Carstens1-2/+2
The opening and closing braces for two following if statements within cpulist_parse() are placed in an odd manner. Just fix this to prevent broken code in the future. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-09-10lib,cpuset: fix comments for cpu mask/list functionsHeiko Carstens1-2/+2
The comments for cpumask_parse() and cpulist_parse() each describe the wrong function. Just exchange the comments. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-08-31Merge branch 'chcpu' of ↵Karel Zak1-2/+5
git://git.kernel.org/pub/scm/linux/kernel/git/heiko/util-linux * 'chcpu' of git://git.kernel.org/pub/scm/linux/kernel/git/heiko/util-linux: chcpu: new tool cpuset: add option to allow cpulist_parse() to fail
2011-08-23lib: [loopdev.c] correct qsort compare functionKarel Zak1-1/+2
Reported-by: Andreas Schwab <schwab@linux-m68k.org> Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-15cpuset: add option to allow cpulist_parse() to failHeiko Carstens1-2/+5
This is a preparation patch for chcpu. If a cpu should be added to a cpu_set where the cpu doesn't fit into the cpu_set this got silently ignored. Since the cpu-list is user space provided it should be checked if cpus are specified that are completely out of range of the system. In order to do that add a parameter which specifies if cpulist_parse() should fail if it parses a cpu-list with "impossible" cpus. The current callers have been converted so they behave like before. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-08-08lib: [loopdev.c] correct trivial typoDavidlohr Bueso1-1/+1
Should say "failed to find" instead of "failed to found". Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2011-08-01lib: [cpuset.c] fix compiler warnings [-Wsign-compare]Karel Zak1-9/+12
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-01lib: [mangle.c] fix compiler warnings [-Wsign-compare]Karel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-01lib: [tt.c] clean up used typesKarel Zak1-16/+20
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-01lib: [strutils.c] fix compiler warnings [-Wsign-compare]Karel Zak1-1/+1
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-01lib: [sysfs.c] fix compiler warnings [-Wsign-compare]Karel Zak1-3/+3
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-01lib: [at.c] fix compiler warnings [-Wunused-parameter]Karel Zak1-11/+24
at.c: In function ‘fstat_at’: at.c:14:35: warning: unused parameter ‘dirname’ [-Wunused-parameter] at.c: In function ‘open_at’: at.c:36:34: warning: unused parameter ‘dirname’ [-Wunused-parameter] at.c: In function ‘readlink_at’: at.c:66:42: warning: unused parameter ‘dirname’ [-Wunused-parameter] Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-28build-sys: fix 'make checkincludes' warningsKarel Zak2-4/+0
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-27include: [strutils.c] add list parsersKarel Zak2-41/+95
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-27include; [tt.c] check for array size in columns parserKarel Zak1-7/+11
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-26Merge branch 'cramfs' of https://github.com/kerolasa/lelux-utiliteetitKarel Zak1-2/+2
* 'cramfs' of https://github.com/kerolasa/lelux-utiliteetit: include: move fsck return values to exitcodes.h include: move disk-utils/mkfs.h -> include/exitcodes.h mkfs.cramfs: coding style mkfs.cramfs: include-what-you-use header check mkfs.cramfs: error printing fixes mkfs.cramfs: convert spaces to tabs mkfs.cramfs: validate numeric user inputs mkfs.cramfs: few symbolic exit codes where missing md5: use symbolical digest length mkfs.cramfs: use program_invocation_short_name mkfs.cramfs: use xalloc.h fsck.cramfs: add missed strings to translation fsck.cramfs: coding style fsck.cramfs: use xalloc.h fsck.cramfs: retire die function cramfs.h: coding style cramfs: use stdint.h instead of u{8,16,32} cramfs_common: coding style Conflicts: disk-utils/Makefile.am Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-26sysfs: free used resourcesDavidlohr Bueso1-0/+1
In the sysfs lib example, we should be using sysfs_deinit() to free used resources and for correct usage. Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2011-07-21md5: use symbolical digest lengthSami Kerola1-2/+2
Magic hash lenght number 16 is turned to a definition MD5LENGTH, and put into use everywhere where md5 checksum is in use. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-15include: [tt.c] always truncate if TT_FL_TRUNCKarel Zak1-2/+10
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-27lib: [blkdev.c] remove kernel version check from blkdev_get_sector_size()Karel Zak1-10/+3
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-27lib: [blkdev.c] more robust blkdev_is_misaligned()Karel Zak1-1/+5
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-27lib: [blkdev.c] add blkdev_get_physector_size()Davidlohr Bueso1-4/+33
This function uses the BLKPBSZGET ioctl to get the physical block size of the device. Signed-off-by: Davidlohr Bueso <dave@gnu.org> Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-20lib: [procutils.c] improve robustnessKarel Zak1-0/+3
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-20lib: [linux_version.c] simplify version parsingKarel Zak1-11/+11
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-20misc: hurd build fixesSamuel Thibault2-0/+5
* Make blkdev_is_misaligned return 0 when BLKALIGNOFF is not available. * Make procutils.c include c.h to get a PATH_MAX replacement. * Provide agetty.c USE_SYSLOG, DEFAULT_VCTERM and DEFAULT_STERM defaults for Hurd. * Make agetty.c only deal with OFDEL, XCASE and VSWTCH if they are available. Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-14lib: [tt.c] Fix mbs_width macro for systems without WIDECHARJosiah Worcester1-1/+1
Signed-off-by: Josiah Worcester <josiahw@gmail.com>
2011-06-10lib: [loopdev.c] cleanup flags usageKarel Zak1-17/+97
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-06lib: [linux_version.c] accommodate two-component linux version (e.g. 3.0)Karel Zak1-3/+3
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-01lib: add strtoul_or_err() functionSami Kerola1-0/+24
Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
2011-05-30lib: [loopdev.c] add module for work loop devicesKarel Zak3-3/+1066
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-05-30lib: [sysfs.c] fix double freeKarel Zak1-1/+3
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-05-26This adds a second parameter to size_to_human_string() to return aFrancesco Cosoleto1-8/+25
string with a different format based on the following flags: SIZE_SUFFIX_1LETTER = "1K" SIZE_SUFFIX_3LETTER = "1KiB", SIZE_SUFFIX_SPACE = "1 KiB" or "1 K" [kzak@redhat.com: - rename flags to SIZE_SUFFIX_* format, - fix suffix[] buffer size - add 3 letter version to the test] Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
2011-05-25build-sys: cleanup lib/ testsKarel Zak3-6/+11
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-05-18lib: [sysfs.c] add sysfs_readlink and name/path functionsKarel Zak1-14/+122
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-05-18lib: [at.c] add readlink_at(), fix semantic for absolute pathsKarel Zak1-12/+41
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-05-18lib: [sysfs.c] make sysfs_read_* function more robustKarel Zak1-11/+39
The functions does not modify result if the requested sysfs attribute does not exist. Signed-off-by: Karel Zak <kzak@redhat.com>
2011-05-18build-sys: disable lib/ at.c tests buildingKarel Zak1-2/+2
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-05-16libblkid: use stuff from sysfs.h and at.hKarel Zak1-0/+7
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-05-16lib: add generic sysfs utilsKarel Zak3-2/+351
Signed-off-by: Karel Zak <kzak@redhat.com>