Commit Graph

11342 Commits

Author SHA1 Message Date
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
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
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
Karel Zak 6f3c9c3430 script: always write stat and done message to typescript file
And remove usec from timestamp.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-18 12:12:44 +02:00
Karel Zak 4213390597 Merge branch 'script_newline' of https://github.com/renyuneyun/util-linux
* 'script_newline' of https://github.com/renyuneyun/util-linux:
  fix the position of newline in the time output of 'script'
2017-04-18 12:02:01 +02:00
Karel Zak 6ca1b9d3d0 Merge branch 'bash-completion' of git://github.com/kerolasa/lelux-utiliteetit
* 'bash-completion' of git://github.com/kerolasa/lelux-utiliteetit:
  bash-completion: update text-utils
  bash-completion: update term-utils
  bash-completion: update sys-utils
  bash-completion: update schedutils
  bash-completion: update misc-utils
  bash-completion: update login-utils
  bash-completion: update disk-utils
2017-04-18 11:35:27 +02:00
Damien Le Moal b1484d8d37 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>
2017-04-18 11:25:31 +02:00
Karel Zak 73be2127cb lscpu: use macro for path to DMI
Just to be consistent with lscpu.c.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-18 11:18:36 +02:00
Ard Biesheuvel 92a6392c41 lscpu: use sysfs for table access if available
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>
2017-04-18 11:14:49 +02:00
Stanislav Brabec ecfeae90a2 libmount: Ensure utab.lock mode 644
If utab.lock is created by a process with a restricted umask, utab.lock is
created with restricted permissions. It breaks userspace monitor.

Ensure that the mode is always 644.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2017-04-18 11:13:32 +02:00
Sami Kerola 1ab3f16b43 bash-completion: update fincore
Add RES column to --output completions.

Commit: e4e8b57be2
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-04-18 11:13:27 +02:00
Sami Kerola fb6f70184d bash-completion: update hwclock
Add --udate-drift [1], remove --badyear [2], and use the same argument
for --date as in manual page[3].

Commit [1]: f276d71a3e
Commit [2]: f6374e1fb3
Commit [3]: cc5ec6936e
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-04-18 11:13:24 +02:00
Karel Zak 2eb243c2b5 Merge branch '170409' of github.com:jwpi/util-linux
* '170409' of github.com:jwpi/util-linux:
  hwclock: remove residual 'compare' from man-page
  hwclock: fix whitespace in hwclock-rtc.c
  docs: parse-date.txt fix whitespace
  parse-date: remove extraneous form feed
  hwclock: use errtryhelp()
2017-04-18 11:07:09 +02:00
Sami Kerola 768f315230
bash-completion: update text-utils
hexdump:

	Add --color option.

	Commit: 098ab0778f

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-04-17 18:40:34 +01:00
Sami Kerola e4fc3d574c
bash-completion: update term-utils
scriptreplay:

	Add --maxdelay option.

	Commit: 7f1d483638

setterm:

	Add --resize coption.

	Commit: 5d79599951

write:

	List only users who are online and determine tty based on given user
	name.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-04-17 18:34:14 +01:00
Sami Kerola d092911bcd
bash-completion: update sys-utils
blkdiscard:

	Add --step [1] and --zeroout [2] options.

	Commit [1]: c472a7e35a
	Commit [2]: 7154cc8926

chmem:

	Commit: 30e1ea8ba1

dmesg:

	Add --time-format.

	Commit: babf605d2c

fallocate:

	Add --insert-range [1], --collapse-range [2], --zero-range [3], and
	--posix [4] options.  Also make the options to be in same order as
	usage() output.

	Commit [1]: b439065634
	Commit [2]: 83cc932d74
	Commit [3]: 1fd4f609ee
	Commit [4]: 833f9a7aae
	Command [5]: fallocate --help | awk '/--/ {print "\t\t\t\t" $2}'

flock:

	Add --no-fork option.

	Commit: 703251401c

hwclock:

	Add --udate-drift [1], remove --badyear [2], and use the same
	argument for --date as in manual page[3].

	Commit [1]: f276d71a3e
	Commit [2]: f6374e1fb3
	Commit [3]: cc5ec6936e

ldattach:

	Add --intro-command and --pause.

	Commit: 8596f63914

losetup:

	Add --nooverlap [1], --json [2], --noheadings and --raw [3] options,
	and direct io aka DIO output field [4].

	Commit [1]: 9a94b634a3
	Commit [2]: 4827093d4b
	Commit [3]: 9f56106df6
	Commit [4]: faeef4d2e9

lscpu:

	Add --json [1] and --physical [2] options.  Add DRAWER [3] to output
	fields.

	Commit [1]: 19a5510b96
	Commit [2]: 0d2b5d2a72
	Commit [3]: b3adf6ef66

lsipc:

	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.

	Commit [1]: 2a7150ac2e
	Commit [2]: 9d20ffda79
	Commit [3]: 2916afa3f5

lsmem:

	Commit: cad2d1ac92

lsns:

	Add cgroup --type argument.

	Commit: 2b8889c44b

mount:

	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.

nsenter:

	Add --cgroup [1], --setuid, --setgid [2], --preserve-credentials
	[3] and, --all [4] option.

	Commit [1]: f9e7b66dbd
	Commit [2]: 6b9e5bf670
	Commit [3]: e99a6626d6
	Commit [4]: 974cc006f1

rtcwake:

	Add --auto [1], --adjfile [2], and --list-modes [3] options.

	Commit [1]: 49ebda9b89
	Commit [2]: 3a2f3e82bb
	Commit [3]: 43a44bfc6d

setarch:

	Add --list [1] option.

	Commit [1]: 5edb0ea6bb

setsid:

	Add --wait option.

	Commit: 0dde19974b

umount:

	Use /proc and kernel module listing for --type argument list.

unshare:

	Add --cgroup [1], --fork [2], --mount-proc [3], --map-root-user,
	--setgroups [4], and --propagation [5] options.

	Commit [1]: f9e7b66dbd
	Commit [2]: 5088ec338f
	Commit [3]: 6728ca101e
	Commit [4]: fbceefded6
	Commit [5]: f0f22e9c6f

zramctl:

	Add new output fields MEM-LIMIT, MEM-USED, and MIGRATED.

	Commit: bffc9174b8

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-04-17 18:26:37 +01:00
Sami Kerola f2b9813286
bash-completion: update schedutils
ionice:

	Add --pgid and --uid options.

	Commit: bd2ff3d2d9

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-04-17 18:20:54 +01:00
Sami Kerola c6b1d511d2
bash-completion: update misc-utils
fincore:

	Add RES column to --output completions.

	Commit: e4e8b57be2

findfs:

	Commit: 940817b736

logger:

	Add --socket-errors [1] and --tcp [2] options.

	Commit [1]: d77dc29e6e
	Commit [2]: 68265d070d

lsblk:

	Add HOTPLUG [1], SERIAL [2], and SUBSYSTEMS [3] output fields.  Add
	--json [4], --output-all [5], and --paths [6] options.

	Commit [1]: 483987c275
	Commit [2]: 460c7afb79
	Commit [3]: 7f14ee1b55
	Commit [4]: 4a102a4871
	Commit [5]: 1b4d2a4a4a
	Commit [6]: c7e76cd145

lslocks:

	Add --noinaccessible option.  Remove file argument completion, this
	command does not use that sort of command line input.

	Commit: f29bc6e1cc

mcookie:

	Add --max-size option.

	Commit: f7bac5731b

wipefs:

	Add --backup option.

	Commit: 7e658c15a2

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-04-17 18:18:10 +01:00
Sami Kerola f4e8fd91d6
bash-completion: update login-utils
last:

	Broken since first commit.
	Commit: 41e5a92cf1

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-04-17 18:16:24 +01:00
Sami Kerola 99d8ed0ac5
bash-completion: update disk-utils
fdformat:

	Add --from, --to, and --repair options.

	Commit: e0402441a1

fdisk:

	Add --output [1], --bytes [2], --wipe [3], --wipe-partition [4], and
	remove --geom- from from --cylinders, --heads, --sector options [5].

	Commit [1]: fff8ad5882
	Commit [2]: 354f8cc8cf
	Commit [3]: cb9a4b0033
	Commit [4]: ba465623d8
	Commit [5]: 4b4e391a28

fsck.cramfs:

	Broken since first commit.

	Commit: bf60993cf2

mkswap:

	Provide random uuid when completing --uuid argument.

partx:

	Add --sector-size option.  Fix also list of known partition types to
	match with libblkid blkid_idinfo names.  The fix is also applied to
	manual page.

	Commit: f8a4a0d4f2

	Reference: git grep -A 4 blkid_idinfo libblkid/src/partitions | grep name

sfdisk:

	Add --reoder, --delete, --mode-dataa, -no-tell-kernel, --wipe, and
	--wipe-partitions options.  In same go fix some option argument
	completions.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-04-17 18:12:10 +01:00
Rui Zhao (renyuneyun) bdef362d5d fix the position of newline in the time output of 'script'
- move '\n' to fprintf
- use `timeutils/strtime_iso()` instead of `strtime()`

Signed-off-by: Rui Zhao (renyuneyun) <renyuneyun@gmail.com>
2017-04-14 17:49:25 +01:00
Karel Zak d05422417e script: don't call strftime() if not necessary
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-13 15:06:52 +02:00
Karel Zak 59868828e4 Merge branch 'script_quiet' of https://github.com/renyuneyun/util-linux
* 'script_quiet' of https://github.com/renyuneyun/util-linux:
  script: fix start message showing in output file when -q is on
2017-04-13 15:04:54 +02:00
Karel Zak c8341f418a libsmartcols: fix typo
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-13 11:47:43 +02:00
Karel Zak 091683a82f lsblk: fix --inverse --list
Let's follow --inverse dependencies although --list output requested.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1441175
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-13 11:39:22 +02:00
Karel Zak 066f46e0ee libsmartcols: add scols_sort_table_by_tree()
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-13 11:19:59 +02:00
Karel Zak 341c4ae26e lsblk: move scols_flags to lsblk control struct
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-13 10:17:36 +02:00
J William Piggott 697bfcf576 hwclock: remove residual 'compare' from man-page
Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-04-10 14:57:01 -04:00
J William Piggott 9c7234bc32 hwclock: fix whitespace in hwclock-rtc.c
Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-04-10 14:50:32 -04:00
J William Piggott 796b9759a5 docs: parse-date.txt fix whitespace
Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-04-10 14:41:46 -04:00
J William Piggott dc0b13af68 parse-date: remove extraneous form feed
* lib/parse-date.y: Remove extraneous form feed (FF, 0x0C, ^L).

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-04-10 14:26:12 -04:00
J William Piggott 657a55681a hwclock: use errtryhelp()
* sys-utils/hwclock.c: use errtryhelp() instead of usage().

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-04-10 14:22:30 -04:00
J William Piggott dddbfa4e9b agetty: various man-page fixes
Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-04-10 15:46:26 +02:00
Ruediger Meier 1ea4e7bd8d chmem: don't use scanf format for printf
The compiler had not complained here because both macros are
probably the same.

But gettext issued a funny warning:
sys-utils/chmem.c:67: warning: Although being used in a format string position, the msgid is not a valid C format string. Reason: The string ends in the middle of a directive.

CC: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-04-10 15:41:21 +02:00
Ruediger Meier c8df4b17d4 misc: fix some printf format strings
Fix compiler warnings seen on Linux/i586 and OSX/travis.

  #type            #format   #cast
   unsigned long    %lu       -
   uint64_t         PRIu64    -
   fdisk_sector_t   %ju       (uintmax_t)

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-04-10 15:40:58 +02:00
Sami Kerola a0a32456c8 libmount: fix file descriptor leak
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-04-10 15:40:40 +02:00
Sami Kerola b9dc8d071d fincore: fix file descriptor leak
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-04-10 15:40:39 +02:00