Karel Zak [Tue, 2 May 2017 09:28:42 +0000 (11:28 +0200)]
Merge branch 'master' of https://github.com/pali/util-linux
* 'master' of https://github.com/pali/util-linux:
tests: Add UDF hdd images created by Linux mkudffs 1.3
tests: Rename udf-hdd-mkudffs* images to indicate used mkudffs version
libblkid: udf: For better readibility use one snprintf call instead multiple in loop
Karel Zak [Tue, 2 May 2017 09:12:33 +0000 (11:12 +0200)]
Merge branch '170419' of github.com:jwpi/util-linux
* '170419' of github.com:jwpi/util-linux:
hwclock: use a consistent name for --predict
hwclock: remove unneeded braces
hwclock: make clock test mode message consistent
hwclock: extra messages for debug only
Karel Zak [Thu, 27 Apr 2017 12:01:26 +0000 (14:01 +0200)]
libmount: add mnt_context_get_excode()
It's pretty complex task to make mount(8) and umount(8) return code
and generate error message. It seems better to do that in the libmount
rather than force all library users to duplicate mount(8) mk_exit_code()
functions. It also means that all the messages will be translated only
once. Changes:
* all error messages are printed by warn()
* no more multi-line messages
* all messages prefixed by mount target (mountpoint)
* library provides mount(8) compatible MNT_EX_* codes
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1429531 Signed-off-by: Karel Zak <kzak@redhat.com>
The predict function name is documented as '--predict', but the
code uses '--predict-hc'. This works okay, except that the
'mutually exclusive' error message prints the undocumented name.
* sys-utils/hwclock.c: rename 'predict-hc' to 'predict' so that
it matches the man-page. This should not be a problem because
'predict-hc' was never documented.
Signed-off-by: J William Piggott <elseifthen@gmx.com>
Karel Zak [Wed, 26 Apr 2017 15:27:02 +0000 (17:27 +0200)]
libmount: support MS_RDONLY on write-protected devices
This feature is supported by mount(8) only. It seems better move
this code to libmount. The results is more simple mount(8) and the
feature is accessible for all libmount users.
flock(1) uses the timer facility to interrupt a blocking flock(2)
call. However, in a pathological case (or with a sufficiently short
timeout), the timer may fire and the signal be delivered after the
timer is set up, but before we get around to doing the flock(2)
call. In that case, we'd block forever. Checking timeout_expired right
before calling flock(2) does not eliminate that race, so the only
option is to make the timer fire repeatedly. Having the timer fire
after we've returned from flock(2) is not a problem, since we only
check timeout_expired in case of EINTR (also, this firing after return
could also happen with the current code).
There is currently one other user of setup_timer (misc-utils/uuidd.c),
but in that case the signal handler simply exits. Future users of
setup_timer obviously need to ensure that they can tolerate multiple
signal deliveries.
Choosing 1% of the initial timeout as the repeating interval is
somewhat arbitrary. However, I put a lower bound of 0.01s, since
setting the interval much smaller than this may end up effectively
live-locking the process, handling a never-ending stream of signals.
lib/timer.c: remove bogus SA_SIGINFO from timer_settime call
The only valid flag for timer_settime is TIMER_ABSTIME, which we
certainly don't want here. This seems to be harmless since
timer_settime doesn't validate the flags parameter, TIMER_ABSTIME is
universally 0x1, and no architecture has SA_SIGINFO == 1.
switch_root: unlink files without _DIRENT_HAVE_D_TYPE
When _DIRENT_HAVE_D_TYPE is not defined, we need to always fstat the
directory entry in order to determine whether it is a directory or not.
If we determine that the file is indeed a directory on the same device,
we proceed to recursively remove its contents as well. Otherwise, we
simply skip removing the entry altogether.
This logic is not entirely correct though. Note that we actually skip
deletion of the entry if it is either not a directory or if it is not on
the same device. The second condition is obviously correct here, as we
do not want to delete files on other mounts here. But skipping deletion
of the entry itself if it is not a directory is wrong.
When _DIRENT_HAVE_D_TYPE is defined, this condition should never be
triggered, as we have already determined that the entry is a directory.
But if it is not, we will always do the fstat and check. Because of
this, we will now skip deletion of all files which are not directories,
which is wrong.
Fix the issue by disentangling both conditions. We now first check
whether we are still on the same device - if not, we skip recursive
deletion as well as deletion of the directory entry. Afterwards, we
check whether it is a directory - if so, we do delete its contents
recursively. And finally, we will now unlink the entry disregarding
whether it is a directory or not.
Karel Zak [Wed, 26 Apr 2017 09:17:46 +0000 (11:17 +0200)]
Merge branch '170415' of github.com:jwpi/util-linux
* '170415' of github.com:jwpi/util-linux:
optutils.h: don't print non-graph characters
hwclock: improve audit control
hwclock: --set and --predict segmentation fault
hwclock: make epoch functions alpha only
hwclock: improve default function handling
Karel Zak [Tue, 25 Apr 2017 15:05:09 +0000 (17:05 +0200)]
libfdisk: fix NLS support
The current libfdisk code uses gettext() to translate strings. It
means it follows the default text domain (as set by textdomain(3)
usually in the main program). This is useless for public shared
library.
We have call private bindtextdomain() and use dgettext() with private
domain name to be independent on the main program. For this purpose
include/nls.h supports UL_TEXTDOMAIN_EXPLICIT to use dgettext().
Note that libfdisk will continue to use util-linux.po, rather than
keep the texts in the separate file.
The nls.h has to be included only from fdiskP.h to be sure that
nls.h works as expected for the library.
Karel Zak [Wed, 19 Apr 2017 12:28:16 +0000 (14:28 +0200)]
lsblk: don't duplicate columns
$ lsblk --discard --perms
NAME DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO NAME SIZE OWNER GROUP MODE
sdb 0 0B 0B 0 sdb 74.5G root disk brw-rw----
└─sdb1 0 0B 0B 0 └─sdb1 74.5G root disk brw-rw----
sda 0 512B 2G 0 sda 223.6G root disk brw-rw----
├─sda4 0 512B 2G 0 ├─sda4 50G root disk brw-rw----
├─sda2 0 512B 2G 0 ├─sda2 200M root disk brw-rw----
├─sda5 0 512B 2G 0 ├─sda5 35.1G root disk brw-rw----
├─sda3 0 512B 2G 0 ├─sda3 130.3G root disk brw-rw----
├─sda1 0 512B 2G 0 ├─sda1 200M root disk brw-rw----
└─sda6 0 512B 2G 0 └─sda6 7.8G root disk brw-rw----
... see NAME column.
It's fine to support duplicated columns when requested by user (e.g.
-o NAME,NAME,SIZE), but it does not make sense for the default output
when multiple command options specified.
There is no eloquent way to exclude/include arch dependent arguments
from the ul_excl_t array. So when an arch dependent argument is left
undefined err_exclusive_options() was printing out-of-bounds values.
This commit cause them to be skipped instead.
err_exclusive_options() shouldn't be printing out-of-bounds values
in any case.
Also change the error massage from 'options' to 'arguments' as some
programs, like hwclock, distinguish between options and functions.
Signed-off-by: J William Piggott <elseifthen@gmx.com>
Move audit control to option parsing. This fixes non-alpha build
error and cleans up an unruly 'if' statement.
Having audit control in option parsing may also draw awareness to
the audit system when adding new functions, which could easily be
overlooked otherwise.
Signed-off-by: J William Piggott <elseifthen@gmx.com>
It's been 19.1315 years since the comment below was written and the kernel
has actually gone further away from allowing an RTC epoch on ISA machines.
/*
* Maintenance note: This should work on non-Alpha machines, but the
* evidence today (98.03.04) indicates that the kernel only keeps the epoch
* value on Alphas. If that is ever fixed, this function should be changed.
*/
The current behavior is to accept the epoch options on ISA machines
only to print a lengthy message explaining that you cannot use them.
This patch removes that behavior, making the epoch functions truly Alpha
only, as the man-page states that they are.
* sys-utils/hwclock.c: make epoch function alpha only.
* sys-utils/hwclock.h: same.
Signed-off-by: J William Piggott <elseifthen@gmx.com>
Damien Le Moal [Wed, 12 Apr 2017 09:20:32 +0000 (18:20 +0900)]
blkzone: Fix zone condition strings handling
Fixed the condition strings for implicit open and explicit open to
match the man page defined strings ("oi" and "oe"). Also while at it,
correct the condition_str array entries adding the reserved "xC" case
so that the read_only, full and offline conditions match the condition
codes. This increases the array size to 16, so also fix the condition
code masking when displaying the result.
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
On ARM systems, accessing SMBIOS tables via /dev/mem using read()
calls is not supported. The reason is that such tables are usually
located in EFI_RUNTIME_SERVICE_DATA memory, which is not covered
by the linear mapping on those systems, and so read() calls will
fail.
So instead, use the /sys/firmware/dmi/tables/DMI sysfs file, which
contains the entire structure table array, and will be available
on any recent Linux system, even on ones that only export the rev3
SMBIOS entry point, which is currently ignored by lscpu.
Note that the max 'num' value is inferred from the size. This is not
a limitation of the sysfs interface, but a limitation of the rev3
entry point, which no longer carries a number of array elements.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Tested-by: Alexander Graf <agraf@suse.de> Reviewed-by: Alexander Graf <agraf@suse.de>
Update output columns (earlier field names were almost completely
incorrect). Remove --colon-separate and --print0 [1] options. Add
--time-format, --bytes, --numeric-perms [2], and --list [3] options.
Use /proc and kernel module listing for --type argument list. Some
of the items in the lists do not make much sense, but this is still
better than a static list provided by package maintainer.
mountpoint:
Remove fixme item that was left in place when this completion was
originally wrote.