]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
7 years agohwclock: rename --debug option to --verbose
J William Piggott [Sun, 24 Dec 2017 20:37:36 +0000 (15:37 -0500)] 
hwclock: rename --debug option to --verbose

Warn on --debug; do not fallthrough because
the message is lost in the verbose output.

Coauthored-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: J William Piggott <elseifthen@gmx.com>
7 years agocal: update man page
J William Piggott [Tue, 16 Jan 2018 18:08:31 +0000 (13:08 -0500)] 
cal: update man page

Update cal.1 with the new options --reform and --iso.

Also add information about the calendar systems used and
the difference between the --julian option and the Julian
calendar system.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
7 years agocal: add option to set Gregorian reform date
J William Piggott [Tue, 16 Jan 2018 11:19:00 +0000 (06:19 -0500)] 
cal: add option to set Gregorian reform date

Create the new option: --reform <1752|gregorian|iso|julian>

This adds the capability to display either the proleptic Gregorian or
the Julian calendar systems exclusively.

Also create the option --iso as alias of --reform=gregorian.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
7 years agocal: move REFORMATION_YEAR to control struct
J William Piggott [Mon, 15 Jan 2018 16:06:36 +0000 (11:06 -0500)] 
cal: move REFORMATION_YEAR to control struct

Signed-off-by: J William Piggott <elseifthen@gmx.com>
7 years agoinclude/debug: improve debug message
Karel Zak [Fri, 12 Jan 2018 12:46:49 +0000 (13:46 +0100)] 
include/debug: improve debug message

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agoinclude/debug: print info when addresses suppressed
Karel Zak [Fri, 12 Jan 2018 12:37:05 +0000 (13:37 +0100)] 
include/debug: print info when addresses suppressed

Suggested-by: Peter Cordes <peter@cordes.ca>
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agosfdisk: cleanup shortcuts in man page too
Karel Zak [Fri, 12 Jan 2018 11:38:58 +0000 (12:38 +0100)] 
sfdisk: cleanup shortcuts in man page too

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolibfdisk: (script) be consistent in code with types
Karel Zak [Fri, 12 Jan 2018 11:04:16 +0000 (12:04 +0100)] 
libfdisk: (script) be consistent in code with types

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agoMerge branch 'mbsencode' of https://github.com/yontalcar/util-linux
Karel Zak [Fri, 12 Jan 2018 10:59:22 +0000 (11:59 +0100)] 
Merge branch 'mbsencode' of https://github.com/yontalcar/util-linux

* 'mbsencode' of https://github.com/yontalcar/util-linux:
  tests: mark mbsencode as KNOWN_FAIL
  tests: mbsencode - test for HAVE_WIDECHAR
  lib/mbsalign: Fix escaping nonprintable multibyte characters
  tests: mbsencode - removed emoji, added control unicode character
  tests: add tests for encode functions from lib/mbsalign.c
  lib/mbsalign: escape "\x" when HAVE_WIDECHAR not defined

7 years agoinclude/debug: don't print pointer address for SUID programs
Karel Zak [Fri, 12 Jan 2018 10:01:26 +0000 (11:01 +0100)] 
include/debug: don't print pointer address for SUID programs

* introduce new flag __UL_DEBUG_FL_NOADDR to suppress pointer address printing

* use __UL_DEBUG_FL_NOADDR when SUID

* move ul_debugobj() to debugobj.h, and require UL_DEBUG_CURRENT_MASK
  to provide access to the current mask from ul_debugobj(). It's better
  than modify all ul_debugobj() calls and use the global mask as
  argument.

* remove never used UL_DEBUG_DEFINE_FLAG

Reported-by: halfdog <me@halfdog.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolibfdisk: allow to start freespace for zero
Karel Zak [Thu, 11 Jan 2018 14:18:00 +0000 (15:18 +0100)] 
libfdisk: allow to start freespace for zero

This is necessary for disk labels like SUN where whole disk is possible
to address by partitions.

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolibfdisk: (sun) fix n-1 bug and whole-disk
Karel Zak [Thu, 11 Jan 2018 13:23:57 +0000 (14:23 +0100)] 
libfdisk: (sun) fix n-1 bug and whole-disk

* set whole_disk variable if SUN_TAG_WHOLEDISK specified
* fix N-1 bug in add new partition according to template (script)

Addresses: https://github.com/karelzak/util-linux/issues/555
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agotests: mark mbsencode as KNOWN_FAIL
Vaclav Dolezal [Thu, 11 Jan 2018 13:19:23 +0000 (14:19 +0100)] 
tests: mark mbsencode as KNOWN_FAIL

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
7 years agotests: mbsencode - test for HAVE_WIDECHAR
Vaclav Dolezal [Thu, 11 Jan 2018 10:11:31 +0000 (11:11 +0100)] 
tests: mbsencode - test for HAVE_WIDECHAR

Test only safe-ascii as it should behave in the same way.

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
7 years agolib/mbsalign: Fix escaping nonprintable multibyte characters
Vaclav Dolezal [Thu, 11 Jan 2018 09:42:22 +0000 (10:42 +0100)] 
lib/mbsalign: Fix escaping nonprintable multibyte characters

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
7 years agotests: mbsencode - removed emoji, added control unicode character
Vaclav Dolezal [Thu, 11 Jan 2018 09:38:43 +0000 (10:38 +0100)] 
tests: mbsencode - removed emoji, added control unicode character

Emojis are apparently too recent to be reliably recognised as printable
on test machines.

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
7 years agoMerge branch 'fixes' of https://github.com/rudimeier/util-linux
Karel Zak [Thu, 11 Jan 2018 09:09:48 +0000 (10:09 +0100)] 
Merge branch 'fixes' of https://github.com/rudimeier/util-linux

7 years agolibblkid: Add support for stratis
Tony Asleson [Tue, 9 Jan 2018 21:08:12 +0000 (15:08 -0600)] 
libblkid: Add support for stratis

Initial support for stratis, ref.
https://github.com/stratis-storage

[kzak@redhat.com: - remove C++ comment]

Signed-off-by: Tony Asleson <tasleson@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agotests: add tests for encode functions from lib/mbsalign.c
Vaclav Dolezal [Thu, 21 Dec 2017 14:10:15 +0000 (15:10 +0100)] 
tests: add tests for encode functions from lib/mbsalign.c

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
7 years agomisc: fix printf i386 compiler warnings
Ruediger Meier [Fri, 1 Dec 2017 19:57:24 +0000 (20:57 +0100)] 
misc: fix printf i386 compiler warnings

sys-utils/lsns.c:683:2: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘ino_t’ [-Werror=format=]

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
7 years agolibfdisk: (script) support R (RAID) and V (LVM) shortcuts
Karel Zak [Tue, 9 Jan 2018 11:12:50 +0000 (12:12 +0100)] 
libfdisk: (script) support R (RAID) and V (LVM) shortcuts

Addresses: https://github.com/karelzak/util-linux/issues/560
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolibfdisk: (gpt) add VMware specific UUIDs
Karel Zak [Mon, 8 Jan 2018 11:43:22 +0000 (12:43 +0100)] 
libfdisk: (gpt) add VMware specific UUIDs

Addresses: https://github.com/karelzak/util-linux/issues/559
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolibmount: fix mnt_table_is_fs_mounted() for rbind
Karel Zak [Wed, 3 Jan 2018 12:59:59 +0000 (13:59 +0100)] 
libmount: fix mnt_table_is_fs_mounted() for rbind

There is no difference between "bind" and "rbind" if we want to FS
root to search for the FS in mountinfo file.

fstab:

 /dev/sdc1       /mnt/foo        xfs     defaults        0 0
 /mnt/foo        /mnt/test       none    rw,rbind        0 0

use -a more than once:

  mount -a
  mount -a

/proc/mounts (the current result):

 /dev/sdc1 /mnt/foo xfs rw,relatime,attr2,inode64,noquota 0 0
 /dev/sdc1 /mnt/test xfs rw,relatime,attr2,inode64,noquota 0 0
 /dev/sdc1 /mnt/test xfs rw,relatime,attr2,inode64,noquota 0 0
 /dev/sdc1 /mnt/foo xfs rw,relatime,attr2,inode64,noquota 0 0

expected (fixed version) result:

 /dev/sdc1 /mnt/foo xfs rw,relatime,attr2,inode64,noquota 0 0
 /dev/sdc1 /mnt/test xfs rw,relatime,attr2,inode64,noquota 0 0

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1528959
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolibfdisk: (dos) fix max heads
Karel Zak [Tue, 2 Jan 2018 15:50:31 +0000 (16:50 +0100)] 
libfdisk: (dos) fix max heads

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolibfdisk: extend API to provide label specific geometry ranges
Karel Zak [Tue, 2 Jan 2018 15:43:22 +0000 (16:43 +0100)] 
libfdisk: extend API to provide label specific geometry ranges

Now fdisk provides DOS specific geometry ranges in expert menu.

Addresses: https://github.com/karelzak/util-linux/issues/556
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agortcwake: wait stdin to settle down before entering a system sleep
Sami Kerola [Sun, 3 Dec 2017 15:43:25 +0000 (15:43 +0000)] 
rtcwake: wait stdin to settle down before entering a system sleep

This can delay entering to system sleep up to 0.28 seconds while discarding
input, when stdin is interactive device.

[kzak@redhat.com: - add note to the man page]

Reference: https://github.com/karelzak/util-linux/issues/527
See-also: a85c39013491713ac0d9e24fd0f07b4fabdcfc17
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agosfdisk: wait before re-read
Karel Zak [Tue, 2 Jan 2018 13:48:01 +0000 (14:48 +0100)] 
sfdisk: wait before re-read

The original old (v2.13) fdisk had sleep(2) beany ideafore re-read ioctl. It
seems overkill, but short sleep is probably a good idea as we call
re-read on sfdisk start and at the end. It's possible that sfdisk is
too fast and the initial re-read is not gone yet.

It would be nice to have something more elegant than sleep, any idea?

Addresses: https://github.com/karelzak/util-linux/issues/557
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agoMerge branch 'patch-1' of https://github.com/kenyon/util-linux
Karel Zak [Tue, 2 Jan 2018 13:06:40 +0000 (14:06 +0100)] 
Merge branch 'patch-1' of https://github.com/kenyon/util-linux

7 years agoMerge branch 'master' of https://github.com/yurchor/util-linux
Karel Zak [Tue, 2 Jan 2018 13:05:37 +0000 (14:05 +0100)] 
Merge branch 'master' of https://github.com/yurchor/util-linux

7 years agolib/sha1: use proper WORDS_BIGENDIAN macro
Karel Zak [Tue, 2 Jan 2018 10:08:03 +0000 (11:08 +0100)] 
lib/sha1: use proper WORDS_BIGENDIAN macro

The original code uses BYTE_ORDER, but we use WORDS_BIGENDIAN in
utl-linux.

Reported-by: Andreas Schwab <schwab@linux-m68k.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agoFix minor typo: priorty -> priority
Yuri Chornoivan [Sun, 31 Dec 2017 11:07:43 +0000 (13:07 +0200)] 
Fix minor typo: priorty -> priority

7 years agorename.1: fix typo, where -> were
Kenyon Ralph [Sat, 23 Dec 2017 21:44:34 +0000 (13:44 -0800)] 
rename.1: fix typo, where -> were

7 years agolib/mbsalign: escape "\x" when HAVE_WIDECHAR not defined
Vaclav Dolezal [Thu, 21 Dec 2017 14:23:56 +0000 (15:23 +0100)] 
lib/mbsalign: escape "\x" when HAVE_WIDECHAR not defined

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
7 years agolib/mbsalign: encode \x to \xecx
Karel Zak [Wed, 20 Dec 2017 12:01:43 +0000 (13:01 +0100)] 
lib/mbsalign: encode \x to \xecx

Don't encode stand alone '\', our encoding is about \x<hex>, so we
need to care about \x prefix only.

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolibfdisk: (gpt) use fdisk_warn() for failed name setting
Karel Zak [Wed, 20 Dec 2017 11:31:10 +0000 (12:31 +0100)] 
libfdisk: (gpt) use fdisk_warn() for failed name setting

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agoMerge branch 'gpt-part-name' of https://github.com/yontalcar/util-linux
Karel Zak [Wed, 20 Dec 2017 11:29:16 +0000 (12:29 +0100)] 
Merge branch 'gpt-part-name' of https://github.com/yontalcar/util-linux

* 'gpt-part-name' of https://github.com/yontalcar/util-linux:
  libfdisk: return bytes processed from gpt_entry_set_name(), process rc
  libfdisk: allocate enough bytes for ucs2 to utf8 encoding
  libfdisk: gpt: properly encode string on rename
  lib/mbsalign: encode backslash to prevent ambiguity

7 years agotests: don't use mount.<type> helpers in mount-by-pattern tests
Karel Zak [Tue, 19 Dec 2017 12:46:35 +0000 (13:46 +0100)] 
tests: don't use mount.<type> helpers in mount-by-pattern tests

The test behavior is fragile if depends on external helpers. Let's
keep it based on mount(2) only. The test will be faster too.

Note that "mount -t <pattern>" does not behaviour as expected with
helpers. We need to try another helper if the current one ends with
status=1 (waitpid()). Now it returns status from the first helper.

Reported-by: Ruediger Meier <sweet_f_a@gmx.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolibfdisk: return bytes processed from gpt_entry_set_name(), process rc
Vaclav Dolezal [Tue, 19 Dec 2017 09:39:19 +0000 (10:39 +0100)] 
libfdisk: return bytes processed from gpt_entry_set_name(), process rc

Made gpt_entry_set_name() return number of utf8 bytes processed on
success, so info message about change can be accurate.

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
7 years agolibfdisk: allocate enough bytes for ucs2 to utf8 encoding
Vaclav Dolezal [Thu, 14 Dec 2017 14:39:42 +0000 (15:39 +0100)] 
libfdisk: allocate enough bytes for ucs2 to utf8 encoding

Allocate 3*number_of_ucs2_characters bytes for utf8 output.

Also as we are using calloc there's no need to write terminating null
byte.

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
7 years agolibfdisk: gpt: properly encode string on rename
Vaclav Dolezal [Wed, 20 Sep 2017 13:50:37 +0000 (15:50 +0200)] 
libfdisk: gpt: properly encode string on rename

GPT partition name entry should be recorded as little endian UCS2, so I have
written proper conversion (assuming UTF8 input).

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
7 years agobuild-sys: don't check for swapon() number of arguments
Karel Zak [Mon, 18 Dec 2017 12:57:20 +0000 (13:57 +0100)] 
build-sys: don't check for swapon() number of arguments

The syscall swapon() with two arguments is supported since Linux 1.3.2
and it's really long time ago... Let's assume that all libc header files
have been already fixed.

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolibblkid: (bcache) cleanup magic string definition
Karel Zak [Mon, 18 Dec 2017 12:03:46 +0000 (13:03 +0100)] 
libblkid: (bcache) cleanup magic string definition

Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agocal: fix multi-byte comment, explain in better way
Karel Zak [Mon, 18 Dec 2017 11:44:03 +0000 (12:44 +0100)] 
cal: fix multi-byte comment, explain in better way

On Sun, Dec 17, 2017 at 07:47:49PM -0500, J William Piggott wrote
> * it contains multi-byte characters (which is what drew me to reading it).
> * it truncates one very important piece of the formula: ". . . (mod 7)."
> * it explains the values for 'e', but there is no 'e' in the code.
> * it doesn't include a row resolving 'e' in the table, so it is not
>    obvious what it relates to in the code.
> * without citing it as an external reference, the comment language is confusing.

Co-Author: J William Piggott <elseifthen@gmx.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agowhereis: fix typo in debug message
Karel Zak [Thu, 14 Dec 2017 14:52:57 +0000 (15:52 +0100)] 
whereis: fix typo in debug message

Reported-by: Matthew White <mehw.is.me@inventati.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agoRevert "cal: simplify leap year rule"
Karel Zak [Thu, 14 Dec 2017 12:19:08 +0000 (13:19 +0100)] 
Revert "cal: simplify leap year rule"

It was mistake, we use extra rule for date < 1752 from the beginning
and another calculations depends on this.

This reverts commit b9bd8dc267a71611859496bff29e329868273714.

7 years agocal: explain magic values for day of week calculation
Karel Zak [Wed, 13 Dec 2017 18:09:56 +0000 (19:09 +0100)] 
cal: explain magic values for day of week calculation

Based on BERNDT E.SCHWERDTFEGER papers.

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agofincore: fix a typo in fincore.1
Masatake YAMATO [Tue, 12 Dec 2017 07:16:45 +0000 (16:16 +0900)] 
fincore: fix a typo in fincore.1

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
7 years agotests: update libsmartcols/title
Karel Zak [Wed, 13 Dec 2017 11:57:22 +0000 (12:57 +0100)] 
tests: update libsmartcols/title

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolibsmartcols: don't add blank padding after left aligned title
Karel Zak [Tue, 12 Dec 2017 12:19:36 +0000 (13:19 +0100)] 
libsmartcols: don't add blank padding after left aligned title

Let's use the same semantic for the title as for the last column in
the table. If aligned on left, table is not "maxout" and title padding
symbol is undefined (or blank) then keep title as short as possible.

Addresses: https://github.com/karelzak/util-linux/issues/549
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agosample-scols-title: add left title without padding
Karel Zak [Tue, 12 Dec 2017 12:16:54 +0000 (13:16 +0100)] 
sample-scols-title: add left title without padding

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agomcookie: properly initialize hash
Karel Zak [Tue, 12 Dec 2017 11:09:13 +0000 (12:09 +0100)] 
mcookie: properly initialize hash

This stupid mistake has been introduced by commit 46ae163a8e5dc8457f8e2828eb53db8e610af275.

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolib/md5: use ul_/UL_ prefix
Karel Zak [Tue, 12 Dec 2017 10:54:08 +0000 (11:54 +0100)] 
lib/md5: use ul_/UL_ prefix

The symbols names are too generic.

Addresses: https://github.com/karelzak/util-linux/issues/548
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolib/sha1: fix indention
Karel Zak [Tue, 12 Dec 2017 10:42:28 +0000 (11:42 +0100)] 
lib/sha1: fix indention

* indent -linux -psl -blf  lib/sha1.c
* manually fix comments

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agotest_sha1: update helper
Karel Zak [Tue, 12 Dec 2017 10:38:17 +0000 (11:38 +0100)] 
test_sha1: update helper

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolib/sha1: use ul_/UL_prefix for symbols
Karel Zak [Tue, 12 Dec 2017 10:29:02 +0000 (11:29 +0100)] 
lib/sha1: use ul_/UL_prefix for symbols

Unfortunately, the symbols are visible in statically compiled libuuid
and the names are too generic.

Addresses: https://github.com/karelzak/util-linux/issues/548
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agoMerge branch '2017wk48' of https://github.com/kerolasa/lelux-utiliteetit
Karel Zak [Mon, 11 Dec 2017 15:03:39 +0000 (16:03 +0100)] 
Merge branch '2017wk48' of https://github.com/kerolasa/lelux-utiliteetit

7 years agodocs: improve setarch(8) manual page
Sami Kerola [Sun, 10 Dec 2017 10:50:32 +0000 (10:50 +0000)] 
docs: improve setarch(8) manual page

Add more information when and why one might want to use various options.

Reviewed-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agolib/timeutils.c: warn format_iso_time() overflow
J William Piggott [Sat, 9 Dec 2017 23:43:29 +0000 (18:43 -0500)] 
lib/timeutils.c: warn format_iso_time() overflow

Print a message when the format_iso_time() buffer is exceeded, because
there is more than one type of failure that returns -1.

Also remove the corresponding message from hwclock.c.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
7 years agolib/timeutils.c:strxxx_iso: do not wrap tm_year
J William Piggott [Sat, 9 Dec 2017 20:05:38 +0000 (15:05 -0500)] 
lib/timeutils.c:strxxx_iso: do not wrap tm_year

Year can wrap when adding the tm struct epoch during iso formatting:
hwclock --utc --noadjfile --predict --date '67768034678844900 seconds'
-2147481749-12-31 23:59:59.000000-05:00

Patched:
hwclock --utc --noadjfile --predict --date '67768034678844900 seconds'
2147485547-12-31 23:59:59.000000-05:00

Comparable to date(1):
date -Ins --date '67768034678844900 seconds'
2147485547-12-31T23:59:59,547886165-0500

Note: the 'seconds' argument is relative to the current time, so
      reaching this max year output is a moving target. The values shown
      above were invalid one second later. They then overflow tm_year
      upon conversion with localtime(3) and friends, which causes them
      to return NULL indicating that an error occurred.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
7 years agolib/timeutils.c:strxxx_iso: test conversion errors
J William Piggott [Sat, 9 Dec 2017 19:40:05 +0000 (14:40 -0500)] 
lib/timeutils.c:strxxx_iso: test conversion errors

Test for libc time conversion errors in ISO time format functions.

hwclock --utc --noadjfile --predict --date '67768034678846520 seconds'
Segmentation fault

Patched:
hwclock --utc --noadjfile --predict --date '67768034678846520 seconds'
hwclock: time 67768036191695381 is out of range.

Comparable to date(1):
date --date '67768034678846520 seconds'
date: time 67768036191695384 is out of range

Signed-off-by: J William Piggott <elseifthen@gmx.com>
7 years agolib/timeutils.c: bug fix Segmentation fault
J William Piggott [Sat, 9 Dec 2017 19:01:33 +0000 (14:01 -0500)] 
lib/timeutils.c: bug fix Segmentation fault

Use reentrant time functions to avoid sending a NULL pointer to
format_iso_time() (and to be reentrant ;). Followup commits test for
errors and tm_year wrapping (illustrated below).

hwclock --utc --noadjfile --predict --date '67768034678849400 seconds'
Segmentation fault

Patched
hwclock --utc --noadjfile --predict --date '67768034678849400 seconds'
-2147481748-01-00 00:10:46.000000-05:00

Signed-off-by: J William Piggott <elseifthen@gmx.com>
7 years agotests: unlocks on failed ts_scsi_debug_init
Karel Zak [Thu, 7 Dec 2017 14:08:29 +0000 (15:08 +0100)] 
tests: unlocks on failed ts_scsi_debug_init

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agotests: don't call tests with races in --parallel
Karel Zak [Thu, 7 Dec 2017 13:41:49 +0000 (14:41 +0100)] 
tests: don't call tests with races in --parallel

Some of the tests have a race by design (=wanted).

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agotests: support multiple locks
Karel Zak [Thu, 7 Dec 2017 13:41:08 +0000 (14:41 +0100)] 
tests: support multiple locks

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agotests: add mdadm locks
Karel Zak [Thu, 7 Dec 2017 11:31:41 +0000 (12:31 +0100)] 
tests: add mdadm locks

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolibblkid: add debug messages when ignore useless devices
Karel Zak [Thu, 7 Dec 2017 11:15:34 +0000 (12:15 +0100)] 
libblkid: add debug messages when ignore useless devices

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolibblkid: Add VDO superblock information into blkid
Sweet Tea Dorminy [Wed, 6 Dec 2017 23:26:59 +0000 (18:26 -0500)] 
libblkid: Add VDO superblock information into blkid

[kzak@redhat.com: - add tests/expected/blkid/low-probe-vdo
                  - enlarge the image (must be > 1024)]

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agotests: use flock to modify fstab
Karel Zak [Wed, 6 Dec 2017 13:38:44 +0000 (14:38 +0100)] 
tests: use flock to modify fstab

Note that for btrfs test we need to use low-level ts_fstab_addline,
because we add multiple lines there.

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agotests: add lock on shared resources (e.g. scsi_debug)
Karel Zak [Wed, 6 Dec 2017 13:21:38 +0000 (14:21 +0100)] 
tests: add lock on shared resources (e.g. scsi_debug)

The patch enables flock for scsi_debug to avoid collision between
tests. The patch also adds ./run.sh --nolocks to disable this feature.

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agosetarch: minor code clean up
Sami Kerola [Sun, 3 Dec 2017 12:51:17 +0000 (12:51 +0000)] 
setarch: minor code clean up

Remove global variable, skip unnecessary comparison, and remove version
printing function when a simple printf() can do the job.  In same go fix
compiler warning.

sys-utils/setarch.c:296:4: warning: null argument where non-null required
(argument 2) [-Wnonnull]
    execl("/bin/bash", NULL);

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agorename: use access(3) to check if a file exists
Sami Kerola [Sun, 3 Dec 2017 12:51:15 +0000 (12:51 +0000)] 
rename: use access(3) to check if a file exists

This is more lightweight than calling stat(3).  In same go add a regression
test to ensure changes like this will not break --no-overwrite option.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agovipw: do not let editor to inherit open file descriptors
Sami Kerola [Sun, 3 Dec 2017 12:51:14 +0000 (12:51 +0000)] 
vipw: do not let editor to inherit open file descriptors

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agologin: add LOGIN_PLAIN_PROMPT to login.defs
Karel Zak [Mon, 4 Dec 2017 11:31:29 +0000 (12:31 +0100)] 
login: add LOGIN_PLAIN_PROMPT to login.defs

We have command line option -H to disable hostname in login prompt.
Unfortunately, in same cases (e.g. telnetd) it's impossible to specify
login(1) command line options due to hardcoded execl()...

This patch introduces LOGIN_PLAIN_PROMPT boolean for /etc/login.defs
to suppress hostname in the prompt.

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolib/mbsalign: encode backslash to prevent ambiguity
Vaclav Dolezal [Fri, 8 Sep 2017 14:36:26 +0000 (16:36 +0200)] 
lib/mbsalign: encode backslash to prevent ambiguity

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
7 years agofallocate: remove typo
Karel Zak [Wed, 29 Nov 2017 14:13:24 +0000 (15:13 +0100)] 
fallocate: remove typo

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agofallocate: dig holes only in data extents
Karel Zak [Wed, 29 Nov 2017 13:26:42 +0000 (14:26 +0100)] 
fallocate: dig holes only in data extents

Based on patch from Vaclav Dolezal <vdolezal@redhat.com>, this
implementation is less invasive.

The patch adds a new while() for pread() call (so diff is mostly code
indention). The pread() is called for a real data only (addressed by
'off' and 'end') and we use SEEK_{DATA,HOLE} before the pread() to
skip already existing holes. The variables 'file_off' and 'file_end'
addresses area in the file as specified on fallocate command line.

Test:

$ truncate -s 10G testfile
$ dd if=/dev/zero of=testfile count=10 bs=1M conv=notrunc

old version:

$ time /usr/bin/fallocate --dig-holes --verbose testfile
testfile: 10 GiB (10737418240 bytes) converted to sparse holes.

real 0m3.013s
user 0m0.700s
sys 0m2.304s

new version:

$ time ./fallocate --dig-holes --verbose testfile
testfile: 10 MiB (10485760 bytes) converted to sparse holes.

real 0m0.026s
user 0m0.002s
sys 0m0.004s

The old version scans all file.

The change has minimal overhead for files without holes.

Addresses: https://github.com/karelzak/util-linux/issues/421
Co-Author: Vaclav Dolezal <vdolezal@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agologin-utils: use free_getlogindefs_data()
Karel Zak [Tue, 28 Nov 2017 13:49:05 +0000 (14:49 +0100)] 
login-utils: use free_getlogindefs_data()

It seems better to deallocate logindefs.conf stuff in long time
running (=waiting) processes like login(1) and su(1).

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agoeject: remove list_speeds() #ifdef CDROM_SELECT_SPEED protection
Sami Kerola [Sun, 26 Nov 2017 17:47:51 +0000 (17:47 +0000)] 
eject: remove list_speeds() #ifdef CDROM_SELECT_SPEED protection

The CDROM_SELECT_SPEED should be available practically everywhere.  Where
the define is missing an error message about path /proc/sys/dev/cdrom/info
cannot be opened is better error than a warnx() about kernel support.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agolib/signames: remove unused function
Sami Kerola [Sun, 26 Nov 2017 17:47:49 +0000 (17:47 +0000)] 
lib/signames: remove unused function

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agoman: use long options in text and add example to uuidgen
Sami Kerola [Sun, 26 Nov 2017 17:27:21 +0000 (17:27 +0000)] 
man: use long options in text and add example to uuidgen

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agomisc: fix typos
Sami Kerola [Sun, 26 Nov 2017 17:27:20 +0000 (17:27 +0000)] 
misc: fix typos

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
7 years agotests: check for HAVE_LINUX_NET_NAMESPACE_H
Karel Zak [Tue, 28 Nov 2017 12:19:20 +0000 (13:19 +0100)] 
tests: check for HAVE_LINUX_NET_NAMESPACE_H

* use one cleanup function
* check if kernel headers support net namespace
* enable netnsid test

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agotests: add set-x to lsns test
Karel Zak [Tue, 28 Nov 2017 11:00:58 +0000 (12:00 +0100)] 
tests: add set-x to lsns test

.. just to see why does it fail on Travis.

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agotests: better lsns report on fail
Karel Zak [Tue, 28 Nov 2017 10:17:18 +0000 (11:17 +0100)] 
tests: better lsns report on fail

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agotests: make lsns test more robust
Karel Zak [Tue, 28 Nov 2017 09:58:37 +0000 (10:58 +0100)] 
tests: make lsns test more robust

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agonsenter: fix compiler warning [-Wuninitialized]
Karel Zak [Tue, 28 Nov 2017 09:53:35 +0000 (10:53 +0100)] 
nsenter: fix compiler warning [-Wuninitialized]

sys-utils/nsenter.c: In function ‘is_same_namespace’:
sys-utils/nsenter.c:170:2: warning: ‘b_ino’ may be used uninitialized in this function [-Wuninitialized]
sys-utils/nsenter.c:170:2: warning: ‘a_ino’ may be used uninitialized in this function [-Wuninitialized]

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agodmesg: fix compiler warning [-Wuninitialized]
Karel Zak [Tue, 28 Nov 2017 09:45:06 +0000 (10:45 +0100)] 
dmesg: fix compiler warning [-Wuninitialized]

sys-utils/dmesg.c: In function ‘print_record.constprop.12’:
sys-utils/dmesg.c:1039:14: warning: ‘mesg_size’ may be used uninitialized in this function [-Wuninitialized]

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agobuild-sys: lsns requires libmount
Karel Zak [Mon, 27 Nov 2017 16:44:43 +0000 (17:44 +0100)] 
build-sys: lsns requires libmount

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolsns: initialize stuff when really necessary
Karel Zak [Mon, 27 Nov 2017 16:40:56 +0000 (17:40 +0100)] 
lsns: initialize stuff when really necessary

It's more robust to depend on list of the wanted columns than on
another variables.

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agotests: fix lsns perms
Karel Zak [Mon, 27 Nov 2017 16:33:28 +0000 (17:33 +0100)] 
tests: fix lsns perms

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolsns: rename notruns to no_trunc
Karel Zak [Mon, 27 Nov 2017 16:04:29 +0000 (17:04 +0100)] 
lsns: rename notruns to no_trunc

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolsns: nsfs stuff cleanup
Karel Zak [Mon, 27 Nov 2017 15:58:19 +0000 (16:58 +0100)] 
lsns: nsfs stuff cleanup

* don't use booleans
* use is_ prefix for boolean-like functions
* make nsfs_xasputs() more readable
* enable 'nowrap' together with 'raw' and don't test for "nowrap || raw"
* add missing 'W' to getopt_long()

Signed-off-by: Karel Zak <kzak@redhat.com>
7 years agolsns: (man) write about using multi-line in NSFS cell of lsns
Masatake YAMATO [Fri, 24 Nov 2017 10:31:10 +0000 (19:31 +0900)] 
lsns: (man) write about using multi-line in NSFS cell of lsns

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
7 years agolsns: add a case for testing nsfs column
Masatake YAMATO [Fri, 24 Nov 2017 10:31:09 +0000 (19:31 +0900)] 
lsns: add a case for testing nsfs column

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
7 years agolsns: add --nowrap(-W) option
Masatake YAMATO [Fri, 24 Nov 2017 10:31:08 +0000 (19:31 +0900)] 
lsns: add --nowrap(-W) option

This option forces lsns command not use
multi-line presentation when printing a cell.

Currently, it affects only NSFS column.

Implementing this option is suggested by Karl Zak.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
7 years agolsns: add nsfs column
Masatake YAMATO [Fri, 24 Nov 2017 10:31:06 +0000 (19:31 +0900)] 
lsns: add nsfs column

nsfs provides kernel level interface for assigning
logical name to a namespace. Following message is quoted
from git log of linux kernel:

    commit 0226f4923f6c9b40cfa1c1c1b19a6ac6b3924ead
    Author: Al Viro <viro@zeniv.linux.org.uk>
    Date:   Tue Dec 6 12:21:54 2011 -0500

vfs: take /proc/*/mounts and friends to fs/proc_namespace.c

rationale: that stuff is far tighter bound to fs/namespace.c than to
the guts of procfs proper.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
/proc/self/mountinfo lists the logical names for namespaces:
  ...
  652 81 0:3 net:[4026532579] /tmp/XYZ rw shared:192 - nsfs nsfs rw,seclabel
  ...

In the lines /tmp/XYZ is a logical name for 4026532579 of net
namespace.

This patch adds nsfs column. It seems that the logical name is
used only in "ip netns" now. So the column is disabled by default.
Use '--type=net' or '-o NSFS' options to enable it.

This feature and the way to implementation using multi lines in a column
is Suggested by Karel Zak.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
7 years agolsns: add a case for testing netnsid column
Masatake YAMATO [Fri, 24 Nov 2017 10:31:05 +0000 (19:31 +0900)] 
lsns: add a case for testing netnsid column

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
7 years agolsns: disable netnsid column by default
Masatake YAMATO [Fri, 24 Nov 2017 10:31:04 +0000 (19:31 +0900)] 
lsns: disable netnsid column by default

Enable only when

* --type=net is given, or
* -o NETNSID is given.

Suggested by Karel Zak.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
7 years agolsns: add netnsid column
Masatake YAMATO [Fri, 24 Nov 2017 10:31:03 +0000 (19:31 +0900)] 
lsns: add netnsid column

Linux network subsystem assigns an unique integer to a network
namespace.

  term0# ip netns add UTIL-LINUX-LSNS-TEST-NS
  term0# ip netns list
  UTIL-LINUX-LSNS-TEST-NS
  term0# ip link add name lsns-vetha type veth peer name lsns-vethb
  term0 # ip link set lsns-vethb netns UTIL-LINUX-LSNS-TEST-NS
  term0# ip netns list
  UTIL-LINUX-LSNS-TEST-NS (id: 0)
  term0# ip link show dev lsns-vetha
  230: lsns-vetha@if229: <BROADCAST,MULTICAST> mtu 1500 qdisc noop ...
         link/ether 3e:27:68:ba:b3:95 brd ff:ff:ff:ff:ff:ff link-netnsid 0
In this example 0 is assigned to UTIL-LINUX-LSNS-TEST-NS net namespace.
The name, UTIL-LINUX-LSNS-TEST-NS, and it semantics is given and defined
by iproute2 in userland; and nothing to do with util-linux.

However, the id, 0, is managed in linux kernel. If lsns can show
the ids, it helps users understand the state of network namespaces.

This commit adds NETNSID column to the output.

Here is an example of session:

  term0# ip netns exec UTIL-LINUX-LSNS-TEST-NS cat

  (Open another terminal)

  term1# ./lsns --type net
          NS TYPE NPROCS   PID USER     NETNSID COMMAND
  4026531993 net     383     1 root  unassigned /usr/lib/systemd/...
  4026532433 net       1  1219 rtkit unassigned /usr/libexec/rtkit-daemon
  4026532562 net       1 18201 root           0 cat

0 is shown as NETNSID for the cat process.

For the initial name space, "unassigned" is printed.
For the namespaces other type than net, "n/a" is printed.
If an error occurred during getting the id, "n/a" is printed.

Changes in V2:

* Remove wrongly used & operators.
* Make netnsid field empty if value for the column is not available.
  Suggested by Karel Zak.
* Remove redundant condtion for checking the avaiablebility of netlink
  socket. Suggested by Karel Zak.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
7 years agortcwake: fix sys vs. rtc time delta usage
Karel Zak [Mon, 27 Nov 2017 11:37:53 +0000 (12:37 +0100)] 
rtcwake: fix sys vs. rtc time delta usage

srett commented:

 After some head scratching why relative wakeup using -s always works
 while -t didn't seem to work at all I discovered that the adjustment
 for time difference between sys and rtc is actually inverted when
 writing the alarm (code for -m show reading is fine), so if the RTC
 lags 10 minutes behind, the alarm will be shifted into the future by
 10 minutes, resulting in a wakeup that is 20 minutes late.

Addresses: https://github.com/karelzak/util-linux/issues/544
Signed-off-by: Karel Zak <kzak@redhat.com>