Commit Graph

120 Commits

Author SHA1 Message Date
Karel Zak f9eec41838 lib: [fsprobe.c] fix blkid_evaluate_spec() call
lib/fsprobe.c:56:2: warning: passing argument 2 of ‘blkid_evaluate_spec’ from incompatible pointer type
shlibs/blkid/src/blkid.h:189:14: note: expected ‘struct blkid_struct_cache **’ but argument is of type ‘blkid_cache’

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-03-22 09:54:57 +01:00
Karel Zak 5298f72839 libblkid: add blkid_evaluate_spec()
The function blkid_evaluate_tag() is useful for tags only (e.g.
LABEL=foo). But we also need to address devices by tags OR paths in
many utils.

The function blkid_evaluate_spec() support this functionality without
extra care about the way how device is addressed. The tags as well as
paths are converted to the standardized device path.

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-03-17 12:51:06 +01:00
Karel Zak 70cc35de73 lib: [fsprobe.c] remove obsolete <blkid/blkid.h>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-03-16 17:48:47 +01:00
Karel Zak b9eb3c1131 lib: [fsprobe.c] use internal libblkid only
fsck, mount and swapon will be compilable with libblkid from
util-linux package. The old libblkid from e2fsprogs will not be
supported.

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-03-16 16:22:36 +01:00
Karel Zak feb81b6897 lib: [tt.c] use mbs_truncate() from mbsalign.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-03-11 15:30:27 +01:00
Karel Zak 7b6911e9ae lib: [tt.c] dereferencing data before a null check [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-03-11 15:00:30 +01:00
Karel Zak 6c7f688b1f umount: segfaults with inconsistent entry in /etc/fstab
Addresses: https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/726283
Reported-by: Greg Brockman <gdb@gregbrockman.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-03-04 14:44:29 +01:00
Karel Zak 6c7d5ae9a2 move struct option to .rodata
It does not make sense to have writable large arrays of "struct
option" on the stack.

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-03-03 15:00:30 +01: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
Karel Zak 9da2972c15 tests: [cpuset] call free() for range
The free() before exit() is not so important, but let's keep the
example code nice and consistent.

Reported-by: Steve Grubb <sgrubb@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-02-17 11:26:36 +01:00
Karel Zak 2fa3fbe858 fdisk: more robust whole-disk detection
In lib/wholedisk.c, i is set to 0. If fd was a -1, then at
line 18 geometry.start is used without it being initialized.

Reported-by: Steve Grubb <sgrubb@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-02-17 11:02:26 +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
Sami Kerola 2897f29a10 cfdisk: data type mismatch, and other, compiler warning fixes
Following warnings will longer appear when one will compile with
gcc flags -Wall -Wextra -pedantic

cfdisk.c:475:3: warning: comparison of unsigned expression < 0 is always false
cfdisk.c:487:16: warning: comparison between signed and unsigned integer expressions
cfdisk.c:492:14: warning: comparison between signed and unsigned integer expressions
cfdisk.c:565:19: warning: comparison between signed and unsigned integer expressions
cfdisk.c:569:19: warning: comparison between signed and unsigned integer expressions
cfdisk.c:1070:14: warning: comparison between signed and unsigned integer expressions
cfdisk.c:1568:5: warning: missing initializer
cfdisk.c:1568:5: warning: (near initialization for 'tmp_ext.volume_label')

mbsalign.c:131:2: warning: comparison of unsigned expression >= 0 is always true

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-01-25 10:40:34 +01:00
Karel Zak 1f51db365f include: [tt] enlarge output buffer
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-25 00:24:17 +01:00
Fabian Groffen aabe244176 build-sys: use WORDS_BIGENDIAN to determine platform byte-order
Autoconf contains the right magic to determine the endianness on many
platforms next to Linux.  This reverses previous commits to move away
from WORDS_BIGENDIAN:
"use __BYTE_ORDER rather than AC specific WORDS_BIGENDIAN"

This is necessary to compile on non Linux platforms like Darwin and
Solaris.

Signed-off-by: Fabian Groffen <grobian@gentoo.org>
2011-01-17 15:34:45 +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 049caefdcf findmnt: add --submounts option
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-04 14:01:33 +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
Karel Zak 035507c84b lib: [env] consolidate safe_getenv() usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-03 12:28:48 +01:00
Karel Zak 5ac6a13327 libmount: cleanup mangle() usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-03 12:28:47 +01:00
Karel Zak dd36965211 libmount: use better format for utab, improve bind mounts
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-03 12:28:46 +01:00
Karel Zak 8f3f6383a5 libmount: rewrite mountinfo/fstab parsers to use sscanf()
The old solution (without scanf()) was based on old code from
mount(8). It seems that the modern libc is able to provide all
necessary functionality by sscanf() and %ms directive.

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-03 12:28:43 +01:00
Karel Zak 7a539b29af lib: fix mange() and unmangle() to handle NULL
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-03 12:28:40 +01:00
Karel Zak 3c5e4ef888 libmount: add unmangle/mangle() functions to API
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-03 12:28:40 +01:00
Karel Zak 5a5eeb1513 lib: add wrappers for "at" functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-01-03 12:28:39 +01:00
Karel Zak f872ed1f22 lib: [tt] fix alignment of the last tree child
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-12-16 12:12:43 +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 601d12fb10 rename util-linux-ng back to util-linux
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-11-30 11:41:59 +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
Karel Zak 3e451589d5 lib: [tt] add TT_FL_RIGHT, add columns list parser
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-11-24 17:08:31 +01:00
Karel Zak 8c9e72ce2b lib: [ismounted] don't wast time with mtab is /proc/mounts used
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-11-24 17:08:26 +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
Karel Zak f7a29259ee findmnt: follow HAVE_LANGINFO
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-11-15 16:47:13 +01:00
Karel Zak dc61d398ba lib: add fallback for nl_langinfo()
The fallback ignores locales and returns hardcoded static strings. It
should be enough to include "nls.h" to work with nl_langinfo() on all
systems.

Signed-off-by: Karel Zak <kzak@redhat.com>
2010-11-15 16:42:45 +01:00
Davidlohr Bueso 97be4a37e3 lib/tt: fix langinfo build break
When HAVE_LANGINFO_H is not defined we break the compilation in tt.c:

  CC     tt.o
tt.c: In function ‘tt_new_table’:
tt.c:142: warning: implicit declaration of function ‘nl_langinfo’
tt.c:142: error: ‘CODESET’ undeclared (first use in this function)
tt.c:142: error: (Each undeclared identifier is reported only once
tt.c:142: error: for each function it appears in.)
make: *** [tt.o] Error 1

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2010-11-15 13:37:27 +01:00
Karel Zak 6cfa971e1b lib: add test program to canonicalize.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-10-25 11:00:15 +02:00
Karel Zak fab1c0463a lib: fix syntax error in blkdev.c
Reported-by: Tuco <tuco.xyz@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-08-23 11:06:08 +02:00
François Revol 9779651e2b portability: fix mntent.h and pty.h usage
Signed-off-by: François Revol <revol@free.fr>
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-07-26 11:43:51 +02:00
Samuel Thibault 4951f9b38f build-sys: minor changes for GNU/Hurd
Here is a patch to fix the build on GNU/Hurd.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2010-06-14 11:10:02 +02:00
Karel Zak e7baa97105 lib: remove unwanted debug messages
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-06-03 15:20:13 +02:00
Karel Zak ac3d410c46 lib: tt.c - fix minimal width of column
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-06-03 15:20:12 +02:00
Karel Zak 46e9ff0aeb lib: tt.c: don't print header for empty table
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-06-03 15:20:12 +02:00
Karel Zak c15b21e4e3 lib: add tt.c (Tree and Table output)
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-06-03 15:20:12 +02:00
Karel Zak bae91ecf07 taskset: move NR_CPUS determination to lib/cpuset.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-06-01 11:11:26 +02:00
Karel Zak ee32c514b5 lib: add fallback for libc (uClibc) without CPU_ALLOC
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-06-01 11:09:23 +02:00
Karel Zak ff5a6d2067 taskset: use libc based cpu_set_t
The glibc already supports dynamically allocated CPU sets. We don't
have to maintains our private non-compatible implementation.

Signed-off-by: Karel Zak <kzak@redhat.com>
2010-06-01 11:06:50 +02:00
Karel Zak 125b6a9191 tests: add cpuset regression test
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-06-01 11:06:49 +02:00
Karel Zak efcb71f8ff taskset: move bitmap routines to lib/cpuset.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-06-01 11:04:44 +02:00