Commit Graph

18 Commits

Author SHA1 Message Date
Chandan B Rajenda 179b923a19 lib/strutils: move array bounds check in string_to_idarray() to appropriate 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>
2012-02-23 10:54:25 +01:00
Petr Uzel b106d05238 libmount: ignore tailing slash in netfs source paths
Addresses: https://bugzilla.novell.com/show_bug.cgi?id=728480
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-11-08 16:25:01 +01:00
Davidlohr Bueso af7df9ee67 lib,strutils: add default value to parse_range()
This function currently sets the low or high values to 0 when the string doesn't
contain a value, like '123:' or ':123'. In order to make it more flexible, we allow it
to be passed an arbitrary value.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2011-10-17 11:06:48 +02:00
Davidlohr Bueso a883c6349c lib,strutils: share parse_range()
This function is currently only being used by partx(8), but it's handy and
generic enough that we can use it elsewhere as well.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2011-10-12 10:01:26 +02:00
Sami Kerola a9f97001c3 lib: [strutils] add strtod_or_err() function
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-29 22:45:27 +02:00
Karel Zak b28f22673d lib: [strutils.c] fix compiler warnings [-Wsign-compare]
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-01 12:01:29 +02:00
Karel Zak c87638ad30 include: [strutils.c] add list parsers
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-27 16:41:21 +02:00
Sami Kerola e53bc9604c lib: add strtoul_or_err() function
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-01 09:57:43 +02:00
Francesco Cosoleto 5d2a98490e This adds a second parameter to size_to_human_string() to return a
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-26 15:32:33 +02:00
Karel Zak 69e433d8d9 lib: [strutils.c] more robust strtol checks
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-02-21 15:35:04 +01:00
Sami Kerola 94d32126bf strutils: new wrapper function strtoll_or_err
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-02-21 15:32:50 +01:00
Dave Reisner f9e05dafd0 lib: [strutils] avoid integer overflow on large values
This is visible on a 2TB disk via lsblk, where a large partition
incorrectly displays as 1.171798692T instead of 1.8T. This is
corrected by using a uint64_t type instead of a simple int --
consistant with the type used in lsblk.c to represent the raw size in
bytes.

[kzak@redhat.com: - add EiB support
                  - add size_to_human_string() to regression tests]

Signed-off-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-02-15 10:13:31 +01:00
Fabian Groffen eb76ca98b0 build-sys: provide alternatives for err, errx, warn and warnx
Solaris lacks err, errx, warn and warnx.  This also means the err.h header
doesn't exist.  Removed err.h include from all files, and included err.h from
c.h instead if it exists, otherwise alternatives are provided.

Signed-off-by: Fabian Groffen <grobian@gentoo.org>
2011-02-14 17:45:24 +01:00
Karel Zak 218f9d3d66 remove duplicate includes
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-04 22:36:09 +01:00
Karel Zak 013bff51a6 tests: fix strtosize() test
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-03 12:28:48 +01:00
Davidlohr Bueso c4ecaf21d5 partx: complete rewrite
Co-Author: Karel Zak <kzak@redhat.com>
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-12-09 21:54:17 +01:00
Karel Zak ce877f2d16 lib: [strutils] move strmode() from namei.c to strutils.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-11-24 17:08:32 +01:00
Davidlohr Bueso 8abcf29002 lib: [strutils] general purpose string handling functions
This patch replaces a few functions used throughout the source:
* Renames getnum (from schedutils) to strtol_or_err
* Moves strtosize (from lib/strtosize.c)
* Moves xstrncpy (from include/xstrncpy.h)
* Adds strnlen, strnchr and strndup if not available (remove it from libmount utils)

A few Makefile.am files were modified to compile accordingly along with trivial renaming
in schedutils source code.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2010-11-23 21:06:49 +01:00