]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
6 years agolast: fix wtmp user name buffer overflow [asan]
Sami Kerola [Sun, 13 Jan 2019 19:48:59 +0000 (19:48 +0000)] 
last: fix wtmp user name buffer overflow [asan]

Ensure utmp user name field is null terminated.  Without that getpwnam() can
buffer overflow, when wtmp file is malformed.

Addresses: https://github.com/karelzak/util-linux/issues/715
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
6 years agologin: add support for login.defs(5) LASTLOG_UID_MAX
Karel Zak [Fri, 11 Jan 2019 11:16:00 +0000 (12:16 +0100)] 
login: add support for login.defs(5) LASTLOG_UID_MAX

This new variable allows to keep lastlog file small and filter out
things like huge nfsnobody UIDs.

The variable is also supported by shadow-utils (adduser, etc.).

Addresses: https://github.com/shadow-maint/shadow/pull/142/
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agologin-utils/logindefs: clenaup API
Karel Zak [Fri, 11 Jan 2019 11:15:00 +0000 (12:15 +0100)] 
login-utils/logindefs: clenaup API

The default value should be unsigned if the result is also unsigned...

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agofstrim: check for read-only devices on -a/-A
Karel Zak [Fri, 11 Jan 2019 09:44:14 +0000 (10:44 +0100)] 
fstrim: check for read-only devices on -a/-A

 to avoid "FITRIM ioctl failed: Remote I/O error"

Addresses: https://github.com/karelzak/util-linux/issues/738
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agosu-common.c: prefer ENV_SUPATH over ENV_ROOTPATH
Stanislav Brabec [Thu, 10 Jan 2019 00:28:54 +0000 (01:28 +0100)] 
su-common.c: prefer ENV_SUPATH over ENV_ROOTPATH

ENV_SUPATH and ENV_ROOTPATH are equivalent and ENV_ROOTPATH takes
precedence in both login and su. It makes no sense. More logical would be
precedence of ENV_SUPATH in su and ENV_ROOTPATH in login.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
6 years agosu-common.c: prefer /etc/default/su over login.defs
Stanislav Brabec [Thu, 10 Jan 2019 00:28:53 +0000 (01:28 +0100)] 
su-common.c: prefer /etc/default/su over login.defs

su(1) documentation says:
       /etc/default/su  command specific logindef config file
       /etc/login.defs  global logindef config file

It indirectly indicates that /etc/default/su should take precedence
over /etc/login.defs.

But the reverse is true. It is not possible to define ENV_PATH in
/etc/login.defs and then make su specific customization in
/etc/default/su. We need to change read order to match the documented
behavior.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
6 years agofdisk: make partition types uses more robust
Karel Zak [Thu, 10 Jan 2019 11:17:19 +0000 (12:17 +0100)] 
fdisk: make partition types uses more robust

* report failed partition type parsing
* make sure partition types code (from user reply) for MBR is hex

Reported-by: Jonny Grant <jg@jguk.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agofdisk: support CTRL+C on change-partition-type dialog
Karel Zak [Thu, 10 Jan 2019 10:26:05 +0000 (11:26 +0100)] 
fdisk: support CTRL+C on change-partition-type dialog

Reported-by: Jonny Grant <jg@jguk.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agoutmpdump: fix word swapping in manual page
Carlos Santos [Mon, 7 Jan 2019 19:32:34 +0000 (17:32 -0200)] 
utmpdump: fix word swapping in manual page

From
    The only binary version of the utmp(5) is standardised.
To
    Only the binary version of the utmp(5) is standardised.

Change-Id: I0033f6cf055d569c7dfca5e05e918f735ea72582
Signed-off-by: Carlos Santos <casantos@datacom.com.br>
6 years agolibblkid: improve whole-disk detection when read /proc/partitions
Karel Zak [Tue, 8 Jan 2019 11:07:18 +0000 (12:07 +0100)] 
libblkid: improve whole-disk detection when read /proc/partitions

blkid(8) in high-level mode checks partitions and unpartitioned
whole-disk devices from the file /proc/partitions.

The current heuristic assumes that partition name ends with a digit.
Unfortunately, this is not correct -- for example md0 or nvme0n1 are
whole-disk devices.

This commit uses sysfs_devno_is_wholedisk() to make sure the device is
a partition (according to kernel or DM). It's probably more expensive,
because this way requires more syscalls (to read stuff from /sys etc.).

The patch also adds more information to the blkid(8) man page.

Addresses: https://github.com/karelzak/util-linux/issues/728
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agoldattach: Check for value of _HAVE_STRUCT_TERMIOS_C_ISPEED
Khem Raj [Sat, 5 Jan 2019 06:38:25 +0000 (22:38 -0800)] 
ldattach: Check for value of _HAVE_STRUCT_TERMIOS_C_ISPEED

in glibc 2.29+ checking for just existence of _HAVE_STRUCT_TERMIOS_C_ISPEED
won't be enough, the value has to be checked

see
https://sourceware.org/git/?p=glibc.git;a=commit;h=e5a50db36eaa6e8c6427b3a971563240b633ca85

Signed-off-by: Khem Raj <raj.khem@gmail.com>
6 years agolibblkid: (ntfs) fix compiler warning [-Wpedantic]
Karel Zak [Wed, 2 Jan 2019 13:44:59 +0000 (14:44 +0100)] 
libblkid: (ntfs) fix compiler warning [-Wpedantic]

libblkid/src/superblocks/ntfs.c:80:2: warning: ISO C restricts enumerator
values to range of 'int' (4294967295 is too large) [-Wpedantic]

Addressed: https://github.com/karelzak/util-linux/pull/732
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agochmem: add initilizer [clang]
Sami Kerola [Thu, 13 Dec 2018 22:12:26 +0000 (22:12 +0000)] 
chmem: add initilizer [clang]

warning: use of GNU empty initializer extension [-Wgnu-empty-initializer]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
6 years agolibsmartcols: remove extra ';' outside of a function [-Wextra-semi]
Sami Kerola [Thu, 13 Dec 2018 21:55:02 +0000 (21:55 +0000)] 
libsmartcols: remove extra ';' outside of a function [-Wextra-semi]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
6 years agoMerge branch 'master' of https://github.com/kvanals/util-linux
Karel Zak [Wed, 2 Jan 2019 13:20:21 +0000 (14:20 +0100)] 
Merge branch 'master' of https://github.com/kvanals/util-linux

* 'master' of https://github.com/kvanals/util-linux:
  Removed BlueStore VERSION information as it is gibberish
  Updated BlueStore expected result
  Added BlueStore test image

6 years agoRemoved BlueStore VERSION information as it is gibberish
Kenneth Van Alstyne [Tue, 18 Dec 2018 02:21:32 +0000 (20:21 -0600)] 
Removed BlueStore VERSION information as it is gibberish

6 years agoRemove duplicate entry for reset-env from usage
John W Higgins [Tue, 18 Dec 2018 01:11:44 +0000 (17:11 -0800)] 
Remove duplicate entry for reset-env from usage

I assume the second entry was not desired in the original commit. Line 153-154 would appear to be a duplicate

6 years agoUpdated BlueStore expected result
Kenneth Van Alstyne [Mon, 17 Dec 2018 18:07:14 +0000 (12:07 -0600)] 
Updated BlueStore expected result

6 years agoAdded BlueStore test image
Kenneth Van Alstyne [Mon, 17 Dec 2018 17:05:24 +0000 (11:05 -0600)] 
Added BlueStore test image

6 years agolibblkid: (bluestore) terminate magic strings array
Karel Zak [Mon, 17 Dec 2018 10:05:23 +0000 (11:05 +0100)] 
libblkid: (bluestore) terminate magic strings array

Signed-off-by: Karel Zak <kzak@redhat.com>
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>