If you mark a column with TT_FL_NOEXTREMES flag then extremely
large fields will no have effect to column width. Foe example:
without the TT_FL_NOEXTREMES flag for the 'AAA' column:
AAA BBB CCC DDD
aa bbb ccc ddd
aaaaaaaaaaa bb ccc ddd
aa bb ccc ddd
aa bb ccc ddd
with the flags:
AAA BBB CCC DDD
aa bbb ccc dddddddddd
aaaaaaaaaaa
bb ccc dddddddd
aa bb ccc dddddd
aa bb ccc ddddddddd
Signed-off-by: Karel Zak <kzak@redhat.com>
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>
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>
* 'sys-utils-again' of https://github.com/kerolasa/lelux-utiliteetit:
cytune: fix printf type warning
docs: mention long options in cytune.8
cytune: coding style fixes
cytune: refactor main(), new function query_tty_stats()
cytune: use libc error printing facilities
cytune: check numeric user inputs
cytune: add long options and usage()
docs: restructure flock.1 manual page
flock: simplify strtotimeval()
lib: [strutils] add strtod_or_err() function
flock: use strutils.h to check numeric user input
flock: use sysexit.h for all exit values
flock: use function attributes
flock: align with howto-usage-function.txt
flock: use libc error printing facilities
flock: move long_options struct to function scope
flock: fix coding style
docs: align fallocate.1 with howto-man-page.txt
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
* 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>
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>
We include the following functions as a first approach:
- proc_open_tasks(): allocate resources and setup basic data
- proc_next_tid(): iterate over the thread group
- proc_close_tasks(): free used resources
[kzak@redhat.com: - free() on error in proc_open_tasks(),
- always call free() in proc_close_tasks()
- ignore non-digit dirs and return 1 on end-of-dir
in proc_next_tid()]
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
This functions returns the status of the device's alignment. It will
be 0 when aligned, otherwise return the offset.
[kzak@redhat.com: - returns 0 if the ioctl failed]
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
On Sat, Apr 03, 2010 at 12:58:48PM +0000, Jorge wrote:
> When you want to write changes to disk you're asked for a
> confirmation, like this one:
>
> Are you sure you want to write the partition table to disk? (yes
> or no)
>
> There is no problem on the English version, but when you launch the
> program in Spanish you get this:
>
> ¿Está seguro de que desea escribir la tabla de particiones en el
> disco?
> (sí o no):
>
> You can't type the "í" character. Trying to do so will end in no
> input at all. That is, typing in my keyboard "´" then "i" leads to
> nothing. So you can't write changes to disk, and you must launch the
> program in English for it to operate.
Reported-by: Jorge <yo@jorgesuarezdelis.name>
Addresses: https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/205327
Signed-off-by: Karel Zak <kzak@redhat.com>
This function
int strtosize(const char *str, uintmax_t *res)
supports {K,M,G,T,E,P}iB and {K,M,G,T,E,P}B suffixes.
Signed-off-by: Karel Zak <kzak@redhat.com>
echo l | fdisk/fdisk /dev/zero
FYI that however now spins forever doing:
offset=3074457345618258603)
at ../lib/blkdev.c:31
at ../lib/blkdev.c:151
at ../lib/blkdev.c:161
Reported-by: Pádraig Brady <P@draigBrady.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
The ambivalent probing result should be properly reported and user
should be informed that the problem is possible to bypass by "-t
<type>" or resolved by wipefs(8).
The mount(8) command uses a brute force stage (calls mount(2) for all
/{proc,etc}/fylesystems) if there is not any other way how to detect
the filesystem type. The brute force stage should not be restricted by
libblkid. It's possible that libblkid is not able to detect slightly
corrupted filesystem, but kernel is able to mount such filesystem.
Note that the brute force stage should not be used if libblkid returns
ambivalent probing result. In this case user's intervention is required
(e.g. mount -t <type>).
Reported-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
$ make checkincludes
fsck/fsck.c: errno.h is included more than once.
lib/canonicalize.c: string.h is included more than once.
shlibs/blkid/src/blkidP.h: stdio.h is included more than once.
shlibs/blkid/src/devname.c: string.h is included more than once.
shlibs/blkid/src/devno.c: string.h is included more than once.
Signed-off-by: Karel Zak <kzak@redhat.com>
On Wed, Dec 09, 2009 at 10:08:38PM +0000, Jochen Voss wrote:
> while experimenting with coccinelle, I accidentally found what I
> believe is a bug in util-linux-ng release 2.17-rc2 (downloaded
> today). The problem is the following code in lib/md5.c (around line
> 153):
>
> void MD5Final(unsigned char digest[16], struct MD5Context *ctx)
> {
> [...]
> memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
> }
>
> The third argument of memset should probably be the size of 'struct
> MD5Context' instead of the size of the pointer. So my guess is
> that the memset line should be
>
> memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */
>
> instead. I don't know whether this actually causes a problem,
> but the comment makes it seem possible that it does.
Note, this typo does not have any impact on the utils in the
util-linux-ng project, because we don't use MD5 for any security
sensitive data or cryptographic stuff. The typo also does not have any
impact to the final MD5 hashes.
Reported-by: Jochen Voss <voss@seehuhn.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
* mount(8) uses private device-mapper names in mtab
* libblkid returns private device-mapper names when evaluate udev
/dev/disk-by symlinks.
* on systems where DM is fully integrated with udev the /dev/mapper/<name>
files are symlinks to /dev/dm-N. It means we need a special care to hide
private device-mapper names.
Signed-off-by: Karel Zak <kzak@redhat.com>
The current implementation uses fixed sector size (512 bytes), that's
wrong. UEFI standard requires real logical sector size -- it means
BLKSSZGET for Linux.
The size of GPT header is not static, but whole sector is allocated
for the header. In theory the HeaderSize field could be greater than
sizeof(struct gpt_header). It means we have to read whole sector with
the header, because the header crc32 checksum is counted according to
HeaderSize.
Signed-off-by: Karel Zak <kzak@redhat.com>
This is public domain implementation, based on static crc32_table[].
This implementation is used on may places (libparted, FreeBSD kernel,
PostgreSQL, ...). The Linux kernel uses on-the-fly generated and
allocated tables. That's useless in shared libraries.
Signed-off-by: Karel Zak <kzak@redhat.com>
The libvolume_id is deprecated in favor of libblkid. The libblkid from
u-l-ng provides the same functionality as libvolume_id.
Signed-off-by: Karel Zak <kzak@redhat.com>
When building util-linux-ng-2.15, I get this:
../lib/fsprobe.c:10:19: error: blkid.h: No such file or directory
Unfortunately, the blkid.pc uses -I${includedir}/blkidi since
e2fsprogs v1.41.2. The old versions use -I${includedir} only.
Reported-by: Robert Schwebel <r.schwebel@pengutronix.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
"SPEC" is usually used in mount(8) as a generic term for device name or
tag (LABEL, UUID). The function blkid_evaluate_* works with TAGs only.
Signed-off-by: Karel Zak <kzak@redhat.com>
<linux/fd.h> is included for no reason in lib/ismounted.c. This
obviously breaks on non-Linux systems.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
lib/fsprobe.c: In function ‘fsprobe_get_fstype_by_devname’:
lib/fsprobe.c:243: warning: return discards qualifiers from pointer target type
Signed-off-by: Karel Zak <kzak@redhat.com>
This is a small fragment from libdisk (from xfsprogs). The final
solution will be to move the library to util-linux-ng.
Signed-off-by: Karel Zak <kzak@redhat.com>
It seems that blkid.pc from e2fsprogs has been fixed:
$ pkg-config --libs blkid
-lblkid
and the pkg-config does not return any other extra libraries (such
-luuid or -ldevmapper).
Signed-off-by: Karel Zak <kzak@redhat.com>
* moves the generic libblkid/libvolume_id wrapper (fsprobe.c) from
mount/ to lib/. We'll use the wrapper in cfdisk and fsck.
The wrapper supports:
- obsolete volume_id (udev)
- obsolete libblkid (e2fsprogs)
- libblkid (util-linux-ng)
* mount, umount and swapon when linked against the new libblkid use
- low-level probing code to read LABEL, UUID or FSTYPE from a device
- high-level blkid_evaluate_spec() to convert LABEL/UUID to devname
Signed-off-by: Karel Zak <kzak@redhat.com>
[kzak@redhat.com: split the original patch to small patches]
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
The get_linux_version() function is Linux-specific.
Work around it in a few places.
[kzak@redhat.com: split the original patch to small patches]
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
Now we duplicate BLK* ioctls on many places... This patch also
fix BLKGETSIZE64 usage in dependence on kernel version.
Co-Author: Karel Zak <kzak@redhat.com>
Signed-off-by: Stefan Krah <stefan@bytereef.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
Build lib/*.c individually for each project which uses it, so that the
right set of flags is applied each time.
Signed-off-by: Stepan Kasal <skasal@redhat.com>
The generated autotools stuff shouldn't be maintained by SCM. After check out
from git use ./autogen.sh. For more details see README.devel.
Signed-off-by: Karel Zak <kzak@redhat.com>