]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
5 years agohardlink: make code more readable
Karel Zak [Mon, 11 Feb 2019 12:25:04 +0000 (13:25 +0100)] 
hardlink: make code more readable

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agohardlink: cleanup global variables
Karel Zak [Mon, 11 Feb 2019 12:18:35 +0000 (13:18 +0100)] 
hardlink: cleanup global variables

* remove NAMELEN, use PATH_MAX
* mark global variables as static
* move all global variables to the begin of the code

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agohardlink: remove typedefs
Karel Zak [Mon, 11 Feb 2019 12:00:18 +0000 (13:00 +0100)] 
hardlink: remove typedefs

- remove typedefs
- use long names for structs

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agotests: (hardlink) update summary output
Karel Zak [Mon, 11 Feb 2019 09:37:09 +0000 (10:37 +0100)] 
tests: (hardlink) update summary output

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolsblk: use ID_SCSI_SERIAL when available
Sven Wiltink [Fri, 8 Feb 2019 09:53:21 +0000 (10:53 +0100)] 
lsblk: use ID_SCSI_SERIAL when available

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agohardlink: cleanup error messages, use xalloc.h
Karel Zak [Wed, 6 Feb 2019 16:21:36 +0000 (17:21 +0100)] 
hardlink: cleanup error messages, use xalloc.h

- do not use magical doexit(), just use err()
- print summary on exit

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agohardlink: cleanup verbose and warning messages
Karel Zak [Wed, 6 Feb 2019 16:13:08 +0000 (17:13 +0100)] 
hardlink: cleanup verbose and warning messages

- use warn()
- use stdout rather than stderr

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agohardlink: (man) add AVAILABILITY
Karel Zak [Wed, 6 Feb 2019 13:37:34 +0000 (14:37 +0100)] 
hardlink: (man) add AVAILABILITY

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoMerge branch 'hardlink' of https://github.com/rudimeier/util-linux into hardlink
Karel Zak [Wed, 6 Feb 2019 12:55:20 +0000 (13:55 +0100)] 
Merge branch 'hardlink' of https://github.com/rudimeier/util-linux into hardlink

* 'hardlink' of https://github.com/rudimeier/util-linux: (25 commits)
  hardlink: add first simple tests
  hardlink: util-linux usage
  hardlink: fix compiler warnings
  hardlink: style indentations and license header
  hardlink: enable build with and without pcre2
  fixes for the fixes
  temporal fix before re-patch (updates from Fedora repo)
  Update hardlink.1
  Fixed version number, added changelog about Todd Lewis' patch
  exclude files via pcre
  Fixed 32 bit build with gcc7 (RH Bugzilla ID 1422989)
  spec file reflects the atomic hardlinking patch; removed cleaning buildroot (redundant); update FSF address at .c source file
  Revert "spec file reflects the atomic hardlinking patch; removed cleaning buildroot (redundant); current FSF address at .c source file"
  spec file reflects the atomic hardlinking patch; removed cleaning buildroot (redundant); current FSF address at .c source file
  Mention -f option in the man page
  do not allow to hardlink files across filesystems by default (#786719) (use -f option to override)
  fix possible buffer overflows, integer overflows, update man page
  fix URL and remove mmap() (#676962, #672917)
  - update docs to describe highest verbosity -vv option (#210816) - use dist Resolves: 210816
  mostly spec cleanup
  ...

5 years agomount: Do not call mnt_pretty_path() on net file systems.
Stanislav Brabec [Tue, 5 Feb 2019 23:07:54 +0000 (00:07 +0100)] 
mount: Do not call mnt_pretty_path() on net file systems.

Calling mnt_pretty_path() on network file systems can cause mangling of
the output:
root# mount | grep nfs
nfs.example.com:/home on /home type nfs4 ...
root# mkdir -p nfs.example.com:/home
root# mount | grep nfs
/root/nfs.example.com:/home on /home type nfs4 ...

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
5 years agocol: improve error message, update regression test
Karel Zak [Tue, 5 Feb 2019 17:07:26 +0000 (18:07 +0100)] 
col: improve error message, update regression test

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agodocs: add col(1) to TODO
Karel Zak [Tue, 5 Feb 2019 11:13:46 +0000 (12:13 +0100)] 
docs: add col(1) to TODO

Addresses: https://github.com/karelzak/util-linux/issues/749
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agocol: make flush_line() a little bit robust
Karel Zak [Tue, 5 Feb 2019 11:06:00 +0000 (12:06 +0100)] 
col: make flush_line() a little bit robust

The code is horrible. The core of the problem are signed integers
and no check for the limits.

This patch fixes c->c_column = cur_col; where c_column is "short"
and "cur_col" is int. Let's use "int" for all the variables. It's
really not perfect as for bigger lines it can segfault again...

The patch also removes some unnecessary static variables.

Addresses: https://github.com/karelzak/util-linux/issues/749
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoMerge branch 'patch-1' of https://github.com/edupont/util-linux
Karel Zak [Tue, 5 Feb 2019 10:09:02 +0000 (11:09 +0100)] 
Merge branch 'patch-1' of https://github.com/edupont/util-linux

* 'patch-1' of https://github.com/edupont/util-linux:
  Typo in configuration help

5 years agoMerge branch 'mount-nosuid' of https://github.com/Lekensteyn/util-linux
Karel Zak [Tue, 5 Feb 2019 10:07:32 +0000 (11:07 +0100)] 
Merge branch 'mount-nosuid' of https://github.com/Lekensteyn/util-linux

* 'mount-nosuid' of https://github.com/Lekensteyn/util-linux:
  mount.8: clarify (no)suid behavior on file capabilities

5 years agolibfdisk: (gpt) add HiFive Unleashed bootloader partition UUIDs
Icenowy Zheng [Thu, 24 Jan 2019 10:33:34 +0000 (18:33 +0800)] 
libfdisk: (gpt) add HiFive Unleashed bootloader partition UUIDs

The HiFive Unleashed SBC's bootloader seeks for GPT partitions with
specific UUID for loading the next stage bootloader (ZSBL loads FSBL,
and FSBL loads BBL).

Add these partition type UUIDs.

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
5 years agocal: use standout mode on monochrome terminals
Karel Zak [Mon, 4 Feb 2019 13:16:11 +0000 (14:16 +0100)] 
cal: use standout mode on monochrome terminals

The function colors_init() checks for colors, it means it fails
on monochrome terminals, but cal(1) in this case still need to
highlight the current day.

Reported-by: Nuno Silva <nunojsilva@ist.utl.pt>
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolib/colors: force to "never" mode on non-terminal output
Karel Zak [Mon, 4 Feb 2019 13:14:37 +0000 (14:14 +0100)] 
lib/colors: force to "never" mode on non-terminal output

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoTypo in configuration help
edupont [Fri, 1 Feb 2019 21:57:34 +0000 (22:57 +0100)] 
Typo in configuration help

5 years agomount.8: clarify (no)suid behavior on file capabilities
Peter Wu [Fri, 1 Feb 2019 14:40:53 +0000 (15:40 +0100)] 
mount.8: clarify (no)suid behavior on file capabilities

Clarify that the nosuid option also affects file capabilities and that
it only limits execution of programs. (setgid on directories still
inherit the group regardless of the nosuid option.) The new text is
taken from the mount(2) manual page from the man-pages project.

Addresses: https://github.com/karelzak/util-linux/issues/482
Signed-off-by: Peter Wu <peter@lekensteyn.nl>
5 years agosfdisk: fix logical partition resize when start specified
Karel Zak [Thu, 31 Jan 2019 13:16:42 +0000 (14:16 +0100)] 
sfdisk: fix logical partition resize when start specified

Addresses: https://github.com/karelzak/util-linux/issues/745
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agologger: (man) add info about rewrite and authors
Karel Zak [Tue, 29 Jan 2019 14:59:41 +0000 (15:59 +0100)] 
logger: (man) add info about rewrite and authors

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agologger: (man) make more obvious that --server/socket is required
Karel Zak [Tue, 29 Jan 2019 14:44:13 +0000 (15:44 +0100)] 
logger: (man) make more obvious that --server/socket is required

The options --tcp/udp specify only how, but no where.

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agobuild-sys: fix crypt() detection without -lcrypt
Johannes Nixdorf [Tue, 22 Jan 2019 18:17:55 +0000 (19:17 +0100)] 
build-sys: fix crypt() detection without -lcrypt

The check tested whether code using crypt() links without -lcrypt, but
didn't set have_crypt to yes if it succeeded.

This fixes the check erroneously failing when compiling against musl
libc.

Signed-off-by: Johannes Nixdorf <mixi@shadowice.org>
5 years agologger: concatenate multiple lines of MESSAGE into a single field.
Karel Zak [Wed, 23 Jan 2019 10:41:43 +0000 (11:41 +0100)] 
logger: concatenate multiple lines of MESSAGE into a single field.

this is deemed a useful special case since journalctl will only show
either the first or last element of the message array if the field
appears multiple times.

Based on patch from: Kjetil Torgrim Homme <kjetil.homme@redpill-linpro.com>
https://github.com/karelzak/util-linux/pull/743

Addresses: https://github.com/karelzak/util-linux/issues/742
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolibblkid: remove dependence on libuuid
Karel Zak [Tue, 22 Jan 2019 11:33:19 +0000 (12:33 +0100)] 
libblkid: remove dependence on libuuid

Currently we use libuuid to print UUID only. This code is possible to replace
by one snprintf(). It seems better to duplicate this one snprintf than force
all distros to keep libuuid together with libblkid.

Note, this scenario has been already supported on --disable-libuuid.

Reported-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agosetarch: don't return address of automatic variable
Andreas Schwab [Sat, 19 Jan 2019 22:18:16 +0000 (23:18 +0100)] 
setarch: don't return address of automatic variable

On architectures without special personalities setarch uses the contents
of a local variable with automatic storage duration after return from
the function, causing it to report a spurious error.

$ setarch m68k
setarch: Kernel cannot set architecture to m68k

Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
5 years agolosetup: update an error message
Jeffrey Ferreira [Tue, 22 Jan 2019 10:56:16 +0000 (11:56 +0100)] 
losetup: update an error message

Update an error message to add --partscan to the list of options
only allowed during loop device setup.

Signed-off-by: Jeffrey Ferreira <jeffpferreira@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolosetup: properly use --sector-size when create a new device
Karel Zak [Tue, 22 Jan 2019 10:50:20 +0000 (11:50 +0100)] 
losetup: properly use --sector-size when create a new device

The --partscan functionality depends on sector size. Make sure
sector size is set before we force kernel to scan the device for
partitions. For example:

 losetup -f loopfile --sector-size 4KiB --partscan --show

where 'loopfile' contains GPT with 4096 sectors.

Reported-by: Jeffrey Ferreira <jeffpferreira@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolib/loopdev: set blocksize when create a new device
Karel Zak [Tue, 22 Jan 2019 10:37:35 +0000 (11:37 +0100)] 
lib/loopdev: set blocksize when create a new device

The partition scanner in kernel depends on blocksize. We need to set
the blocksize before we call LOOP_SET_STATUS64 (this ioctl triggers
the scanner).

This patch extends the internal API to save blocksize into loopdev
context to be usable later for loopcxt_setup_device().

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolib/loopdev: differentiate between setter()s and ioctl calls
Karel Zak [Tue, 22 Jan 2019 10:12:42 +0000 (11:12 +0100)] 
lib/loopdev: differentiate between setter()s and ioctl calls

Now the internal API uses loopcxt_set_...() to set context variables
as well as to call ioctls. This patch introduces loopcxt_ioctl_...()
to makes things more obvious to readers.

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoswapon: be more explicit about BTRFS
Karel Zak [Tue, 22 Jan 2019 09:13:54 +0000 (10:13 +0100)] 
swapon: be more explicit about BTRFS

It seems nocow and nodatasum attributes are required.
See btrfs_swap_activate() in  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ed46ff3d423780fa5173b38a844bf0fdb210a2a7

Addresses: https://github.com/karelzak/util-linux/issues/633
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoswapon: rewrite section about swapfiles
Karel Zak [Tue, 22 Jan 2019 09:02:17 +0000 (10:02 +0100)] 
swapon: rewrite section about swapfiles

* don't duplicate info on two places -- let's keep only small note
  in mkswap(8) man page, suggest to read swapon(8) man page

* add info about kernel versions for XFS and Btrfs swapfiles support

* use subsection in the NOTES

Addresses: https://github.com/karelzak/util-linux/issues/633
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoswapon: (man) iomap for swapfile is already supported by kernel
Karel Zak [Mon, 21 Jan 2019 16:01:25 +0000 (17:01 +0100)] 
swapon: (man) iomap for swapfile is already supported by kernel

... since commit 67482129cdabf7cede1301d2415ef4f0156d35cd (Linus'
tree).

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoswapon: (man) cleanup note about holes
Karel Zak [Mon, 21 Jan 2019 11:44:49 +0000 (12:44 +0100)] 
swapon: (man) cleanup note about holes

Addresses: https://github.com/karelzak/util-linux/issues/633
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agomount: (man) add note about --all to remount desc
Karel Zak [Mon, 21 Jan 2019 10:56:27 +0000 (11:56 +0100)] 
mount: (man) add note about --all to remount desc

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolosetup: use offset in warn_size() calculation
Karel Zak [Fri, 18 Jan 2019 11:13:12 +0000 (12:13 +0100)] 
losetup: use offset in warn_size() calculation

 # dd if=/dev/urandom of=dummy bs=513 count=1 2>/dev/null

 # losetup -f --show --offset 1 dummy
 /dev/loop0
 losetup: dummy: Warning: file does not fit into a 512-byte sector; the end of the file will be ignore

The warning is bogus as with offset the size of the file fits into
512-byte sector. Simple test that all is right:

 # dd if=dummy bs=1 skip=1 2>/dev/null | sha256sum - /dev/loop0
 da2ed0ade6ea518a802cd8a7a3c01c408ad8699ef6856b0b01f92b867d4ba9b5  -
 da2ed0ade6ea518a802cd8a7a3c01c408ad8699ef6856b0b01f92b867d4ba9b5  /dev/loop0

Addresses: https://github.com/karelzak/util-linux/issues/722
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolibfdisk: add comment to fdisk_set_first_lba()
Karel Zak [Fri, 18 Jan 2019 10:38:57 +0000 (11:38 +0100)] 
libfdisk: add comment to fdisk_set_first_lba()

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agodocs: update TODO
Karel Zak [Fri, 18 Jan 2019 10:14:38 +0000 (11:14 +0100)] 
docs: update TODO

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agowhereis: search in /(s)bin before /usr/lib
Karel Zak [Thu, 17 Jan 2019 10:19:27 +0000 (11:19 +0100)] 
whereis: search in /(s)bin before /usr/lib

Addresses: https://github.com/karelzak/util-linux/issues/741
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolibmount: add support for MS_REMOUNT on --all
Karel Zak [Wed, 16 Jan 2019 14:00:07 +0000 (15:00 +0100)] 
libmount: add support for MS_REMOUNT on --all

This patch add to support for remount-all operation to
libmount and mount(8).

For example:
mount --all -o remount,ro -t vfat

to remount read-only all VFAT filesystems.

Addresses: https://github.com/karelzak/util-linux/issues/589
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agofsck.cramfs: fix utimes() usage
Karel Zak [Tue, 15 Jan 2019 10:44:25 +0000 (11:44 +0100)] 
fsck.cramfs: fix utimes() usage

The bug has been introduced by untested commit ad7ac3d598e2d541d9eba70975e68dff7e52c7d9 ;-(

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agobuild-sys: use REALTIME_LIBS for hwclock due to monotonic.c
Karel Zak [Mon, 14 Jan 2019 11:18:35 +0000 (12:18 +0100)] 
build-sys: use REALTIME_LIBS for hwclock due to monotonic.c

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoMerge branch 'time-fixes' of https://github.com/kerolasa/util-linux
Karel Zak [Mon, 14 Jan 2019 11:04:04 +0000 (12:04 +0100)] 
Merge branch 'time-fixes' of https://github.com/kerolasa/util-linux

* 'time-fixes' of https://github.com/kerolasa/util-linux:
  fsck.cramfs: use utimes() instead of utime() that is obsolete
  hwclock: use monotonic time to measure how long setting time takes
  include: add indirect monotonic clock id specifier
  timeutils: match today day and this year correctly

5 years agoMerge branch 'asan-fixes' of https://github.com/kerolasa/util-linux
Karel Zak [Mon, 14 Jan 2019 10:58:06 +0000 (11:58 +0100)] 
Merge branch 'asan-fixes' of https://github.com/kerolasa/util-linux

5 years agoreadprofile: check input file is not empty [asan]
Sami Kerola [Sun, 13 Jan 2019 19:59:40 +0000 (19:59 +0000)] 
readprofile: check input file is not empty [asan]

Addresses: https://github.com/karelzak/util-linux/issues/717
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 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>
5 years agobash-completion: umount support relative path and ~ as home shorthands
Sami Kerola [Sat, 12 Jan 2019 11:14:15 +0000 (11:14 +0000)] 
bash-completion: umount support relative path and ~ as home shorthands

Addresses: https://github.com/karelzak/util-linux/issues/703
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agofsck.cramfs: use utimes() instead of utime() that is obsolete
Sami Kerola [Mon, 7 Jan 2019 22:23:04 +0000 (22:23 +0000)] 
fsck.cramfs: use utimes() instead of utime() that is obsolete

Reference: http://man7.org/linux/man-pages/man3/utime.3p.html#APPLICATION_USAGE
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agohwclock: use monotonic time to measure how long setting time takes
Sami Kerola [Mon, 7 Jan 2019 21:34:11 +0000 (21:34 +0000)] 
hwclock: use monotonic time to measure how long setting time takes

Earlier gettimeofday() was affected by discontinuous jumps.  Measuring how
long time it takes to set time using function that effected by the very
thing being measured makes head spin.  Lets make this less confusing with
monotonic clock that ticks on without jumps.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agoinclude: add indirect monotonic clock id specifier
Sami Kerola [Mon, 7 Jan 2019 21:31:34 +0000 (21:31 +0000)] 
include: add indirect monotonic clock id specifier

Avoid repeated ifdef checks in code by adding a project specific
preprocessor definition.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agotimeutils: match today day and this year correctly
Sami Kerola [Sat, 5 Jan 2019 21:32:23 +0000 (21:32 +0000)] 
timeutils: match today day and this year correctly

Assumption all years since 1970 have been exactly 365 days long has it's
problems when leap years happen.  Lets use struct tm fields that are
provided by localtime_r(), making year and day to be correctly compared even
when it's late new years eve somewhere else than UTC-0.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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

5 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

5 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

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

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

5 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>
5 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

5 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>
5 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>
5 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>
5 years agoFinished up BlueStore support
Kenneth Van Alstyne [Fri, 14 Dec 2018 20:32:13 +0000 (14:32 -0600)] 
Finished up BlueStore support

5 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

5 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

5 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>
5 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>
5 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>
5 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

5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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

5 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>
5 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>
5 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>
5 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>
5 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>
5 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>
5 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>