]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
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>
9 years agotailf: Fix previously adjusted segfault patch
Tobias Stoeckmann [Sat, 16 Jul 2016 10:51:42 +0000 (12:51 +0200)] 
tailf: Fix previously adjusted segfault patch

Casting the value to be checked to size_t renders the check useless.
If st_size is SIZE_MAX+1, it will be truncated to 0 and the check
succeeds. In fact, this check can never be false because every value
stored in a size_t is smaller or equal to SIZE_MAX.

I think this adjustment was meant to fix a compiler warning for 64 bit
systems for which sizeof(off_t) is sizeof(size_t), but the signedness
differs.

Going unconditionally to the greatest possible unsigned int type if
st_size is positive (off_t is signed) will fix this issue.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
9 years agotests: fix ttyutils test
Karel Zak [Fri, 15 Jul 2016 08:11:35 +0000 (10:11 +0200)] 
tests: fix ttyutils test

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agowrite: don't use strftime()
Karel Zak [Thu, 14 Jul 2016 11:20:58 +0000 (13:20 +0200)] 
write: don't use strftime()

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoMerge branch 'write-improvements' of git://github.com/kerolasa/lelux-utiliteetit
Karel Zak [Thu, 14 Jul 2016 11:07:25 +0000 (13:07 +0200)] 
Merge branch 'write-improvements' of git://github.com/kerolasa/lelux-utiliteetit

* 'write-improvements' of git://github.com/kerolasa/lelux-utiliteetit:
  lib: try to find tty in get_terminal_name()
  write: stop removing and adding /dev/ in front of tty string
  write: tell when effective gid and tty path group mismatch
  write: improve coding style
  write: remove PUTC macro
  write: make timestamp to be obviously just a clock time
  write: remove unnecessary utmp variables
  write: improve function and variable names
  write: add control structure to clarify what is going on
  write: run atexit() checks at the end of execution
  write: use xstrncpy() from strutils.h
  write: set atime value in term_chk() only when needed
  write: remove pointless fileno(3) calls
  write: get rid of function prototypes
  write: remove unused variable

9 years agosulogin: remove __nonnull__ function attribute
Sami Kerola [Sat, 2 Jul 2016 09:28:55 +0000 (10:28 +0100)] 
sulogin: remove __nonnull__ function attribute

This change fixes compiler option -Werror=nonnull option warning:

login-utils/sulogin-consoles.c: In function 'append_console':
login-utils/sulogin-consoles.c:324:14: warning: nonnull argument 'consoles'
compared to NULL [-Wnonnull-compare]

The NULL check done with list_empty() looks valid, so  it is best to remove
the function attribute that allows compiler to optimize the check away.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agotests: Fix fdisk/id and fdisk/mbr-nondos-mode on Sparc
James Clarke [Thu, 14 Jul 2016 08:02:24 +0000 (09:02 +0100)] 
tests: Fix fdisk/id and fdisk/mbr-nondos-mode on Sparc

On Sparc, fdisk defaults to using SUN disk labels, which causes the
output from these tests to differ from non-Sparc.

Signed-off-by: James Clarke <jrtc27@jrtc27.com>
9 years agoblkdiscard: Improve man page
Allon Mureinik [Thu, 14 Jul 2016 10:19:25 +0000 (12:19 +0200)] 
blkdiscard: Improve man page

Improve the grammar and phrasing of the --verbose option and how it
interacts with the --step option.

Signed-off-by: Allon Mureinik <amureini@redhat.com>
9 years agotailf: Fix segmentation fault in tailf on 32 bit
Tobias Stoeckmann [Sun, 10 Jul 2016 14:14:08 +0000 (16:14 +0200)] 
tailf: Fix segmentation fault in tailf on 32 bit

tailf crashes with a segmentation fault when used with a file that is
exactly 4GB in size due to an integer overflow between off_t and size_t:

$ dd if=/dev/zero of=tailf.crash bs=1 count=1 seek=4294967295
$ tailf tailf.crash
Segmentation fault
$ _

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agofdisk: make -l <dev ...> behaves like fdisk -l
Thierry Vignaud [Tue, 5 Jul 2016 16:39:05 +0000 (18:39 +0200)] 
fdisk: make -l <dev ...> behaves like fdisk -l

aka having the same spacing between disks

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibblkid: avoid non-empty recursion in EBR
Karel Zak [Tue, 12 Jul 2016 11:34:54 +0000 (13:34 +0200)] 
libblkid: avoid non-empty recursion in EBR

This is extension to the patch 7164a1c34d18831ac61c6744ad14ce916d389b3f.

We also need to detect non-empty recursion in the EBR chain. It's
possible to create standard valid logical partitions and in the last one
points back to the EBR chain. In this case all offsets will be non-empty.

Unfortunately, it's valid to create logical partitions that are not in
the "disk order" (sorted by start offset). So link somewhere back is
valid, but this link cannot points to already existing partition
(otherwise we will see recursion).

This patch forces libblkid to ignore duplicate logical partitions, the
duplicate chain segment is interpreted as non-data segment, after 100
iterations with non-data segments it will break the loop -- no memory
is allocated in this case by the loop.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1349536
References: http://seclists.org/oss-sec/2016/q3/40
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agochrt: add fallback to be usable on kernels without sched_{get,set}attr
Karel Zak [Mon, 11 Jul 2016 13:33:46 +0000 (15:33 +0200)] 
chrt: add fallback to be usable on kernels without sched_{get,set}attr

We have fallback for compilation with/without proper glibc and kernel
headers, but it's not enough, because people can switch between
kernels with and without the syscalls. (For example RT kernels for
RHEL/CentOS).

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1353340
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agotests: mark chrt as TS_KNOWN_FAIL
Karel Zak [Mon, 11 Jul 2016 10:36:51 +0000 (12:36 +0200)] 
tests: mark chrt as TS_KNOWN_FAIL

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agotests: make chrt test more debug-able
Karel Zak [Mon, 11 Jul 2016 09:54:31 +0000 (11:54 +0200)] 
tests: make chrt test more debug-able

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agotests: mark chrt tests as root-only
Karel Zak [Mon, 11 Jul 2016 09:12:47 +0000 (11:12 +0200)] 
tests: mark chrt tests as root-only

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agotests: implement ts_skip_subtest
Karel Zak [Mon, 11 Jul 2016 09:01:14 +0000 (11:01 +0200)] 
tests: implement ts_skip_subtest

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agotests: add chrt test
Karel Zak [Mon, 11 Jul 2016 08:25:13 +0000 (10:25 +0200)] 
tests: add chrt test

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agocfisk: add /dev/vda as another default disk
Karel Zak [Thu, 7 Jul 2016 13:02:20 +0000 (15:02 +0200)] 
cfisk: add /dev/vda as another default disk

And use array for all default alternative disks.

Reported-by: Thierry Vignaud <thierry.vignaud@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibblkid: ignore extended partition at zero offset
Karel Zak [Thu, 7 Jul 2016 12:22:41 +0000 (14:22 +0200)] 
libblkid: ignore extended partition at zero offset

If the extended partition starts at zero LBA then MBR is interpreted
as EBR and all is recursively parsed... result is out-of-memory.

 MBR --extended-partition--> EBR --> MBR --> ENB --> MBR ...

Note that such PT is not possible to create by standard partitioning
tools.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1349536
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolib: try to find tty in get_terminal_name()
Sami Kerola [Sat, 14 May 2016 18:50:41 +0000 (19:50 +0100)] 
lib: try to find tty in get_terminal_name()

Try all standard terminal input/output file descriptors when finding tty
name in get_germinal_name().  This should make all invocations of the
function as robust as they can get.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agowrite: stop removing and adding /dev/ in front of tty string
Sami Kerola [Sat, 14 May 2016 18:39:37 +0000 (19:39 +0100)] 
write: stop removing and adding /dev/ in front of tty string

Add both path and tty name representations of tty's to control structure,
that point to same string beginning from different depths.  This way there
is no need to removing and adding /dev/ in front of tty string all the time.

Secondly this change makes it possible to use of get_terminal_name() from
ttyutils.c.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agowrite: tell when effective gid and tty path group mismatch
Sami Kerola [Sat, 7 May 2016 22:44:17 +0000 (23:44 +0100)] 
write: tell when effective gid and tty path group mismatch

Most commonly this error happens when write(1) executable does not have
correct group ownership and setgid bit.  The earlier message was unclear
what exactly was wrong.

$ mesg
is y
$ write testuser
write: you have write permission turned off

Alternatively the 'getegid() == s.st_gid' could be considered unnecessary.
Afterall if to write to destination tty is denied that does not go unnoticed
at thet time when tty is opened.

Reviewed-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agowrite: improve coding style
Sami Kerola [Sun, 8 May 2016 20:00:21 +0000 (21:00 +0100)] 
write: improve coding style

Signed-off-by: Sami Kerola <kerolasa@iki.fi>