]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
8 years agolib/randutils: add xsrand() and rand_get_number()
Karel Zak [Tue, 6 Sep 2016 08:19:52 +0000 (10:19 +0200)] 
lib/randutils: add xsrand() and rand_get_number()

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agosfdisk: add --no-tell-kernel
Karel Zak [Fri, 2 Sep 2016 09:14:54 +0000 (11:14 +0200)] 
sfdisk: add --no-tell-kernel

The option forces sfdisk to not call re-read partitions ioctl after
write PT.

Requested-by: Scott Moser <smoser@ubuntu.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agotests: update sfdisk output strings
Karel Zak [Thu, 1 Sep 2016 09:43:42 +0000 (11:43 +0200)] 
tests: update sfdisk output strings

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agosfdisk: make non-interactive output more readable
Karel Zak [Wed, 31 Aug 2016 13:51:11 +0000 (15:51 +0200)] 
sfdisk: make non-interactive output more readable

 # echo -e ',1M\n,2M' | sfdisk /dev/sdc

Old version:

  >>> Created a new DOS disklabel with disk identifier 0x8fc7d065.
  Created a new partition 1 of type 'Linux' and of size 1 MiB.
  /dev/sdc2: Created a new partition 2 of type 'Linux' and of size 2 MiB.
  /dev/sdc3:

New version:

  >>> Created a new DOS disklabel with disk identifier 0x9afe17c0.
 /dev/sdc1: Created a new partition 1 of type 'Linux' and of size 1 MiB.
 /dev/sdc2: Created a new partition 2 of type 'Linux' and of size 2 MiB.
 /dev/sdc3: Done.

Addresses: https://github.com/karelzak/util-linux/issues/337
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibsmartcols: use SCOLS_FL_RIGHT in sample
Karel Zak [Wed, 31 Aug 2016 13:51:03 +0000 (15:51 +0200)] 
libsmartcols: use SCOLS_FL_RIGHT in sample

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibsmartcols: add maxout sample
Karel Zak [Wed, 31 Aug 2016 13:15:28 +0000 (15:15 +0200)] 
libsmartcols: add maxout sample

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibsmartcols: fix minimal column width calculation
Karel Zak [Wed, 31 Aug 2016 13:13:06 +0000 (15:13 +0200)] 
libsmartcols: fix minimal column width calculation

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibsmartcols: fix non-tty output for 'maxout' columns
Karel Zak [Wed, 31 Aug 2016 11:01:48 +0000 (13:01 +0200)] 
libsmartcols: fix non-tty output for 'maxout' columns

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibsmartcols: fix title output on non-tty
Karel Zak [Wed, 31 Aug 2016 10:42:38 +0000 (12:42 +0200)] 
libsmartcols: fix title output on non-tty

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibsmartcols: fix scols_table_enable_colors() usage in samples
Karel Zak [Wed, 31 Aug 2016 10:05:48 +0000 (12:05 +0200)] 
libsmartcols: fix scols_table_enable_colors() usage in samples

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibsmartcols: don't print title color is colors disabled
Karel Zak [Wed, 31 Aug 2016 10:05:21 +0000 (12:05 +0200)] 
libsmartcols: don't print title color is colors disabled

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolib/loopdev: Set errno in is_loopdev on error
Tobias Stoeckmann [Tue, 30 Aug 2016 19:00:38 +0000 (21:00 +0200)] 
lib/loopdev: Set errno in is_loopdev on error

The function is_loopdev does not set errno if the supplied string does
not reference a valid loop device. Fix this to avoid an error message
like this one:

  losetup: /: failed to use device: Success

I prefer this one:

  losetup: /: failed to use device: No such device

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 years agomount: add note about paths verification to mount.8
Karel Zak [Wed, 31 Aug 2016 07:48:43 +0000 (09:48 +0200)] 
mount: add note about paths verification to mount.8

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibblkid: [exfat] Limit maximum number of iterations in find_label
Rostislav Skudnov [Tue, 30 Aug 2016 10:07:49 +0000 (10:07 +0000)] 
libblkid: [exfat] Limit maximum number of iterations in find_label

Do not hang if there is a cluster chain loop in rootdir

[kzak@redhat.com: - add return NULL]

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibblkid: ignore empty MBR on LVM device
Karel Zak [Tue, 30 Aug 2016 10:07:40 +0000 (12:07 +0200)] 
libblkid: ignore empty MBR on LVM device

It's possible to use boot sector and empty MBR on LVM physical volume
to make LVM disk bootable. In this case MBR should be ignored and disk
reported as LVM.

Just for the record, this is ugly non-default LVM setup maintained for
backward compatibility (yes, LVM guys don't like it too).

Unfortunately people still use it. The proper way is to use regular
partitioned disk.

Reported-by: Xen <list@xenhideout.nl>
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibblkid: remove unused function
Karel Zak [Tue, 30 Aug 2016 09:22:30 +0000 (11:22 +0200)] 
libblkid: remove unused function

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoumount: cleanup umount.8 about mtab
Karel Zak [Tue, 30 Aug 2016 08:41:05 +0000 (10:41 +0200)] 
umount: cleanup umount.8 about mtab

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoumount: fix obsolete info about loop= in umount.8
Karel Zak [Tue, 30 Aug 2016 08:25:44 +0000 (10:25 +0200)] 
umount: fix obsolete info about loop= in umount.8

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1370959
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibblkid: Avoid OOB access on illegal ZFS superblocks
Tobias Stoeckmann [Sun, 28 Aug 2016 19:15:59 +0000 (21:15 +0200)] 
libblkid: Avoid OOB access on illegal ZFS superblocks

64 bit systems can trigger an out of boundary access while performing
a ZFS superblock probe.

This happens due to a possible integer overflow while calculating
the remaining available bytes. The variable is of type "int" and the
string length is allowed to be larger than INT_MAX, which means that
avail calculation can overflow, circumventing the "avail < 0" check and
therefore accessing memory outside the "buff" array later on.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 years agolibfdisk: Distinguish between first LBA sector and partition
Tobias Stoeckmann [Sat, 27 Aug 2016 17:28:48 +0000 (19:28 +0200)] 
libfdisk: Distinguish between first LBA sector and partition

An insufficient check leads to an invalid free space output, as seen here:

$ dd if=/dev/zero of=cfdisk.iso bs=1M count=1
$ losetup -f cfdisk.iso
$ echo w | fdisk /dev/loop0
$ echo '1,1' | sfdisk /dev/loop0 --append
$ echo '3,' | sfdisk /dev/loop0 --append
$ sfdisk --list-free /dev/loop0
Start End Sectors Size
    1   2       2   1K
$ _

In this case, libfdisk fails to notice that it tries to calculate space
between two partitions, not between start of disk and first partition.
Currently, the code tries to achieve that by checking the address of the
last "partition", which is the first_lba block.  Now if the first
partition is merely 1 block in size, the "last" address is still equal
to the first_lba block, which renders the check in libfdisk for the next
partition invalid.

I chose to use "nparts == 0" for this check, because the partitions are
properly sorted before iterating over them.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 years agolibfdisk: Fix assert error in free space handling
Tobias Stoeckmann [Sat, 27 Aug 2016 17:28:16 +0000 (19:28 +0200)] 
libfdisk: Fix assert error in free space handling

An off-by-one issue exists in fdisk_get_freespaces. It can trigger an
assert, as seen here:

$ dd if=/dev/zero of=cfdisk.iso bs=1M count=1
$ losetup -f cfdisk.iso
$ echo w | fdisk /dev/loop0
$ echo '1,2' | sfdisk /dev/loop0 --append
$ echo '3,' | sfdisk /dev/loop0 --append
$ sfdisk --list-free /dev/loop0
Aborted
$ _

Problem here is an invalid "grain" processing. A grain is considered
expected free space between partitions which can be required for proper
alignment. Normally, it's 1 MB but in this case our iso is merely 1 MB
so the grain is reduced to 1 byte.

The if-condition in question checks for "last + grain <= pa->start" and
therefore even triggers if there is no space between them (due to equal
check). Eventually, the start block address is higher than the end block
address which triggers the assert().

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
8 years agolib/pager: fix test
Karel Zak [Fri, 26 Aug 2016 15:47:01 +0000 (17:47 +0200)] 
lib/pager: fix test

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolib/pager: restore signals setting by pager_close()
Karel Zak [Fri, 26 Aug 2016 11:02:37 +0000 (13:02 +0200)] 
lib/pager: restore signals setting by pager_close()

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agofdisk: use PAGER for 'l' command.
Karel Zak [Fri, 26 Aug 2016 10:09:53 +0000 (12:09 +0200)] 
fdisk: use PAGER for 'l' command.

The list of the partition types is too long. Let's try to use $PAGER.

Reported-by: Bruce Dubbs <bruce.dubbs@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolib/pager: cleanup and extend API
Karel Zak [Fri, 26 Aug 2016 10:07:25 +0000 (12:07 +0200)] 
lib/pager: cleanup and extend API

* clean up function names

* add functions to temporary redirect to the pager and then restore
  original terminal output

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agosu, runuser, setpriv: create links between man pages
Karel Zak [Thu, 18 Aug 2016 09:12:44 +0000 (11:12 +0200)] 
su, runuser, setpriv: create links between man pages

.. and add notes about differences between the utuils.

Reported-by: Lennart Poettering <lennart@poettering.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agotests: fix losetup tests for --nooverlap
Karel Zak [Wed, 17 Aug 2016 11:54:34 +0000 (13:54 +0200)] 
tests: fix losetup tests for --nooverlap

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolosetup: allow to use --nooverlap when device specified
Karel Zak [Wed, 17 Aug 2016 11:52:22 +0000 (13:52 +0200)] 
losetup: allow to use --nooverlap when device specified

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agotests: Add losetup-loop test suite
Stanislav Brabec [Tue, 2 Aug 2016 18:00:46 +0000 (20:00 +0200)] 
tests: Add losetup-loop test suite

Add losetup loop test suite that tests proper behavior of conflicting and
re-used loop devices.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
8 years agolosetup: Prevent AUTOCLEAR detach race
Stanislav Brabec [Wed, 17 Aug 2016 10:54:40 +0000 (12:54 +0200)] 
losetup: Prevent AUTOCLEAR detach race

Kernel needs some time to delete a device after losetup --detach. If
the losetup --find --nooverlay is called just after losetup --delete,
it can sometimes attempt to recycle the device that is just being
released.  To prevent this race, clear the AUTOCLEAR flag of the
device.

[kzak@redhat.com: - rebase to the new version of the code]

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoloopdev: Implememt loopcxt_set_status()
Stanislav Brabec [Tue, 2 Aug 2016 17:57:56 +0000 (19:57 +0200)] 
loopdev: Implememt loopcxt_set_status()

Implement stand-alone loopcxt_set_status(). It allows manipulation with some
loop device parameters even if it is initialized.

Its function is limited by the kernel implementation, and only a small subset of
changes is allowed.

For more see linux/drivers/block/loop.c:loop_set_status()

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
8 years agolosetup: add --nooverlap options
Karel Zak [Wed, 17 Aug 2016 10:28:33 +0000 (12:28 +0200)] 
losetup: add --nooverlap options

This patch introduces overlap detections and loop devices
re-use for losetup(8). We already support this feature for mount(8)
where it's enabled by default (because we mount filesystems and it's
always mistake to share the same filesystem between more loop
devices).

Stanislav has suggested to enable this feature also for losetup by
default. I'm not sure about it, IMHO it's better to keep losetup(8)
simple and stupid by default, and inform users about possible problems
and solutions in the man page.

The feature forces losetup to scan all loop devices always when new
one is requested. This maybe disadvantage (especially when we use
control-loop  to avoid /sys or /dev scans) on system with huge number
of loop devices.

Co-Author: Stanislav Brabec <sbrabec@suse.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agotests: keep 'hppa' in fdisk/bsd test too
Karel Zak [Tue, 16 Aug 2016 11:40:44 +0000 (13:40 +0200)] 
tests: keep 'hppa' in fdisk/bsd test too

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agobuild-sys: add parisc to define ARCH_
Karel Zak [Tue, 16 Aug 2016 11:39:07 +0000 (13:39 +0200)] 
build-sys: add parisc to define ARCH_

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agotests: really fix fdisk/bsd for hppa
Helge Deller [Mon, 15 Aug 2016 20:26:30 +0000 (22:26 +0200)] 
tests: really fix fdisk/bsd for hppa

Finally fix the bsd testcase on the hppa architecture.

Commit 1b7be556e553cdcef6213ead6340832c306011ed tried to fix it,
but missed the fact that "uname -m" returns "parisc" or "parisc64"
instead of "hppa*".

Signed-off-by: Helge Deller <deller@gmx.de>
Cc: 827225@bugs.debian.org
8 years agolsns: support cgroup namespaces
Michał Bartoszkiewicz [Mon, 15 Aug 2016 10:22:30 +0000 (12:22 +0200)] 
lsns: support cgroup namespaces

Signed-off-by: Michał Bartoszkiewicz <mbartoszkiewicz@gmail.com>
8 years agoinclude/closestream: define exit codes
Karel Zak [Tue, 16 Aug 2016 11:35:06 +0000 (13:35 +0200)] 
include/closestream: define exit codes

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoinclude/env: minor fixes and clean ups
Karel Zak [Tue, 16 Aug 2016 10:35:57 +0000 (12:35 +0200)] 
include/env: minor fixes and clean ups

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoMerge branch 'misc' of https://github.com/kerolasa/lelux-utiliteetit
Karel Zak [Tue, 16 Aug 2016 10:09:00 +0000 (12:09 +0200)] 
Merge branch 'misc' of https://github.com/kerolasa/lelux-utiliteetit

* 'misc' of https://github.com/kerolasa/lelux-utiliteetit:
  pg: stop building the command by default
  kill: remove pid command-name to option alias
  misc: always check setenv(3) return value

8 years agolibblkid: Check that cluster size is nonzero when probing exFAT
Rostislav Skudnov [Thu, 11 Aug 2016 18:24:00 +0000 (18:24 +0000)] 
libblkid: Check that cluster size is nonzero when probing exFAT

This should prevent division by zero in find_label()

Signed-off-by: Rostislav Skudnov <rostislav@tuxera.com>
8 years agolsns: missing ns/<name> is not error
Karel Zak [Mon, 15 Aug 2016 09:02:18 +0000 (11:02 +0200)] 
lsns: missing ns/<name> is not error

For example user namespace is optional it does not make sense to
ignore process completely if the ns/user file is missing.

Reported-by: Michał Bartoszkiewicz <mbartoszkiewicz@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agopg: stop building the command by default
Sami Kerola [Mon, 8 Aug 2016 21:08:16 +0000 (22:08 +0100)] 
pg: stop building the command by default

The pg command is marked deprecated in POSIX since 1997, and this project
has thought the same since Feb 2013.  Time has come to stop shipping this
binary by default.

Reference: 956e582874d3a28434018bf12057c745f74821de
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agokill: remove pid command-name to option alias
Sami Kerola [Mon, 8 Aug 2016 20:50:19 +0000 (21:50 +0100)] 
kill: remove pid command-name to option alias

Removal was promised to happen in March 2016 and the time has come to get
rid of this unexpected feature.

Reference: c5b057b3422504a671ee588fa66574ae876521f1
Reviewed-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agomisc: always check setenv(3) return value
Sami Kerola [Sun, 7 Aug 2016 06:27:21 +0000 (07:27 +0100)] 
misc: always check setenv(3) return value

At least glibc setenv(3) can fail when system runs out of memory.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agotests: mark build-in paths test as optional
Karel Zak [Fri, 12 Aug 2016 08:06:59 +0000 (10:06 +0200)] 
tests: mark build-in paths test as optional

The test makes sense only if you know what are you doing (see
 #ifdef(s) in the include/pathnames.h.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoMerge branch 'pathnames_fbsd' of https://github.com/fichtner/util-linux
Karel Zak [Fri, 12 Aug 2016 08:05:00 +0000 (10:05 +0200)] 
Merge branch 'pathnames_fbsd' of https://github.com/fichtner/util-linux

8 years agoMerge branch 'blkdev_fbsd_11' of https://github.com/fichtner/util-linux
Karel Zak [Fri, 12 Aug 2016 08:04:35 +0000 (10:04 +0200)] 
Merge branch 'blkdev_fbsd_11' of https://github.com/fichtner/util-linux

8 years agotravis: fix OSX, glibtoolize could not find sed
Ruediger Meier [Thu, 11 Aug 2016 15:30:20 +0000 (17:30 +0200)] 
travis: fix OSX, glibtoolize could not find sed

Since a few days travis OSX seems to have a bad libtool package:
$ glibtoolize --version
/usr/local/bin/glibtoolize: line 406: /usr/local/Library/ENV/4.3/sed: No such file or directory

Exporting SED is a simple fix. Otherwise we could have also re-installed libtool:
  brew uninstall libtool
  brew install libtool

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agopathnames: guard clashing definitions on FreeBSD
Franco Fichtner [Thu, 11 Aug 2016 13:03:50 +0000 (15:03 +0200)] 
pathnames: guard clashing definitions on FreeBSD

8 years agoblkdev: guard against missing DIOCGDINFO on FreeBSD 11
Franco Fichtner [Thu, 11 Aug 2016 12:56:08 +0000 (14:56 +0200)] 
blkdev: guard against missing DIOCGDINFO on FreeBSD 11

DIOCGMEDIASIZE is supported and available since FreeBSD 5, it may
make sense to kill the backwards-glue completely instead.

8 years agolibmount: Preserve empty string value in optstr parsing
Filipe Brandenburger [Wed, 10 Aug 2016 20:27:07 +0000 (13:27 -0700)] 
libmount: Preserve empty string value in optstr parsing

Recent mount (since the switch to libmount in v2.22) drops the '=' in
mount options that are set to an empty value.  For example, the command
line below will be affected:

  # mount -o rw,myopt='' -t tmpfs tmpfs /mnt/tmp

Fix that by preserving an empty string in the options passed to the
mount(2) syscall when they are present on the command line.

Add test cases to ensure empty string handling is working as expected
and in order to prevent regressions in the future.

Also tested manually by stracing mount commands (on a kernel which
accepts a special extra option, for testing purposes.)

Before this commit:

  # strace -e mount ./mount -t tmpfs -o rw,myopt='' tmpfs /mnt/tmp
  mount("tmpfs", "/mnt/tmp", "tmpfs", MS_MGC_VAL, "myarg") = -1 EINVAL (Invalid argument)

After this commit:

  # strace -e mount ./mount -t tmpfs -o rw,myopt='' tmpfs /mnt/tmp
  mount("tmpfs", "/mnt/tmp", "tmpfs", MS_MGC_VAL, "myopt=") = 0

All test cases pass, including newly added test cases.  Also checked
them with valgrind using:

  $ tests/run.sh --memcheck libmount/optstr

Fixes #332.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
8 years agotests: Allow running a single test case from tests/run.sh
Filipe Brandenburger [Wed, 10 Aug 2016 20:36:55 +0000 (13:36 -0700)] 
tests: Allow running a single test case from tests/run.sh

Tested by running `tests/run.sh libmount/optstr` successfully.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
8 years agotests: Use proper word splitting when executing tests
Filipe Brandenburger [Wed, 10 Aug 2016 20:17:12 +0000 (13:17 -0700)] 
tests: Use proper word splitting when executing tests

Use the shell special variable "$@" instead of the inferior $* to
execute the test command in ts_valgrind.  The expansion of "$@" respects
proper word splitting and makes it possible to pass the command empty
arguments.  It might also prevent surprises with quoting in corner
cases.

Tested that `make check` passes.

Valgrind run with `make check TS_OPTS='--nonroot --memcheck'` passes.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
8 years agotaskset: clarify that masks are always hex in man page
Chris Metcalf [Tue, 9 Aug 2016 09:31:41 +0000 (11:31 +0200)] 
taskset: clarify that masks are always hex in man page

The man page confusingly says that the mask is "typically"
hexadecimal, when in fact it is always hexadecimal.  Fix the
language, and provide an additional example with no leading "0x".

Also, provide an example using the --cpu-list option.

Signed-off-by: Chris Metcalf <cmetcalf@mellanox.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibmount: ignore redundant slashes
Karel Zak [Mon, 8 Aug 2016 15:23:54 +0000 (17:23 +0200)] 
libmount: ignore redundant slashes

///aaa/bbb and /aaa/bbb/ are the same paths. This is important
especially with NFS where number of slashes are not the same in
the /proc/self/mountinfo and fstab or utab. The regular URI is

 euler://tmp

but /proc contains

 euler:/tmp

Reported-by: Ales Novak <alnovak@suse.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agouuidd: remove unnecessary pidpile path variable
Sami Kerola [Mon, 8 Aug 2016 10:33:16 +0000 (12:33 +0200)] 
uuidd: remove unnecessary pidpile path variable

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agosfdisk: add show-pt-geometry to usage() and sfdisk.8
Karel Zak [Mon, 8 Aug 2016 10:15:47 +0000 (12:15 +0200)] 
sfdisk: add show-pt-geometry to usage() and sfdisk.8

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agodeprecated.txt: Add sfdisk --show-pt-geometry
Stanislav Brabec [Fri, 5 Aug 2016 11:05:39 +0000 (13:05 +0200)] 
deprecated.txt: Add sfdisk --show-pt-geometry

8 years agosfdisk: Add --show-pt-geometry compatibility code
Stanislav Brabec [Thu, 4 Aug 2016 18:15:57 +0000 (20:15 +0200)] 
sfdisk: Add --show-pt-geometry compatibility code

--show-pt-geometry existed since cf3f26bf (2006), and it is used by third party
tools. To prevent failure of these tools, add a minimal compatibility code.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
8 years agotests: fix loop-overlay test
Karel Zak [Thu, 4 Aug 2016 13:09:05 +0000 (15:09 +0200)] 
tests: fix loop-overlay test

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agotests: fix libmount loop-overlay test
Karel Zak [Thu, 4 Aug 2016 10:30:09 +0000 (12:30 +0200)] 
tests: fix libmount loop-overlay test

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoMerge branch 'lo'
Karel Zak [Thu, 4 Aug 2016 09:57:49 +0000 (11:57 +0200)] 
Merge branch 'lo'

* lo:
  mount: small change to mount.8 loopdev section
  libmount: one iteration to detect overlap and reuse loopdev
  lib/loopdev: cleanup sizelimit check
  mount.8: Update loop device documentation
  tests: Add loop-overlay test
  libmout: Reuse loop device safely
  Implement loopcxt_check_conflict()
  Add sizelimit to internal API
  mount: Handle MNT_ERR_LOOPOVERLAP
  libmount: Introduce new error: MNT_ERR_LOOPOVERLAP
  libmount: Fix possible crash in mnt_context_setup_loopdev()

8 years agomount: small change to mount.8 loopdev section
Karel Zak [Thu, 4 Aug 2016 09:56:50 +0000 (11:56 +0200)] 
mount: small change to mount.8 loopdev section

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibmount: one iteration to detect overlap and reuse loopdev
Karel Zak [Thu, 4 Aug 2016 09:48:26 +0000 (11:48 +0200)] 
libmount: one iteration to detect overlap and reuse loopdev

The current code scans loopdevs to detect already used loop device and
another scan to detect overlap.

Let's use one scan only, for this purpose loopcxt_find_overlap() has
been modified to return info (rc==2) about full size and offset match.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolib/loopdev: cleanup sizelimit check
Karel Zak [Thu, 4 Aug 2016 08:49:46 +0000 (10:49 +0200)] 
lib/loopdev: cleanup sizelimit check

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolscpu: print correct number of threads per core if possible
Heiko Carstens [Fri, 29 Jul 2016 12:13:36 +0000 (14:13 +0200)] 
lscpu: print correct number of threads per core if possible

lscpu calculates the number of threads per core by dividing the number
of online cpus with the number of cores. This may or may not give the
correct number of threads per core depending on the number of online
CPUs (and which CPUs are online).

At least on s390 there is a new "max thread id" field within
/proc/cpuinfo present which reliably allows us to tell the number of
threads per core. Let's use this instead, like we already have also
special treatment to figure out the number core per socket etc. on
s390.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
8 years agolspcu: minor manpage improvement
Heiko Carstens [Fri, 29 Jul 2016 12:13:35 +0000 (14:13 +0200)] 
lspcu: minor manpage improvement

Always use the word "can" instead of "may" to be consistent with the
descriptions of the other columns.

Also print "lspcu" always with bold characters like everywhere else in
the man page.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
8 years agolscpu: only try to read sysfs attributes of present CPUs
Heiko Carstens [Fri, 29 Jul 2016 12:13:34 +0000 (14:13 +0200)] 
lscpu: only try to read sysfs attributes of present CPUs

lscpu can skip all CPUs which are possible but not present. For
configurations where a lot of CPUs are possible but only few CPUs are
present this saves a lot of pointless glibc/system calls.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
8 years agolscpu: add parsable testcase with the --physical option
Heiko Carstens [Fri, 29 Jul 2016 12:13:33 +0000 (14:13 +0200)] 
lscpu: add parsable testcase with the --physical option

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
8 years agolscpu: add --physical option
Heiko Carstens [Fri, 29 Jul 2016 12:13:32 +0000 (14:13 +0200)] 
lscpu: add --physical option

With the --physical option lscpu will use the IDs that are reported by
the kernel (e.g. core id for the CORE column) instead of calculating
them on it's own.

This has the advantage that it is possible to tell on which physical
hardware CPUs a Linux instance runs. The logical IDs that lscpu
generates on it own are based on comparing of CPU masks and may or may
not be identical with the physical IDs.

If the kernel was unable to retrieve an ID for a topology element then
the corresponding sysfs file will normally contain "-1". In the
extended and parsable output a dash "-" will be displayed for such
cases.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
8 years agomount.8: Update loop device documentation
Stanislav Brabec [Fri, 15 Jul 2016 13:07:38 +0000 (15:07 +0200)] 
mount.8: Update loop device documentation

New code checks both offset and sizelimit before re-using loop device.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
8 years agotests: Add loop-overlay test
Stanislav Brabec [Thu, 14 Jul 2016 13:30:09 +0000 (15:30 +0200)] 
tests: Add loop-overlay test

The test will check proper loop device reuse and error in case of overlapping
loop device.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
8 years agolibmout: Reuse loop device safely
Stanislav Brabec [Thu, 14 Jul 2016 13:29:44 +0000 (15:29 +0200)] 
libmout: Reuse loop device safely

Add a safety check to mnt_context_setup_loopdev(). Only a loop device with equal
offset and sizelimit will be reused. If any overlapping loop device exists,
MNT_ERR_LOOPOVERLAP is returned.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
8 years agoImplement loopcxt_check_conflict()
Stanislav Brabec [Thu, 14 Jul 2016 13:29:21 +0000 (15:29 +0200)] 
Implement loopcxt_check_conflict()

Add a function that searches for a possible conflicting (i. e. overlaying loop
device).

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
8 years agoAdd sizelimit to internal API
Stanislav Brabec [Thu, 14 Jul 2016 13:29:09 +0000 (15:29 +0200)] 
Add sizelimit to internal API

Fully safe checks of loop device need to check sizelimit. To prevent need of two
nearly equal functions, introduce sizelimit parameter to several internal
functions:
loopdev_is_used()
loopdev_find_by_backing_file()
loopcxt_is_used()
loopcxt_find_by_backing_file()

If sizelimit is zero, fall back to the old behavior (ignoring of sizelimit).

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
8 years agomount: Handle MNT_ERR_LOOPOVERLAP
Stanislav Brabec [Thu, 14 Jul 2016 13:28:58 +0000 (15:28 +0200)] 
mount: Handle MNT_ERR_LOOPOVERLAP

Use warnx(), as there is no strerror() text associated with it.

There is currently no easy way to report name and type of conflict.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
8 years agolibmount: Introduce new error: MNT_ERR_LOOPOVERLAP
Stanislav Brabec [Thu, 14 Jul 2016 13:28:45 +0000 (15:28 +0200)] 
libmount: Introduce new error: MNT_ERR_LOOPOVERLAP

This error code is intended for situations where overlapping loop device exists
and cannot be reused.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
8 years agolibmount: Fix possible crash in mnt_context_setup_loopdev()
Stanislav Brabec [Thu, 14 Jul 2016 13:28:29 +0000 (15:28 +0200)] 
libmount: Fix possible crash in mnt_context_setup_loopdev()

If loopcxt_init() fails, Iloopcxt_deinit() should not be called.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
9 years agotests: remove unnecessary file
Sami Kerola [Fri, 22 Jul 2016 20:24:34 +0000 (21:24 +0100)] 
tests: remove unnecessary file

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agoMerge branch 'getopt' of git://github.com/kerolasa/lelux-utiliteetit
Karel Zak [Tue, 2 Aug 2016 14:08:31 +0000 (16:08 +0200)] 
Merge branch 'getopt' of git://github.com/kerolasa/lelux-utiliteetit

* 'getopt' of git://github.com/kerolasa/lelux-utiliteetit:
  getops: improve getopt-parse.bash example

9 years agoliblkid: fix probe_nilfs2 I/O error backup
Karel Zak [Fri, 15 Jul 2016 08:39:20 +0000 (10:39 +0200)] 
liblkid: fix probe_nilfs2 I/O error backup

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoMerge branch 'oclint' of git://github.com/kerolasa/lelux-utiliteetit
Karel Zak [Tue, 2 Aug 2016 13:26:49 +0000 (15:26 +0200)] 
Merge branch 'oclint' of git://github.com/kerolasa/lelux-utiliteetit

* 'oclint' of git://github.com/kerolasa/lelux-utiliteetit:
  libblkid: fix debugging macro [oclint]
  agetty: move unreachable code to pre-processor #else segment [oclint]
  setterm: fix declarations shadowing variables in the global scope [oclint]
  misc: fix declarations shadowing variables in the global scope [oclint]
  dmesg: drop core at impossible case in read_buffer() [oclint]
  libmount, look: remove dead code [oclint]
  syspriv: flip inverted logic [oclint]
  logger: simplify if clause [oclint]
  libblkid: simplify if clause [oclint]
  lslogins: simplify if clause and move definition and comments [oclint]
  switch_root: simplify code and reduce indentation [oclint]
  misc: simplify if clauses [oclint]

9 years agolibsmartcols: Corrected JSON escaping
Karel Zak [Tue, 2 Aug 2016 09:58:50 +0000 (11:58 +0200)] 
libsmartcols: Corrected JSON escaping

Based on patch set https://github.com/karelzak/util-linux/pull/331
from Fordi.

Addresses: https://github.com/karelzak/util-linux/issues/330
Co-Author: Bryan Elliott <fordiman@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agogetops: improve getopt-parse.bash example
Sami Kerola [Wed, 27 Jul 2016 10:17:47 +0000 (11:17 +0100)] 
getops: improve getopt-parse.bash example

Use correct names of example scripts in the script.  Remove use of
backticks, they require quoting that makes the example harder to follow.
Split one-liners to one-command-at-a-time expressions.  Add continue keyword
to avoid additional case statement matching.  Be strict with quoting.

Reported-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agolibblkid: fix debugging macro [oclint]
Sami Kerola [Sun, 3 Jul 2016 19:57:23 +0000 (20:57 +0100)] 
libblkid: fix debugging macro [oclint]

The oclint was complaining 'empty do/while statement' that turned out to be
true and I started to think it is best to use the same DBG() macro as in
other source files for this library.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agoagetty: move unreachable code to pre-processor #else segment [oclint]
Sami Kerola [Sun, 3 Jul 2016 19:10:11 +0000 (20:10 +0100)] 
agetty: move unreachable code to pre-processor #else segment [oclint]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agosetterm: fix declarations shadowing variables in the global scope [oclint]
Sami Kerola [Sun, 3 Jul 2016 12:13:21 +0000 (13:13 +0100)] 
setterm: fix declarations shadowing variables in the global scope [oclint]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agomisc: fix declarations shadowing variables in the global scope [oclint]
Sami Kerola [Sun, 3 Jul 2016 12:20:30 +0000 (13:20 +0100)] 
misc: fix declarations shadowing variables in the global scope [oclint]

Fixes multiple occurences of 'optarg' overwrites.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agodmesg: drop core at impossible case in read_buffer() [oclint]
Sami Kerola [Sun, 3 Jul 2016 11:18:03 +0000 (12:18 +0100)] 
dmesg: drop core at impossible case in read_buffer() [oclint]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agolibmount, look: remove dead code [oclint]
Sami Kerola [Sun, 3 Jul 2016 19:13:42 +0000 (20:13 +0100)] 
libmount, look: remove dead code [oclint]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agosyspriv: flip inverted logic [oclint]
Sami Kerola [Sun, 3 Jul 2016 11:42:58 +0000 (12:42 +0100)] 
syspriv: flip inverted logic [oclint]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agologger: simplify if clause [oclint]
Sami Kerola [Mon, 4 Jul 2016 21:14:41 +0000 (22:14 +0100)] 
logger: simplify if clause [oclint]

This has effect of collapsing rather long indentation block, so commit
separately.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agolibblkid: simplify if clause [oclint]
Sami Kerola [Mon, 4 Jul 2016 21:12:55 +0000 (22:12 +0100)] 
libblkid: simplify if clause [oclint]

Move negative and positive testing of 'has' variable to top level, and test
flag bit mask on second level.  This way the 'has' needs to be checked only
once.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agolslogins: simplify if clause and move definition and comments [oclint]
Sami Kerola [Mon, 4 Jul 2016 21:16:54 +0000 (22:16 +0100)] 
lslogins: simplify if clause and move definition and comments [oclint]

The if clause change is pretty trivial.  Moving the macro near to where it
is used makes sense to people who want to read the code.  And finally the
comment about user list was at wrong spot.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agoswitch_root: simplify code and reduce indentation [oclint]
Sami Kerola [Sun, 3 Jul 2016 11:30:46 +0000 (12:30 +0100)] 
switch_root: simplify code and reduce indentation [oclint]

The if statement in line 162 already ensures value of cfd to be 0 or
greater, so the later if is not needed.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agomisc: simplify if clauses [oclint]
Sami Kerola [Mon, 4 Jul 2016 21:09:10 +0000 (22:09 +0100)] 
misc: simplify if clauses [oclint]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agoagetty: call uname() only when necessary
Karel Zak [Wed, 20 Jul 2016 11:20:14 +0000 (13:20 +0200)] 
agetty: call uname() only when necessary

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoagetty: fix \S usage
Karel Zak [Wed, 20 Jul 2016 11:16:13 +0000 (13:16 +0200)] 
agetty: fix \S usage

If \S without argument used then uninitialized 'varname' compared with
ANSI_COLOR.

Addresses: https://github.com/karelzak/util-linux/issues/329
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoRevert "sfdisk: exit with error if rereading partition table fails"
Karel Zak [Wed, 20 Jul 2016 09:24:36 +0000 (11:24 +0200)] 
Revert "sfdisk: exit with error if rereading partition table fails"

This reverts commit 14f644f386a1708483ed446e983c0976e3976a9d.

It seems we have mess in reread-after-write:

all old versions to v2.20  -- returns 0
from v2.20 to v2.26        -- returns 1
since v2.26                -- returns 0

I think re-read errors should not be interpreted as fatal errors,
because it's pretty common that you want to modify only one partition
(e.g. resize) and then another partitions are probably still in use
and re-read all PT does not make sense.

What we need is to improve granularity for re-read and calls it only
when really necessary (all PT modified) and otherwise call BLKPG
(add/delete/resize) ioctls.

Reported-by: Nikhil Valluru <vvnikhil@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agologger: remove trailing spaces when outputing to journal
Sami Kerola [Mon, 18 Jul 2016 20:49:27 +0000 (21:49 +0100)] 
logger: remove trailing spaces when outputing to journal

Issues:
1. Whitespace-ish \r is not stripped, while it should be.
2. In journal \r is considered unprintable.

Lennart: "it is the duty of the client side to drop the trailing whitespace,
which "logger" doesn't do".

Reported-by: Ivan Babrou <ibobrik@gmail.com>
Explained-by: Lennart Poettering <lennart@poettering.net>
Reference: https://github.com/systemd/systemd/issues/3416
Signed-off-by: Sami Kerola <kerolasa@iki.fi>