]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
6 years agoMerge branch 'master' of https://github.com/kvanals/util-linux
Karel Zak [Mon, 17 Dec 2018 09:45:33 +0000 (10:45 +0100)] 
Merge branch 'master' of https://github.com/kvanals/util-linux

* 'master' of https://github.com/kvanals/util-linux:
  Finished up BlueStore support
  Added support for detecting Ceph BlueStore Block Devices

6 years agodmesg: correct "-n, --console-level level" example in manual page
Jean-Philippe ROMAIN [Mon, 17 Dec 2018 08:30:54 +0000 (09:30 +0100)] 
dmesg: correct "-n, --console-level level" example in manual page

When providing an abbreviation of the level name with the option "-n, --console-level level",
it corresponds to the level (included) up to which messages are displayed on the console.
If a level number is given, this level is excluded.

So in the given example, "-n 1" is equivalent to "-n emerg".

Signed-off-by: Jean-Philippe Romain <jean-philippe.romain@st.com>
6 years agodocs: add link to mail list archive
Sami Kerola [Sat, 15 Dec 2018 16:05:40 +0000 (16:05 +0000)] 
docs: add link to mail list archive

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
6 years agolibblkid: stratis: correct byte order
Tony Asleson [Thu, 13 Dec 2018 15:03:28 +0000 (09:03 -0600)] 
libblkid: stratis: correct byte order

Stratis superblock is little endian, ensure we retrieve the
number of sectors and initialization time correctly.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
6 years agoFinished up BlueStore support
Kenneth Van Alstyne [Fri, 14 Dec 2018 20:32:13 +0000 (14:32 -0600)] 
Finished up BlueStore support

6 years agoAdded support for detecting Ceph BlueStore Block Devices
Kenneth Van Alstyne [Fri, 14 Dec 2018 20:27:10 +0000 (14:27 -0600)] 
Added support for detecting Ceph BlueStore Block Devices

6 years agoMerge branch 'aarch32_on_aarch64' of https://github.com/jlinton/util-linux
Karel Zak [Wed, 12 Dec 2018 13:25:22 +0000 (14:25 +0100)] 
Merge branch 'aarch32_on_aarch64' of https://github.com/jlinton/util-linux

* 'aarch32_on_aarch64' of https://github.com/jlinton/util-linux:
  lscpu: Add aarch32 detection on aarch64

6 years agomkswap: use dd(1) in example rather than fallocate(1)
Karel Zak [Wed, 12 Dec 2018 11:14:39 +0000 (12:14 +0100)] 
mkswap: use dd(1) in example rather than fallocate(1)

The man page warns against fallocate on some filesystems and recommends
dd(1) as the most portable solution. So, let's use dd(1) also in the
example used in the same man page.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1203378
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolscpu: Add aarch32 detection on aarch64
Jeremy Linton [Tue, 11 Dec 2018 18:27:29 +0000 (12:27 -0600)] 
lscpu: Add aarch32 detection on aarch64

aarch32 support is an optional feature of ARMv8, as CPUs
which don't support aarch32 become more common, lets make
sure that lscpu can tell a user quickly if they are on a
machine that only supports 64-bit.

Signed-off-by: Jeremy Linton <lintonrjeremy@gmail.com>
6 years agolslogins: make valid_pwd() more robust
Karel Zak [Tue, 11 Dec 2018 13:20:19 +0000 (14:20 +0100)] 
lslogins: make valid_pwd() more robust

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agoMerge branch 'fix-couple-warnings' of https://github.com/kerolasa/util-linux
Karel Zak [Tue, 11 Dec 2018 13:14:37 +0000 (14:14 +0100)] 
Merge branch 'fix-couple-warnings' of https://github.com/kerolasa/util-linux

* 'fix-couple-warnings' of https://github.com/kerolasa/util-linux:
  hexdump: fix potential null pointer dereference warnings
  lslogins: remove duplicate NULL check
  libsmartcols: fix  variable shadowing
  lsblk: fix null pointer dereferences

6 years agotests: check for tar and {b,g}zip
Karel Zak [Tue, 11 Dec 2018 10:44:48 +0000 (11:44 +0100)] 
tests: check for tar and {b,g}zip

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agohexdump: fix potential null pointer dereference warnings
Sami Kerola [Mon, 10 Dec 2018 21:41:19 +0000 (21:41 +0000)] 
hexdump: fix potential null pointer dereference warnings

First three fixes on lines 133, 151, and 280 are cosmetic.  Because there
was unobvious null check compiler thought variable might be null, and warned
when after pointer adjustment it was followed without null check.  Perhaps
this will not happen sometime in future when compiler is made more smart,
meanwhile lets give better hints to avoid false positive.

The last change addresses issue that is possible, at least in theory.

text-utils/hexdump-parse.c:465:12: warning: potential null pointer
dereference [-Wnull-dereference]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
6 years agolslogins: remove duplicate NULL check
Sami Kerola [Mon, 10 Dec 2018 20:41:18 +0000 (20:41 +0000)] 
lslogins: remove duplicate NULL check

Having this excess NULL check in place causes small performance penalty, and
makes compiler to guess wrong if a null should be checked.  To me getting
rid of false positive warning is more useful.

login-utils/lslogins.c:634:7: warning: potential null pointer dereference
[-Wnull-dereference]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
6 years agolibsmartcols: fix variable shadowing
Sami Kerola [Mon, 10 Dec 2018 20:30:59 +0000 (20:30 +0000)] 
libsmartcols: fix  variable shadowing

libsmartcols/src/grouping.c:115:26: warning: declaration of ‘ln’ shadows a
    previous local [-Wshadow]
libsmartcols/src/grouping.c:108:24: note: shadowed declaration is here

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
6 years agolsblk: fix null pointer dereferences
Sami Kerola [Mon, 10 Dec 2018 20:14:12 +0000 (20:14 +0000)] 
lsblk: fix null pointer dereferences

Both catched with -Wnull-dereference compiler option:

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
6 years agolibmount: (umount) make mnt_stat_mountpoin() usable for relative paths
Karel Zak [Mon, 10 Dec 2018 15:25:08 +0000 (16:25 +0100)] 
libmount: (umount) make mnt_stat_mountpoin() usable for relative paths

 # mount -o loop devicefile /mnt/test
 # umount devicefile
 umount: devicefile: not mounted.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1653781
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agoumount: fix --quiet
Karel Zak [Mon, 10 Dec 2018 13:34:12 +0000 (14:34 +0100)] 
umount: fix --quiet

Addresses: https://github.com/karelzak/util-linux/commit/d5fd9ac6b208c5acdb6c0023757a7e2827474482#commitcomment-31610748
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agochoom: fix negative adjust score usage
Karel Zak [Mon, 10 Dec 2018 13:26:04 +0000 (14:26 +0100)] 
choom: fix negative adjust score usage

It's really bad idea to use uint64_t (ul_path_write_u64(()) when write
signed number.

Addresses: https://github.com/karelzak/util-linux/issues/723
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolibuuid: fix man page typos
Seth Girvan [Fri, 7 Dec 2018 10:02:00 +0000 (02:02 -0800)] 
libuuid: fix man page typos

Signed-off-by: Seth Girvan <snth@snthhacks.com>
6 years agofstrim: fix usage()
Karel Zak [Mon, 10 Dec 2018 11:03:18 +0000 (12:03 +0100)] 
fstrim: fix usage()

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agoMerge branch '2018wk48' of https://github.com/kerolasa/util-linux
Karel Zak [Mon, 10 Dec 2018 10:58:04 +0000 (11:58 +0100)] 
Merge branch '2018wk48' of https://github.com/kerolasa/util-linux

* '2018wk48' of https://github.com/kerolasa/util-linux:
  include/c: check returns_nonnull function attribute with __GNUC_PREREQ

6 years agofstrim: trim also root FS on --fstab
Karel Zak [Mon, 10 Dec 2018 10:45:03 +0000 (11:45 +0100)] 
fstrim: trim also root FS on --fstab

The root fs ("/") is optional in many case in /etc/fstab. This patch
forces fstrim to read kernel command line for the root= option to get
root FS if the entry is missing in your fstab.

Addresses: https://github.com/karelzak/util-linux/issues/719
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolibmount: export mnt_guess_system_root() by API
Karel Zak [Mon, 10 Dec 2018 10:39:08 +0000 (11:39 +0100)] 
libmount: export mnt_guess_system_root() by API

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolsblk: add --merge
Karel Zak [Fri, 7 Dec 2018 11:29:50 +0000 (12:29 +0100)] 
lsblk: add --merge

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolibsmartcols: add grouping API docs
Karel Zak [Fri, 7 Dec 2018 11:28:36 +0000 (12:28 +0100)] 
libsmartcols: add grouping API docs

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolibsmartcols: add grouping samples
Karel Zak [Fri, 7 Dec 2018 11:26:58 +0000 (12:26 +0100)] 
libsmartcols: add grouping samples

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolibsmartcols: add lines grouping support
Karel Zak [Fri, 7 Dec 2018 10:54:39 +0000 (11:54 +0100)] 
libsmartcols: add lines grouping support

For some use-case we need to describe M:N relation between output
lines. The nice examples are RAIDs or multi-path devices in lsblk
output.

    NAME                 MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
    loop0                  7:0    0 955.7M  0 loop
┌┈▶ ├─test-thin-metadata 253:0    0     2M  0 dm
└┬▶ └─test-thin-data     253:1    0 953.7M  0 dm
 └┈┈test-thin-pool       253:2    0 953.7M  0 dm

In this example two line (test-thin-metadata and test-thin-data) are
parents for another line (test-thin-pool). The new API uses term "group"
for parental line -- the number of group members is unlimited and every
group has at least one child.

It's possible that group's child is member of another group:

       NAME                 MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
       loop0                  7:0    0 955.7M  0 loop
   ┌┈▶ ├─test-thin-metadata 253:0    0     2M  0 dm
   └┬▶ └─test-thin-data     253:1    0 953.7M  0 dm
┌┈▶ └┈┈test-thin-pool       253:2    0 953.7M  0 dm
┆      └─test-thin          253:3    0 190.8M  0 dm
└┬▶    loop1                  7:1    0 190.8M  0 loop
 └┈┈┈┈┈test-thin-extsnap    253:4    0 190.8M  0 dm

For now multi-group relation is unsupported and one line can be member
of one group only. The library API and printing code is ready to
support this feature, but not sure if we really need it. All what is
necessary is to create array of groups in the line struct.

Note that grouping is independent on standard parent->child relations
between lines and grouping can connect arbitrary lines. The
restriction is only that group child cannot be child of another line
or child of another group. These cross reference are (and probably
will be) impossible.

The patch is relative large, but easy to review. Changes:

* add new UTF symbols
* add scols_symbols_set_group_* public API to modify new symbols
* add struct libscols_group, used only internally

* add "grpset" array to table struct -- the array is used to keep
position of the group in the output. Every active group uses three
items in the grpset. If there is more overlapping groups than bigger
grpset is allocated.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agoinclude/list: add list_entry_is_first() and list_count_entries()
Karel Zak [Fri, 7 Dec 2018 10:37:24 +0000 (11:37 +0100)] 
include/list: add list_entry_is_first() and list_count_entries()

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolibsmartcols: split print.c into print.c, put.c and print-api.c
Karel Zak [Thu, 25 Oct 2018 14:26:30 +0000 (16:26 +0200)] 
libsmartcols: split print.c into print.c, put.c and print-api.c

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolibsmartcols: move width calculation to separate file
Karel Zak [Thu, 25 Oct 2018 14:01:23 +0000 (16:01 +0200)] 
libsmartcols: move width calculation to separate file

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolibsmartcols: rename table_print.c to print.c
Karel Zak [Thu, 25 Oct 2018 13:43:43 +0000 (15:43 +0200)] 
libsmartcols: rename table_print.c to print.c

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolibsmartcols: move buffer stuff to buffer.c
Karel Zak [Thu, 25 Oct 2018 13:39:47 +0000 (15:39 +0200)] 
libsmartcols: move buffer stuff to buffer.c

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolibsmartcols: add another UTF symbols
Karel Zak [Thu, 25 Oct 2018 13:38:08 +0000 (15:38 +0200)] 
libsmartcols: add another UTF symbols

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolibsmartcols: add is_last_child(), move is_last_column()
Karel Zak [Thu, 25 Oct 2018 12:12:16 +0000 (14:12 +0200)] 
libsmartcols: add is_last_child(), move is_last_column()

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolsblk: make devtree dependences more generic
Karel Zak [Tue, 23 Oct 2018 12:04:55 +0000 (14:04 +0200)] 
lsblk: make devtree dependences more generic

We also need reference from child to parent to implement multi-parent
view. This change allows to walk on tree in both directions.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agodocs: add lsblk --merge to TODO
Karel Zak [Thu, 18 Oct 2018 14:16:12 +0000 (16:16 +0200)] 
docs: add lsblk --merge to TODO

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolsblk: add --dedup <column>
Karel Zak [Thu, 18 Oct 2018 13:46:07 +0000 (15:46 +0200)] 
lsblk: add --dedup <column>

The target use-case are systems with large number of multi-path
devices or systems with duplicate (copied) filesystems.

The feature is flexible enough to use arbitrary column (for example
WWM or UUID, ...) as de-duplication key.

For example tree with multi-path devices sd{c,d,e,f}

./lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda           8:0    0 223.6G  0 disk
├─sda1        8:1    0   200M  0 part  /boot/efi
├─sda2        8:2    0   200M  0 part  /boot
├─sda3        8:3    0 130.3G  0 part
├─sda4        8:4    0    50G  0 part  /
└─sda5        8:5    0  42.9G  0 part
sdb           8:16   0  74.5G  0 disk
└─sdb1        8:17   0  74.5G  0 part  /home/archive
sdc           8:32   0   100M  0 disk
└─mpatha    253:0    0   100M  0 mpath
  ├─mpatha1 253:1    0    50M  0 part
  └─mpatha2 253:2    0    49M  0 part
sdd           8:48   0   100M  0 disk
└─mpatha    253:0    0   100M  0 mpath
  ├─mpatha1 253:1    0    50M  0 part
  └─mpatha2 253:2    0    49M  0 part
sde           8:64   0   100M  0 disk
└─mpatha    253:0    0   100M  0 mpath
  ├─mpatha1 253:1    0    50M  0 part
  └─mpatha2 253:2    0    49M  0 part
sdf           8:80   0   100M  0 disk
└─mpatha    253:0    0   100M  0 mpath
  ├─mpatha1 253:1    0    50M  0 part
  └─mpatha2 253:2    0    49M  0 part

De-duplicate by WWN:

./lsblk -M WWN
NAME        MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda           8:0    0 223.6G  0 disk
├─sda1        8:1    0   200M  0 part  /boot/efi
├─sda2        8:2    0   200M  0 part  /boot
├─sda3        8:3    0 130.3G  0 part
├─sda4        8:4    0    50G  0 part  /
└─sda5        8:5    0  42.9G  0 part
sdb           8:16   0  74.5G  0 disk
└─sdb1        8:17   0  74.5G  0 part  /home/archive
sdc           8:32   0   100M  0 disk
└─mpatha    253:0    0   100M  0 mpath
  ├─mpatha1 253:1    0    50M  0 part
  └─mpatha2 253:2    0    49M  0 part

Addresses: https://github.com/karelzak/util-linux/issues/616
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolsblk: remember whole-disk, remove unused struct member
Karel Zak [Thu, 18 Oct 2018 11:57:46 +0000 (13:57 +0200)] 
lsblk: remember whole-disk, remove unused struct member

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolsblk: make device_get_data() more generic
Karel Zak [Thu, 18 Oct 2018 10:39:41 +0000 (12:39 +0200)] 
lsblk: make device_get_data() more generic

* independent on smartcols line
* keep sort data optional

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolsblk: apply --nodeps to partitions too
Karel Zak [Wed, 17 Oct 2018 12:13:31 +0000 (14:13 +0200)] 
lsblk: apply --nodeps to partitions too

The new implementation differentiates between partitions and another
dependences -- this is regression, we need root devices only.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolsblk: read queue/discard_granularity only when necessary
Karel Zak [Wed, 17 Oct 2018 12:10:27 +0000 (14:10 +0200)] 
lsblk: read queue/discard_granularity only when necessary

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolsblk: reuse 'removable' flag from parent
Karel Zak [Wed, 17 Oct 2018 11:48:43 +0000 (13:48 +0200)] 
lsblk: reuse 'removable' flag from parent

It's used in the default output, let's make it a little bit more
effective.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolsblk: don't keep sysfs dirs open
Karel Zak [Wed, 17 Oct 2018 11:19:50 +0000 (13:19 +0200)] 
lsblk: don't keep sysfs dirs open

Don't keep open sysfs file descriptors for all time to avoid problems
on systems with huge number of block devices.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolib/path: allow to close dirfd
Karel Zak [Wed, 17 Oct 2018 11:18:25 +0000 (13:18 +0200)] 
lib/path: allow to close dirfd

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolsblk: rename set_device()
Karel Zak [Wed, 17 Oct 2018 09:14:40 +0000 (11:14 +0200)] 
lsblk: rename set_device()

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolsblk: add comments
Karel Zak [Wed, 17 Oct 2018 08:54:59 +0000 (10:54 +0200)] 
lsblk: add comments

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolsblk: add process_all_devices_inverse()
Karel Zak [Tue, 16 Oct 2018 13:53:22 +0000 (15:53 +0200)] 
lsblk: add process_all_devices_inverse()

This is necessary to implement --inverse. Note that this new
implementation scans /sys/dev/block/ to get top-level devices
and than it calls process_one_device().

Note that standard non-inverse tree does not use process_one_device()
as it's more effective to scan /sys/block where are no partitions.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolib/sysfs: add function to detect partitioned devices
Karel Zak [Tue, 16 Oct 2018 13:52:13 +0000 (15:52 +0200)] 
lib/sysfs: add function to detect partitioned devices

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolsblk: reorder functions
Karel Zak [Tue, 16 Oct 2018 12:37:28 +0000 (14:37 +0200)] 
lsblk: reorder functions

The goal is to call process_one_device() from process_all_devices(),
so let's it keep in code in the right order.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolsblk: make process_partitions() more readable
Karel Zak [Tue, 16 Oct 2018 12:35:36 +0000 (14:35 +0200)] 
lsblk: make process_partitions() more readable

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolsblk: remove unncessary parent pointer
Karel Zak [Tue, 16 Oct 2018 12:29:00 +0000 (14:29 +0200)] 
lsblk: remove unncessary parent pointer

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolsblk: use real rather than hardcoded parent
Karel Zak [Tue, 16 Oct 2018 12:20:29 +0000 (14:20 +0200)] 
lsblk: use real rather than hardcoded parent

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolsblk: use devtree functions
Karel Zak [Tue, 16 Oct 2018 11:39:25 +0000 (13:39 +0200)] 
lsblk: use devtree functions

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolsblk: add lsblk_device_has_dependence()
Karel Zak [Tue, 16 Oct 2018 11:37:36 +0000 (13:37 +0200)] 
lsblk: add lsblk_device_has_dependence()

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolsblk: process_one_device() refactoring
Karel Zak [Mon, 15 Oct 2018 14:12:33 +0000 (16:12 +0200)] 
lsblk: process_one_device() refactoring

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolsblk: add devtree_get_device_or_new()
Karel Zak [Mon, 15 Oct 2018 13:53:33 +0000 (15:53 +0200)] 
lsblk: add devtree_get_device_or_new()

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolsblk: keep functions names consistent
Karel Zak [Mon, 15 Oct 2018 12:25:15 +0000 (14:25 +0200)] 
lsblk: keep functions names consistent

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolsblk: remove unused reset_device()
Karel Zak [Mon, 15 Oct 2018 12:16:32 +0000 (14:16 +0200)] 
lsblk: remove unused reset_device()

Now all is maintained by reference counting ion the devtree.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolsblk: fix devtree deallocation
Karel Zak [Mon, 15 Oct 2018 12:14:33 +0000 (14:14 +0200)] 
lsblk: fix devtree deallocation

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolsblk: split sysfs reading and scols table filling
Karel Zak [Mon, 15 Oct 2018 11:55:08 +0000 (13:55 +0200)] 
lsblk: split sysfs reading and scols table filling

This change allows read devices from sysfs only once and reuse device
properties if the device is references more than once in the tree
(RAIDs, etc.).

* every device is in the tree only once (tree->devices list)

* iterate_block_devices() reuse already read devices (for example if
  already read for any dependence)

* the smartscols table is build from the final tree

The patch temporary disables dependencies evaluation (in
process_blkdev() to keep the patch small and simple.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolsblk: cleanup device reference in the tree
Karel Zak [Mon, 15 Oct 2018 11:53:19 +0000 (13:53 +0200)] 
lsblk: cleanup device reference in the tree

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolsblk: remove badly named debug interface name
Karel Zak [Fri, 12 Oct 2018 10:51:03 +0000 (12:51 +0200)] 
lsblk: remove badly named debug interface name

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolsblk: add basic function to build devices tree
Karel Zak [Fri, 12 Oct 2018 10:50:03 +0000 (12:50 +0200)] 
lsblk: add basic function to build devices tree

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolsblk: properly initialize structs
Karel Zak [Fri, 12 Oct 2018 10:48:42 +0000 (12:48 +0200)] 
lsblk: properly initialize structs

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolsblk: rename reset_lsblk_device() to reset_device()
Karel Zak [Tue, 9 Oct 2018 10:48:34 +0000 (12:48 +0200)] 
lsblk: rename reset_lsblk_device() to reset_device()

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolsblk: rename blkdev_cxt to lsblk_device
Karel Zak [Tue, 9 Oct 2018 10:46:28 +0000 (12:46 +0200)] 
lsblk: rename blkdev_cxt to lsblk_device

The patch does not change code logic and semantic -- just rename.

* set_cxt() to set_device()
* struct blkdev_cxt to lsblk_device

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agobuild-sys: do not require crypt()
Karel Zak [Thu, 22 Nov 2018 11:53:00 +0000 (12:53 +0100)] 
build-sys: do not require crypt()

The function is necessary only for newgrp and sulogin.

Addresses: https://github.com/karelzak/util-linux/issues/584
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agobuild-sys: do not require dirfd()
Karel Zak [Wed, 24 Oct 2018 12:32:29 +0000 (14:32 +0200)] 
build-sys: do not require dirfd()

The dirfd() is required on many places, but it should not be required for
all utils by ./configure.ac.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agobuild-sys: improve error message
Karel Zak [Wed, 24 Oct 2018 12:21:15 +0000 (14:21 +0200)] 
build-sys: improve error message

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolib/timer: add fallback if timer_create() not available
Karel Zak [Wed, 24 Oct 2018 10:28:13 +0000 (12:28 +0200)] 
lib/timer: add fallback if timer_create() not available

* add struct ul_timer as API abstraction to hide differences between
timer_create() and setitimer()

* add setitimer() detection to ./configure.ac

* add fallback code to use setitimer() if timer_create() not available
  (for example on OSX)

Addresses: https://github.com/karelzak/util-linux/issues/584
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agobuild-sys: make sure HAVE_TIMER_CREATE defined
Karel Zak [Wed, 24 Oct 2018 10:18:54 +0000 (12:18 +0200)] 
build-sys: make sure HAVE_TIMER_CREATE defined

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agoinclude/c: re-add type checking in container_of()
Ruediger Meier [Sun, 2 Dec 2018 18:23:45 +0000 (19:23 +0100)] 
include/c: re-add type checking in container_of()

This reverts parts of commit eb06d5d4, which seems to be based on
Linux kernel commit c7acec71. Unlike the original kernel patch we did
not add that even stronger type checking by using macro BUILD_BUG_ON_MSG.
So basically we removed a useful warning when compiling such
broken code:

      struct st {
            int a;
            char b;
      };
      struct st t = { .a = 1, .b = 2 };
      struct st *x = container_of(&t.a, struct st, b);
      printf("%p %p\n", (void *)&t, (void *)x);

Moreover we also introduced a new compiler warning for intel/icc:
   "arithmetic on pointer to void or function type"

Let's just revert the update of container_of() because adding a
kernel-like BUILD_BUG_ON_MSG would be too much noise and also
problematic (see kernel commit c03567a8). Also note that the original
problem addressed by the kernel commit seems to be only reproducible
with gcc 4.9, not with any later gcc nor clang,icc. Moreover, currently
we have no such use-case in the UL sources anyways.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
6 years agoinclude/c: check returns_nonnull function attribute with __GNUC_PREREQ
Sami Kerola [Sun, 2 Dec 2018 16:28:22 +0000 (16:28 +0000)] 
include/c: check returns_nonnull function attribute with __GNUC_PREREQ

Karel pointed out previous commit could have been better in github feedback,
so lets use the version check macro instead of compare versions directly.

Previous-commit: f1b327f8d5c8de7bf7fae99e85765d0954a25bac
Reference: https://github.com/karelzak/util-linux/pull/704#issuecomment-432605211
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
6 years agotests: make lsns-netnsid portable
Karel Zak [Fri, 30 Nov 2018 11:24:15 +0000 (12:24 +0100)] 
tests: make lsns-netnsid portable

It seems ip(8) link-show command does not provide link-netnsid in all
cases (versions ?). Let's try to use "ip netns list-id" as fallback.

This commit also add possibility to debug the script by $LOG variable.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agotests: enlarge backing file for fstab-btrfs
Karel Zak [Fri, 30 Nov 2018 11:22:48 +0000 (12:22 +0100)] 
tests: enlarge backing file for fstab-btrfs

It seems the new limit for Btrfs is 47MiB.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolib/canonicalize: fix typo
Karel Zak [Thu, 29 Nov 2018 12:33:02 +0000 (13:33 +0100)] 
lib/canonicalize: fix typo

Addresses: https://github.com/karelzak/util-linux/commit/8b8277b7a812c04f2288460f3a8d23cdd53ff66d#commitcomment-31491031
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolibmount: (fuse) follow only user_id= on umount
Karel Zak [Thu, 15 Nov 2018 11:11:29 +0000 (12:11 +0100)] 
libmount: (fuse) follow only user_id= on umount

The option user= is already handled by evaluate_permissions() and by
classic mount and umount usermount support. It seems we do not need
to duplicate support for user= in is_fuse_usermount().

The option user_id= is fuse specific and it's maintained by
libfuse/kernel in /proc/self/mountinfo. This is feature we need to
support in umount(8).

Addresses: https://github.com/karelzak/util-linux/pull/705
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolibmount: Support unmount FUSE mounts
Rian Hunter [Sat, 13 Oct 2018 02:48:47 +0000 (19:48 -0700)] 
libmount: Support unmount FUSE mounts

FUSE mounts don't need an fstab entry to be unmounted.
This checks if a mount is a FUSE mount before checking for
the fstab entry, and if so returns success.

[kzak@redhat.com: - use libmount tools for mount options
                  - use namespace switches
                  - cleanup code

 The requirement is user=<username> or user_id=<uid> in /proc/self/mountinfo
 for fuse filesystem. The logic is the same as for user= mount options, but in
 this case it is not maintained by libmount in userspace, but by fuse FS in kernel.]

Co-Author: Karel Zak <kzak@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolib/canonicalize: do restricted canonicalize in a subprocess
Rian Hunter [Sat, 13 Oct 2018 02:45:06 +0000 (19:45 -0700)] 
lib/canonicalize: do restricted canonicalize in a subprocess

Accessing FUSE mounts require suid/sgid (saved uid) to be equal to the
owner of the mount. If mount is running as a setuid process, swapping
creds by only setting the euid/egid isn't enough to change the
suid/sgid as well. We must do a full setuid()/setgid(), but that
removes our ability to re-assume the identity of the original
euid. The solution is swap creds in a child process, preserving the
creds of the parent.

[kzak@redhat.com: - use switch() rather than if() for fork
  - use all-io.h
  - close unused pipe[] ends
  - be more strict about used types]

Addresses: https://github.com/karelzak/util-linux/pull/705
Co-Author: Karel Zak <kzak@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agoblkid: fix usage()
Karel Zak [Thu, 29 Nov 2018 12:30:11 +0000 (13:30 +0100)] 
blkid: fix usage()

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agoblkid: make PART_ENTRY_* tags optional (add --no-part-details)
Karel Zak [Thu, 29 Nov 2018 12:21:36 +0000 (13:21 +0100)] 
blkid: make PART_ENTRY_* tags optional (add --no-part-details)

blkid(8) returns information from partition table also for empty
partitions. This is necessary for example for udev, but it could be
confusing if you care about on-device content only.

Default:
 # blkid -p /dev/md0p1; echo $?
 /dev/md0p1: PART_ENTRY_SCHEME="dos" PART_ENTRY_UUID="6d8796b1-01" PART_ENTRY_TYPE="0x83" PART_ENTRY_NUMBER="1" PART_ENTRY_OFFSET="2048" PART_ENTRY_SIZE="204800" PART_ENTRY_DISK="9:0"
 0

With --no-part-details:
 # blkid -p /dev/md0p1 --no-part-details; echo $?
 2

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1653413
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agomkswap: fix page size warning message
Noel Cragg [Thu, 29 Nov 2018 10:38:41 +0000 (11:38 +0100)] 
mkswap: fix page size warning message

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agobuild-sys: make fdisk, sfdisk, cfdisk optional (enabled by default)
Carlos Santos [Thu, 22 Nov 2018 15:05:49 +0000 (13:05 -0200)] 
build-sys: make fdisk, sfdisk, cfdisk optional (enabled by default)

Useful for embedded systems, on which only few utilities are required.

[kzak@redhat.com: - rename to --disable-fdisks
                  - use $enable_{c,s,}fdisk in code]

Signed-off-by: Carlos Santos <casantos@datacom.com.br>
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agouuidd: Add hardening settings to uuidd.service
Andreas Henriksson [Fri, 23 Nov 2018 11:10:59 +0000 (12:10 +0100)] 
uuidd: Add hardening settings to uuidd.service

This limits what the uuid daemon has access to when it runs.

Further improving this with additional option or making
things even tighter is most likely possible.

Signed-off-by: Andreas Henriksson <andreas@fatal.se>
6 years agotests: add test images for drbd v08/v09
Roland Kammerer [Thu, 22 Nov 2018 13:42:48 +0000 (14:42 +0100)] 
tests: add test images for drbd v08/v09

This adds DRBD meta data images for DRBD versions 8 and 9, as well as
the according expected output.

Signed-off-by: Roland Kammerer <roland.kammerer@linbit.com>
6 years agoMerge branch 'master' of https://github.com/nyantec/util-linux
Karel Zak [Thu, 22 Nov 2018 11:04:54 +0000 (12:04 +0100)] 
Merge branch 'master' of https://github.com/nyantec/util-linux

* 'master' of https://github.com/nyantec/util-linux:
  fix a bug where switch_root would erroneously try to parse initargs

6 years agoMerge branch '2018wk41' of https://github.com/kerolasa/util-linux
Karel Zak [Thu, 22 Nov 2018 10:51:00 +0000 (11:51 +0100)] 
Merge branch '2018wk41' of https://github.com/kerolasa/util-linux

* '2018wk41' of https://github.com/kerolasa/util-linux:
  include/c: use returns_nonnull function attribute in xalloc.h

6 years agoMerge branch 'fix-uuid-oids-test' of https://github.com/Whissi/util-linux
Karel Zak [Thu, 22 Nov 2018 10:40:42 +0000 (11:40 +0100)] 
Merge branch 'fix-uuid-oids-test' of https://github.com/Whissi/util-linux

* 'fix-uuid-oids-test' of https://github.com/Whissi/util-linux:
  tests: run oids test only when uuidgen tool was built

6 years agofstrim: Add hardening settings to fstrim.service
Andreas Henriksson [Thu, 22 Nov 2018 10:13:58 +0000 (11:13 +0100)] 
fstrim: Add hardening settings to fstrim.service

This limits what the fstrim process has access to when it runs.

PrivateUsers can't be enabled because of:
"If this mode is enabled, all unit processes are run without privileges
in the host user namespace[...]"

Further improving this with additional option or making
things even tighter is most likely possible.

Signed-off-by: Andreas Henriksson <andreas@fatal.se>
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agosetarch: fix obscure sparc32bash use-case
Karel Zak [Thu, 22 Nov 2018 10:03:35 +0000 (11:03 +0100)] 
setarch: fix obscure sparc32bash use-case

Reported-by: Carlos Santos <casantos@datacom.com.br>
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agoinclude/c: use returns_nonnull function attribute in xalloc.h
Sami Kerola [Sat, 6 Oct 2018 11:31:09 +0000 (12:31 +0100)] 
include/c: use returns_nonnull function attribute in xalloc.h

Let the compiler optimize based on the knowledge that the return value will
never be null.

Reference: https://patchwork.ozlabs.org/patch/281112/#631159
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
6 years agolibblkid: add check for DRBD9
Roland Kammerer [Tue, 20 Nov 2018 16:10:49 +0000 (17:10 +0100)] 
libblkid: add check for DRBD9

This adds the according meta-data structs + defines and an additional
function to detect DRBD9 magics.

Signed-off-by: Roland Kammerer <roland.kammerer@linbit.com>
6 years agoagetty: Return old behavior with empty logname
Stanislav Brabec [Mon, 19 Nov 2018 23:38:14 +0000 (00:38 +0100)] 
agetty: Return old behavior with empty logname

c094fcd37 introduced a behavior change: When Return is entered with empty
logname, nothing happens. As it confuses users, return back the old
behavior: re-prompt.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
6 years agolibblkid: Fix hidding typo
Andreas Henriksson [Mon, 12 Nov 2018 19:50:23 +0000 (20:50 +0100)] 
libblkid: Fix hidding typo

Spelling error spotted by lintian.

Signed-off-by: Andreas Henriksson <andreas@fatal.se>
6 years agofstrim: Add Documentation key to fstrim.service
Andreas Henriksson [Mon, 12 Nov 2018 18:45:51 +0000 (19:45 +0100)] 
fstrim: Add Documentation key to fstrim.service

6 years agouuidd: Add Documentation key to uuidd.service
Andreas Henriksson [Mon, 12 Nov 2018 18:39:45 +0000 (19:39 +0100)] 
uuidd: Add Documentation key to uuidd.service

6 years agofstrim: use long options in systemd service file
Sami Kerola [Sun, 12 Aug 2018 12:56:33 +0000 (13:56 +0100)] 
fstrim: use long options in systemd service file

Long options are more user friendly.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
6 years agoMerge branch 'master' of github.com:karelzak/util-linux
Paul Asmuth [Mon, 12 Nov 2018 13:22:12 +0000 (14:22 +0100)] 
Merge branch 'master' of github.com:karelzak/util-linux

6 years agofix a bug where switch_root would erroneously try to parse initargs
Paul Asmuth [Fri, 9 Nov 2018 16:02:11 +0000 (17:02 +0100)] 
fix a bug where switch_root would erroneously try to parse initargs

before this change, switch_root would try to parse all arguments,
including 'initargs', using getopt, which would lead to an 'unrecognized
option' error when trying to pass a flag to the init program