Commit Graph

11376 Commits

Author SHA1 Message Date
Karel Zak
4762ae9d60 column: use libsmartcols for --table
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak
8f1be58816 column: clean up multi-byte #ifelse
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak
37d84d6d26 column: reorder functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak
d6b63b9f1d column: rename functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak
2acfa40ac1 tests: add column(1) table test
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:18:00 +02:00
Karel Zak
cee91191ea tests: add column(1) columnate test
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:17:59 +02:00
Karel Zak
3cc2ade826 column: don't ignore mbs_to_wcs() errors
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:17:59 +02:00
Karel Zak
4219aa3756 tests: add column/files directory
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:17:59 +02:00
Karel Zak
0784187d14 column: make input() more generic
* remove line size limit
* use multi-byte rather than wchar when read input
* prepare for future libsmartcols use in input() for table

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:17:59 +02:00
Karel Zak
2593c13998 column: use colntrol struct on more places
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:17:59 +02:00
Karel Zak
7d07df62a2 columns: add control struct
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:17:59 +02:00
Karel Zak
38d691921c column: split old and new code
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-02 12:17:59 +02:00
Karel Zak
d4ab297043 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
2017-05-02 11:28:42 +02:00
Karel Zak
13944f3d05 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
2017-05-02 11:12:33 +02:00
Pali Rohár
20f47eaab5 tests: Add UDF hdd images created by Linux mkudffs 1.3
$ dd if=/dev/zero of=udf-hdd-mkudffs-1.3-1.img bs=1M count=10
$ mkudffs -l Label -b 512 udf-hdd-mkudffs-1.3-1.img

$ dd if=/dev/zero of=udf-hdd-mkudffs-1.3-2.img bs=1M count=10
$ mkudffs -l Label udf-hdd-mkudffs-1.3-2.img
2017-05-01 10:03:08 +02:00
Pali Rohár
ee069f5f33 tests: Rename udf-hdd-mkudffs* images to indicate used mkudffs version 2017-05-01 09:32:01 +02:00
Pali Rohár
49d84dbedc libblkid: udf: For better readibility use one snprintf call instead multiple in loop 2017-05-01 09:28:22 +02:00
Karel Zak
dc9a23fe66 lib/timer: add comment
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-28 13:25:41 +02:00
Karel Zak
ed1c112666 Merge branch 'timer' of https://github.com/Villemoes/util-linux 2017-04-28 13:02:02 +02:00
Karel Zak
8503c0ed30 libmount: (docs) remove unwanted tag
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-28 12:39:21 +02:00
Karel Zak
a8771daefe tests: update libmount outputs
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-28 11:19:59 +02:00
Karel Zak
0361cb6f9b libmount: add read-only warning
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-28 11:03:24 +02:00
Karel Zak
79055689a2 include/exitcodes: remove mount(8) exit codes
All defined by libmount now.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-27 14:26:45 +02:00
Karel Zak
8e9039afe4 fstrim: use MNT_EX_* from libmount
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-27 14:26:16 +02:00
Karel Zak
e3a7a5f8f0 mount: use MNT_EX_* from libmount
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-27 14:26:02 +02:00
Karel Zak
e058a6c1a0 umount: use MNT_EX_* from libmount
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-27 14:25:57 +02:00
Karel Zak
7b53418bf0 libmount: (docs) add unused declarations
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-27 14:17:50 +02:00
Karel Zak
e1706a6783 mount, umount: use mnt_context_get_excode()
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-27 14:11:50 +02:00
Karel Zak
ea848180dd 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>
2017-04-27 14:10:23 +02:00
J William Piggott
57415653a6 hwclock: use a consistent name for --predict
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>
2017-04-26 23:19:56 -04:00
J William Piggott
019093776a hwclock: remove unneeded braces
Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-04-26 23:19:56 -04:00
J William Piggott
142efd2406 hwclock: make clock test mode message consistent
Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-04-26 23:19:56 -04:00
J William Piggott
66c83c1c7f hwclock: extra messages for debug only
Only print extra save_adjtime() messages in debug mode. This makes
the --test mode output consistent accross functions.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-04-26 23:19:56 -04:00
Karel Zak
6dede2f2f7 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.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-26 17:27:02 +02:00
Rasmus Villemoes
e2cd1072b4 lib/timer.c: prevent pathological race condition
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.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
2017-04-26 13:35:26 +02:00
Rasmus Villemoes
c6a9147fd8 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.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
2017-04-26 13:35:18 +02:00
Karel Zak
863cf02a14 umount: fix typo
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-26 12:34:48 +02:00
Patrick Steinhardt
85bfb519af 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.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
2017-04-26 11:23:50 +02:00
Karel Zak
97fc6ccf79 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
2017-04-26 11:17:46 +02:00
Karel Zak
7095232d21 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.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-25 17:05:09 +02:00
Karel Zak
be685b98c0 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.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-19 14:28:16 +02:00
Damien Le Moal
f2df436564 lsblk: add ZONED column
Add the column "ZONED" to the output to display block devices zone
model information.

Example output:

> lsblk -o+ZONED
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT ZONED
sda      8:0    0 111.8G  0 disk            none
├─sda1   8:1    0   500M  0 part /boot      none
├─sda2   8:2    0  87.3G  0 part /          none
└─sda3   8:3    0    24G  0 part [SWAP]     none
sdb      8:16   0  12.8T  0 disk            host-managed
sdc      8:32   0   5.5T  0 disk            host-managed

or:

> lsblk --zoned
NAME   ZONED
sda    none
├─sda1 none
├─sda2 none
└─sda3 none
sdb    host-managed
sdc    host-managed

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
2017-04-19 14:07:03 +02:00
Karel Zak
02a376f2ee libfdisk: (gpt) rename to gpt_entry_is_used()
The current function name is inconsistent with the rest of the code.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-19 14:00:07 +02:00
Pavel Butsykin
e6b4209d95 libfdisk: allow to change an existing extended partition
Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
2017-04-19 10:25:39 +02:00
J William Piggott
9bf13750cb optutils.h: don't print non-graph characters
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>
2017-04-18 22:39:05 -04:00
J William Piggott
d8949acaa7 hwclock: improve audit control
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>
2017-04-18 22:39:05 -04:00
J William Piggott
969bffb748 hwclock: --set and --predict segmentation fault
Segmentation fault for --set or --predict when the
--date option is not included.

* sys-utils/hwclock.c: exit with an error message when
    the required --date option is missing.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-04-18 22:39:05 -04:00
J William Piggott
039a0ceccf hwclock: make epoch functions alpha only
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>
2017-04-18 22:39:05 -04:00
J William Piggott
8b73ff9633 hwclock: improve default function handling
Removes long default function test. Instead handle the
default when the options are parsed.

Also fixes the non-linux build failure reported by Rudi:
http://marc.info/?l=util-linux-ng&m=149189833115871

Reported-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-04-18 22:39:05 -04:00
Karel Zak
d9f90f697c tests: update script(1) tests
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-18 12:42:58 +02:00