]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
8 years agohwclock: update --help content and grammar
J William Piggott [Sun, 18 Jun 2017 14:32:42 +0000 (10:32 -0400)] 
hwclock: update --help content and grammar

Reviewed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: J William Piggott <elseifthen@gmx.com>
8 years agohwclock: use RTC in help output
J William Piggott [Sat, 17 Jun 2017 23:21:13 +0000 (19:21 -0400)] 
hwclock: use RTC in help output

Switching between 'hardware clock' and 'RTC' is ambiguous.
RTC is used due to space constraints, so use it consistently.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
8 years agoinclude: update pathnames.h
J William Piggott [Sat, 17 Jun 2017 20:32:19 +0000 (16:32 -0400)] 
include: update pathnames.h

* use /dev/rtc0 (/dev/rtc was for the 'old' driver)
* remove hwclock Award workaround and alpha cmos paths
* relocate _PATH_BTMP from hwclock to login-utils
* add a comment for _PATH_BTMP and fix other login-utils comments
* add a comment for proc/cpuinfo
* remove empty shutdown.c comment from 4d43977f

Review changes
* remove 'used in' comments
* white space fixes

Reviewed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: J William Piggott <elseifthen@gmx.com>
8 years agohwclock: add usage() functions heading
J William Piggott [Sat, 17 Jun 2017 19:32:28 +0000 (15:32 -0400)] 
hwclock: add usage() functions heading

Make a functions heading, similar to the existing options heading.

* include/c.h: define USAGE_FUNCTIONS
* Documentation/boilerplate.c: add USAGE_FUNCTIONS
* sys-utils/hwclock.c add functions header to usage()

Reviewed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: J William Piggott <elseifthen@gmx.com>
8 years agohwclock: update usage() FILE name
J William Piggott [Fri, 21 Apr 2017 00:53:23 +0000 (20:53 -0400)] 
hwclock: update usage() FILE name

Use the util-linux standard file name instead of 'usageto'.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
8 years agohwclock: update usage() to util-linux style
J William Piggott [Fri, 21 Apr 2017 00:44:13 +0000 (20:44 -0400)] 
hwclock: update usage() to util-linux style

Update usage() according to:
  Documentation/howto-usage-function.txt
  Documentation/boilerplate.c

Signed-off-by: J William Piggott <elseifthen@gmx.com>
8 years agohwclock: remove dead code in usage()
J William Piggott [Fri, 21 Apr 2017 00:29:15 +0000 (20:29 -0400)] 
hwclock: remove dead code in usage()

Commit 677ec86 caused usage() to be called only by --help.

So remove the now dead code from usage().

Signed-off-by: J William Piggott <elseifthen@gmx.com>
8 years agotests: add MBR resize tests
Karel Zak [Mon, 19 Jun 2017 14:10:33 +0000 (16:10 +0200)] 
tests: add MBR resize tests

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: support logical partition resize
Karel Zak [Mon, 19 Jun 2017 14:03:41 +0000 (16:03 +0200)] 
libfdisk: support logical partition resize

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: allow to resize container
Karel Zak [Mon, 19 Jun 2017 13:32:02 +0000 (15:32 +0200)] 
libfdisk: allow to resize container

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: add more debug messages to get-last-possible resize space
Karel Zak [Mon, 19 Jun 2017 13:27:05 +0000 (15:27 +0200)] 
libfdisk: add more debug messages to get-last-possible resize space

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: (dos) be more verbose on partno -ERANGE error
Karel Zak [Mon, 19 Jun 2017 12:32:59 +0000 (14:32 +0200)] 
libfdisk: (dos) be more verbose on partno -ERANGE error

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agomount: fix man page typo (--bind,ro)
Karel Zak [Mon, 19 Jun 2017 09:49:51 +0000 (11:49 +0200)] 
mount: fix man page typo (--bind,ro)

Addresses: https://github.com/karelzak/util-linux/issues/464
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibfdisk: (dos) fix primary/logical logic when follow template
Karel Zak [Mon, 19 Jun 2017 09:41:02 +0000 (11:41 +0200)] 
libfdisk: (dos) fix primary/logical logic when follow template

This stupid bug has been introduced by e1cfb304 (v2.30) and it
disables to create extended partition by cfdisk :-(

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoMerge branch 'some-fixes' of https://github.com/rudimeier/util-linux
Karel Zak [Fri, 16 Jun 2017 08:50:24 +0000 (10:50 +0200)] 
Merge branch 'some-fixes' of https://github.com/rudimeier/util-linux

* 'some-fixes' of https://github.com/rudimeier/util-linux:
  travis: minor cosmetics
  lib: style cosmetics plymouth-ctrl.c
  libmount: fix warning "set but not used"
  more: remove unused variable
  tests: split partx in root and non-root
  tests: fix and refactor partx

8 years agofstrim: remove obsolete comment
Karel Zak [Thu, 15 Jun 2017 09:49:09 +0000 (11:49 +0200)] 
fstrim: remove obsolete comment

We do not de-duplicate by FS root (since afa382f2e087b71c9e626144f2f313abc42ad594).

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agofstrim: prefer earlier mounted filesystems
Alex Ivanov [Thu, 15 Jun 2017 08:26:25 +0000 (11:26 +0300)] 
fstrim: prefer earlier mounted filesystems

fstrim --all is broken in a way that if there is a bind mount for some filesystem,
that filesystem will not be trimmed. This is especially critical for e.g.
NixOS distribution, which needs bind mount within root fs:
https://github.com/NixOS/nixos/blob/master/modules/system/boot/stage-2-init.sh#L55

Currently for a given filesystem during "de-duplication by source and root" phase,
an early mounted fs path is filtered (e.g. "/"), while later mounted fs path is kept
(e.g. "/nix/store") though anyway discarded later (since it's an overlaying mount).
This leads to skipped trimming.

So flip this behaviour. Should also help for other types of overlaying mounts.

Reference:
https://github.com/karelzak/util-linux/blob/stable/v2.29/libmount/src/tab.c#L715

Signed-off-by: Alex Ivanov <yourbestfriend@openmailbox.org>
8 years agotravis: minor cosmetics
Ruediger Meier [Thu, 15 Jun 2017 06:56:43 +0000 (08:56 +0200)] 
travis: minor cosmetics

This is just to make the diff to my private travis script a bit smaller.

Now we always use $CC _after_ the install script which makes it possible
to install/update the compiler in the install section.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agolib: style cosmetics plymouth-ctrl.c
Ruediger Meier [Thu, 8 Jun 2017 20:29:32 +0000 (22:29 +0200)] 
lib: style cosmetics plymouth-ctrl.c

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agolibmount: fix warning "set but not used"
Ruediger Meier [Thu, 15 Jun 2017 06:56:01 +0000 (08:56 +0200)] 
libmount: fix warning "set but not used"

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agomore: remove unused variable
Ruediger Meier [Thu, 15 Jun 2017 06:55:40 +0000 (08:55 +0200)] 
more: remove unused variable

slow_tty is at least unused since util-linux 2.2.

FYI here is another derived more.c where slow_tty is still used:
https://github.com/sergev/LiteBSD/blob/master/old/more/more.c

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agotests: split partx in root and non-root
Ruediger Meier [Thu, 15 Jun 2017 00:40:57 +0000 (02:40 +0200)] 
tests: split partx in root and non-root

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agotests: fix and refactor partx
Ruediger Meier [Thu, 15 Jun 2017 00:24:40 +0000 (02:24 +0200)] 
tests: fix and refactor partx

Subtest delete-non-existent was broken because since 2d47fa39
option --nr was missing. It wasn't noticed because we did not
check stderr. Now we check all return values and output.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agowall: don't use gid_t when allocate grounps array
Karel Zak [Wed, 14 Jun 2017 19:45:56 +0000 (21:45 +0200)] 
wall: don't use gid_t when allocate grounps array

Reported-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolib: remove _RLD_ from forbid environment variable list
Sami Kerola [Mon, 29 May 2017 17:52:17 +0000 (18:52 +0100)] 
lib: remove _RLD_ from forbid environment variable list

The RLD environment variables are related to runtime linker vulnerability in
TELNET on systems running Silicon Graphics IRIX.  It is extremely unlikely
current util-linux would be compiled on such system.

Reference: http://www.cert.org/historical/advisories/CA-1995-14.cfm
Reference: http://signatures.juniper.net/documentation/signatures/TELNET%3AEXPLOIT%3ASGI-RLD.html
Refefence: http://www.polarhome.com/service/man/?qf=rld&tf=2&of=IRIX&sf=1
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agolib: simplify cpuset if clauses that return
Sami Kerola [Mon, 29 May 2017 17:39:22 +0000 (18:39 +0100)] 
lib: simplify cpuset if clauses that return

There is no need for 'else' when 'if' will return.  In same go move call of
tolower() to last possible moment in char_to_val(), a lot of time hex values
should hit 0-9 range, and it can be omitted.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agomisc: remove stray semicolons
Sami Kerola [Sun, 28 May 2017 09:37:06 +0000 (10:37 +0100)] 
misc: remove stray semicolons

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agolosetup: add missing initializer [clang]
Sami Kerola [Sun, 28 May 2017 18:06:08 +0000 (19:06 +0100)] 
losetup: add missing initializer [clang]

sys-utils/losetup.c:290:12: warning: variable 'rc' is used uninitialized
whenever 'if' condition is false [-Wsometimes-uninitialized]
sys-utils/losetup.c:293:7: note: uninitialized use occurs here
sys-utils/losetup.c:290:8: note: remove the 'if' if its condition is always true
sys-utils/losetup.c:228:9: note: initialize the variable 'rc' to silence
this warning

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agomisc: fix reassigned values before old ones has been used [cppcheck]
Sami Kerola [Sun, 28 May 2017 09:21:48 +0000 (10:21 +0100)] 
misc: fix reassigned values before old ones has been used [cppcheck]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agoisosize: avoid reading more data than what is needed
Sami Kerola [Sat, 27 May 2017 20:18:57 +0000 (21:18 +0100)] 
isosize: avoid reading more data than what is needed

In same go fix error reporting when input file is not long enough.

$ touch empty
$ isosize empty
isosize: empty: might not be an ISO filesystem
isosize: read error on empty: Success

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agouuidgen: slice up the usage text
Sami Kerola [Sun, 21 May 2017 16:47:39 +0000 (17:47 +0100)] 
uuidgen: slice up the usage text

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agorename: notice when expression and replacement are the same string
Sami Kerola [Sat, 20 May 2017 09:41:23 +0000 (10:41 +0100)] 
rename: notice when expression and replacement are the same string

The rename(1) can exit early when replace expression and replacement are
identical string.  It is also appropriate to change return value in this
case to 'nothing was renamed'.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agoMerge branch 'master' of ra.kernel.org:/pub/scm/utils/util-linux/util-linux
Karel Zak [Wed, 14 Jun 2017 09:56:57 +0000 (11:56 +0200)] 
Merge branch 'master' of ra.kernel.org:/pub/scm/utils/util-linux/util-linux

8 years agowall: fix OSX getgrouplist, gid_t* vs int*
Karel Zak [Wed, 14 Jun 2017 09:53:43 +0000 (11:53 +0200)] 
wall: fix OSX getgrouplist, gid_t* vs int*

This was the compiler warning:

term-utils/wall.c:156:39: warning: passing 'gid_t *const' (aka 'unsigned int *const') to
parameter of type 'int *' converts between pointers to integer types with different sign
[-Wpointer-sign]
        rc = getgrouplist(login, pw->pw_gid, buf->groups, &ngroups);
                                             ^~~~~~~~~~~
/usr/include/unistd.h:653:43: note: passing argument to parameter here
int      getgrouplist(const char *, int, int *, int *);
                                              ^

Reported-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agomisc: POSIX usage dd, regarding unit suffixes
Ruediger Meier [Tue, 13 Jun 2017 22:14:13 +0000 (00:14 +0200)] 
misc: POSIX usage dd, regarding unit suffixes

In POSIX we have only 'b' and 'k' (case-sensitive).

In the real work, OSX was the only system I've found  which does
not understand capital 'K'.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agotests: add more tests for line(1)
Ruediger Meier [Tue, 13 Jun 2017 13:33:58 +0000 (15:33 +0200)] 
tests: add more tests for line(1)

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agomisc: fix ggc-7 fallthrough warnings
Sami Kerola [Tue, 16 May 2017 08:18:24 +0000 (09:18 +0100)] 
misc: fix ggc-7 fallthrough warnings

(Original patch and commit message edited by Rudi.)

gcc-7 adds -Wimplicit-fallthrough=3 to our default flag -Wextra.
This warning can be silenced by using comment /* fallthrough */
which is also recognized by other tools like coverity. There are
also other valid comments (see man gcc-7) but we consolidate this
style now.

We could have also used __attribute__((fallthrough)) but the comment
looks nice and does not need to be ifdef'ed for compatibility.

Reference: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=7652
Reference: https://developers.redhat.com/blog/2017/03/10/wimplicit-fallthrough-in-gcc-7/
Reviewed-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Suggested-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agolibblkid: fix gcc-7 warning -Wint-in-bool-context
Ruediger Meier [Sun, 11 Jun 2017 23:59:36 +0000 (01:59 +0200)] 
libblkid: fix gcc-7 warning -Wint-in-bool-context

BLOCK_SIZE(sb) should be unsigned so that the left shift is defined.

This was the warning:

../libblkid/src/superblocks/exfat.c: In function 'probe_exfat':
../libblkid/src/superblocks/exfat.c:40:42: warning: '<<' in boolean context, did you mean '<' ? [-Wint-in-bool-context]
 #define CLUSTER_SIZE(sb) (BLOCK_SIZE(sb) << (sb)->bpc_bits)
                          ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
../libblkid/src/superblocks/exfat.c:122:14: note: in expansion of macro 'CLUSTER_SIZE'
  if (!sb || !CLUSTER_SIZE(sb))
              ^~~~~~~~~~~~

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agomisc: fix gcc-7 snprintf warnings -Wformat-truncation
Ruediger Meier [Sun, 11 Jun 2017 21:18:21 +0000 (23:18 +0200)] 
misc: fix gcc-7 snprintf warnings -Wformat-truncation

../lib/loopdev.c: In function 'loopcxt_next_from_sysfs':
../lib/loopdev.c:545:32: warning: '/loop/backing_file' directive output may be truncated writing 18 bytes into a region of size between 1 and 256 [-Wformat-truncation=]
   snprintf(name, sizeof(name), "%s/loop/backing_file", d->d_name);
                                ^~~~~~~~~~~~~~~~~~~~~~
../lib/loopdev.c:545:3: note: 'snprintf' output between 19 and 274 bytes into a destination of size 256
   snprintf(name, sizeof(name), "%s/loop/backing_file", d->d_name);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../lib/sysfs.c: In function 'sysfs_is_partition_dirent':
../lib/sysfs.c:343:31: warning: '/start' directive output may be truncated writing 6 bytes into a region of size between 1 and 256 [-Wformat-truncation=]
  snprintf(path, sizeof(path), "%s/start", d->d_name);
                               ^~~~~~~~~~
../lib/sysfs.c:343:2: note: 'snprintf' output between 7 and 262 bytes into a destination of size 256
  snprintf(path, sizeof(path), "%s/start", d->d_name);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../lib/sysfs.c: In function 'sysfs_partno_to_devno':
../lib/sysfs.c:372:32: warning: '/partition' directive output may be truncated writing 10 bytes into a region of size between 1 and 256 [-Wformat-truncation=]
   snprintf(path, sizeof(path), "%s/partition", d->d_name);
                                ^~~~~~~~~~~~~~
../lib/sysfs.c:372:3: note: 'snprintf' output between 11 and 266 bytes into a destination of size 256
   snprintf(path, sizeof(path), "%s/partition", d->d_name);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../lib/sysfs.c:377:33: warning: '/dev' directive output may be truncated writing 4 bytes into a region of size between 1 and 256 [-Wformat-truncation=]
    snprintf(path, sizeof(path), "%s/dev", d->d_name);
                                 ^~~~~~~~
../lib/sysfs.c:377:4: note: 'snprintf' output between 5 and 260 bytes into a destination of size 256
    snprintf(path, sizeof(path), "%s/dev", d->d_name);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agomisc: fix gcc-7 sprintf warnings -Wformat-overflow
Ruediger Meier [Sun, 11 Jun 2017 20:20:24 +0000 (22:20 +0200)] 
misc: fix gcc-7 sprintf warnings -Wformat-overflow

../login-utils/last.c: In function ‘main’:
../login-utils/last.c:624:23: warning: ‘%s’ directive writing up to 31 bytes into a region of size 27 [-Wformat-overflow=]
   sprintf(path, "/dev/%s", ut->ut_line);
                       ^~   ~~
../login-utils/last.c:624:3: note: ‘sprintf’ output between 6 and 37 bytes into a destination of size 32
   sprintf(path, "/dev/%s", ut->ut_line);

../libblkid/src/devname.c: In function 'probe_one':
../libblkid/src/devname.c:166:29: warning: '%s' directive writing up to 255 bytes into a region of size 245 [-Wformat-overflow=]
   sprintf(path, "/sys/block/%s/slaves", de->d_name);
                             ^~
../libblkid/src/devname.c:166:3: note: 'sprintf' output between 19 and 274 bytes into a destination of size 256
   sprintf(path, "/sys/block/%s/slaves", de->d_name);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agohwclock: fix warning [-Winvalid-noreturn]
Ruediger Meier [Sun, 11 Jun 2017 20:00:49 +0000 (22:00 +0200)] 
hwclock: fix warning [-Winvalid-noreturn]

clang warned:

 CC       sys-utils/hwclock.o
../sys-utils/hwclock.c:1274:1: warning: function declared 'noreturn' should not return [-Winvalid-noreturn]

We have to move the noreturn attribute from the function definition
to the declaration.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agolibmount: btrfs, remove unused setter functions
Ruediger Meier [Sun, 11 Jun 2017 19:48:08 +0000 (21:48 +0200)] 
libmount: btrfs, remove unused setter functions

We have never used them since introduced in 2cd28fc8.
clang compiler warned about it.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agotests: fix fincore, don't use variable COLUMNS
Ruediger Meier [Sun, 11 Jun 2017 18:45:14 +0000 (20:45 +0200)] 
tests: fix fincore, don't use variable COLUMNS

COLUMNS is automatically set by bash and may result in stupid
errors like

  fincore: unknown column: 160

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agolibsmartcols: fix warning "unused parameter"
Ruediger Meier [Tue, 13 Jun 2017 09:08:10 +0000 (11:08 +0200)] 
libsmartcols: fix warning "unused parameter"

Noticed on OSX.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agolibfdisk: fix guid usage of packed struct gpt_entry
Ruediger Meier [Tue, 13 Jun 2017 08:09:45 +0000 (10:09 +0200)] 
libfdisk: fix guid usage of packed struct gpt_entry

clang issued warnings like this:

../libfdisk/src/gpt.c:371:18: warning: taking address of packed member 'type' of class or structure 'gpt_entry' may result in an unaligned pointer value [-Waddress-of-packed-member]
        guid_to_string(&e->type, str);
                        ^~~~~~~

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agoMerge branch 'sami-fallthrough' of https://github.com/rudimeier/util-linux
Karel Zak [Tue, 13 Jun 2017 21:01:23 +0000 (23:01 +0200)] 
Merge branch 'sami-fallthrough' of https://github.com/rudimeier/util-linux

* 'sami-fallthrough' of https://github.com/rudimeier/util-linux:
  misc: fix ggc-7 fallthrough warnings

8 years agomisc: fix ggc-7 fallthrough warnings
Sami Kerola [Tue, 16 May 2017 08:18:24 +0000 (09:18 +0100)] 
misc: fix ggc-7 fallthrough warnings

(Original patch and commit message edited by Rudi.)

gcc-7 adds -Wimplicit-fallthrough=3 to our default flag -Wextra.
This warning can be silenced by using comment /* fallthrough */
which is also recognized by other tools like coverity. There are
also other valid comments (see man gcc-7) but we consolidate this
style now.

We could have also used __attribute__((fallthrough)) but the comment
looks nice and does not need to be ifdef'ed for compatibility.

Reference: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=7652
Reference: https://developers.redhat.com/blog/2017/03/10/wimplicit-fallthrough-in-gcc-7/
Reviewed-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Suggested-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agolibfdisk: cleanup sun label checksum usuage
Ruediger Meier [Tue, 13 Jun 2017 01:16:02 +0000 (03:16 +0200)] 
libfdisk: cleanup sun label checksum usuage

We are using now the formerly unused function sun_pt_checksum(). This
cleanup was motivated by clang compiler warning, see below. Also nice
that we are now always using uint16_t instead of short.

Warning was:

../libfdisk/src/sun.c:177:35: warning: taking address of packed member 'csum' of class or structure 'sun_disklabel' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
                while(ush < (unsigned short *)(&sunlabel->csum))

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agolscpu: cleanup DMI detection return codes
Karel Zak [Tue, 13 Jun 2017 10:15:11 +0000 (12:15 +0200)] 
lscpu: cleanup DMI detection return codes

Michal wrote:
 There is weird mix of logic in lscpu-dmi.c which sometimes returns 0 and
 sometimes -1 on error. Since most checks are if (rc) goto done; this
 bails out early on error skipping some detection methods. Further, in
 lscpu.c all following detections are guarder by if(hyper) so returning
 -1 causes all following methods to be skipped.

Reported-by: Michal Suchanek <msuchanek@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibsmartcols: (docs) add new functions
Karel Zak [Tue, 13 Jun 2017 09:17:06 +0000 (11:17 +0200)] 
libsmartcols: (docs) add new functions

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agocolumn: add --table-header-repeat
Karel Zak [Tue, 13 Jun 2017 09:14:46 +0000 (11:14 +0200)] 
column: add --table-header-repeat

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibsmartcols: add header-repeat feature
Karel Zak [Tue, 13 Jun 2017 09:11:17 +0000 (11:11 +0200)] 
libsmartcols: add header-repeat feature

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibsmartcols: add missing symbols
Karel Zak [Mon, 12 Jun 2017 14:35:58 +0000 (16:35 +0200)] 
libsmartcols: add missing symbols

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoMerge branch 'pylibmount-NULL-terminate-kwlist-in-Context_init' of https://github...
Karel Zak [Mon, 12 Jun 2017 13:39:59 +0000 (15:39 +0200)] 
Merge branch 'pylibmount-NULL-terminate-kwlist-in-Context_init' of https://github.com/zmedico/util-linux

* 'pylibmount-NULL-terminate-kwlist-in-Context_init' of https://github.com/zmedico/util-linux:
  pylibmount: NULL terminate kwlist in Context_init

8 years agolibsmartcols: add scols_table_{set,get}_termheight()
Karel Zak [Mon, 12 Jun 2017 09:51:36 +0000 (11:51 +0200)] 
libsmartcols: add scols_table_{set,get}_termheight()

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolib/ttyutils: return terminal lines too
Karel Zak [Mon, 12 Jun 2017 09:38:38 +0000 (11:38 +0200)] 
lib/ttyutils: return terminal lines too

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agodocs: update TODO, remove auto,noauto
Karel Zak [Mon, 12 Jun 2017 08:44:37 +0000 (10:44 +0200)] 
docs: update TODO, remove auto,noauto

It seems good enough to use the current semantic and check for
"noauto" string rather than evaluate "auto/noauto" as a bit flag.

We use flags for mount options, but in this case (mount --all) it's
overkill to convert all options on all fstab entries to flags just to
be sure that somewhere is no "auto,noauto" obscure setting.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolsblk: add option --tree
Karel Zak [Fri, 9 Jun 2017 09:33:18 +0000 (11:33 +0200)] 
lsblk: add option --tree

Now lsblk uses --list when --sort <column> is specified. This patch
allows to specify --tree to overwrite this default behavior add to
force tree-like output. In this case tree branches are sorted by the
<column>.

$ lsblk --sort SIZE
NAME MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda2   8:2    0   200M  0 part /boot
sda1   8:1    0   200M  0 part /boot/efi
sda6   8:6    0   7.8G  0 part [SWAP]
sda5   8:5    0  35.1G  0 part /home/misc
sda4   8:4    0    50G  0 part /
sdb1   8:17   0  74.5G  0 part /home/archive
sdb    8:16   0  74.5G  0 disk
sda3   8:3    0 130.3G  0 part /home
sda    8:0    0 223.6G  0 disk

$ lsblk --sort SIZE --tree
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sdb      8:16   0  74.5G  0 disk
└─sdb1   8:17   0  74.5G  0 part /home/archive
sda      8:0    0 223.6G  0 disk
├─sda2   8:2    0   200M  0 part /boot
├─sda1   8:1    0   200M  0 part /boot/efi
├─sda6   8:6    0   7.8G  0 part [SWAP]
├─sda5   8:5    0  35.1G  0 part /home/misc
├─sda4   8:4    0    50G  0 part /
└─sda3   8:3    0 130.3G  0 part /home

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibblkid: (vfat) add more debug messages
Karel Zak [Fri, 9 Jun 2017 09:11:38 +0000 (11:11 +0200)] 
libblkid: (vfat) add more debug messages

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agopylibmount: NULL terminate kwlist in Context_init
Zac Medico [Thu, 8 Jun 2017 00:21:33 +0000 (17:21 -0700)] 
pylibmount: NULL terminate kwlist in Context_init

Fixes a segfault observed with python3.6.

8 years agolibmount: (umount) use mount table filter on -c only
Karel Zak [Wed, 7 Jun 2017 10:40:17 +0000 (12:40 +0200)] 
libmount: (umount) use mount table filter on -c only

The path canonicalization is the worst use-case, it's better to read
all mount table than try canonicalize.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolibmount: use mount table filter on --no-canonicalize
Karel Zak [Wed, 7 Jun 2017 09:35:26 +0000 (11:35 +0200)] 
libmount: use mount table filter on --no-canonicalize

The umount command option --no-canonicalize means that the path is
already canonical. So, we can use mount table filter in this case too.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agorename: add -o to the man page
Karel Zak [Tue, 6 Jun 2017 10:09:34 +0000 (12:09 +0200)] 
rename: add -o to the man page

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoMerge branch 'rename-nooverride' of https://github.com/dov/util-linux
Karel Zak [Tue, 6 Jun 2017 10:07:26 +0000 (12:07 +0200)] 
Merge branch 'rename-nooverride' of https://github.com/dov/util-linux

* 'rename-nooverride' of https://github.com/dov/util-linux:
  Changed "override" to "overwrite" rename option.
  Added --no-override option to rename.

8 years agoMerge branch 'hwclock-localtime' of https://github.com/Villemoes/util-linux
Karel Zak [Tue, 6 Jun 2017 10:06:28 +0000 (12:06 +0200)] 
Merge branch 'hwclock-localtime' of https://github.com/Villemoes/util-linux

8 years agoumount: add note about NFS and -c to umount.8
Karel Zak [Tue, 6 Jun 2017 10:05:14 +0000 (12:05 +0200)] 
umount: add note about NFS and -c to umount.8

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoumount: never 'stat' the path when "-c" is given.
NeilBrown [Mon, 5 Jun 2017 02:32:58 +0000 (12:32 +1000)] 
umount: never 'stat' the path when "-c" is given.

It is currently not possible to reliably and automatically
unmount an NFS filesystem. If the server is not available, the
umount command will hang.

The hang can be avoided by using "-l" or "-f", but neither
of these are appropriate for automatic use such as by an
automounter (e.g automountd or systemd).

"-l" will unmount even if the filesystem is in use, which
an automounter generally doesn't want.  If the filesystem
is in use, then the umount should fail.

"-f" can cause the filesystem to abort pending transactions
which might break filesystem semantics.  This can be useful
in the hands of a sysadmin, but not when used by an
automatic tool.

umount has another option, "-c" aka "--no-canonicalize"
which avoids some "stat" calls.
Currently this doesn't avoid all calls to
canonicalize_path()
as
  mnt_context_prepare_umount() ->
    lookup_umount_fs() ->
      mnt_context_find_umount_fs() ->
        mnt_context_get_mtab_for_target() ->
  mnt_resolve_path() ->
    canonicalize_path_and_cache() ->
      canonicalize_path()

leads to that function being called.

The "-c" option could be taken to mean "I know what I'm
doing, this really is the path to a mount point, I just want
you to unmount it".  Given that, it seems suitable to
extend this to avoid all 'stat' calls on the mountpoint.

It is already appropriate for any automount program to pass
"-c" to "umount", so they can be changed to do so at any
time.
With the patch below, "-c" will result in the mountpoint
never being "stat"ed, so umount won't hang on an
inaccessible server.

This isn't quite sufficient, for NFS at least, as the usage
of libmount in umount.nfs still calls 'stat' on the mount
point.
"-c" isn't passed to the umount helper, but it is reasonable
for such helpers to assume "-c" because "umount" will have
canonicalized the path when that is appropriate.

So, this patch treats "-c" much like "-l" and "-f" when
deciding whether it is safe to 'stat' the path.

Signed-off-by: NeilBrown <neilb@suse.com>
8 years agoMerge branch 'fdformat-done1' of https://github.com/jwilk-forks/util-linux
Karel Zak [Mon, 5 Jun 2017 13:27:39 +0000 (15:27 +0200)] 
Merge branch 'fdformat-done1' of https://github.com/jwilk-forks/util-linux

* 'fdformat-done1' of https://github.com/jwilk-forks/util-linux:
  fdformat: clear progress message before printing "done"

8 years agosetpriv: Add --init-groups option
Sebastian Schrader [Thu, 1 Jun 2017 14:52:10 +0000 (16:52 +0200)] 
setpriv: Add --init-groups option

Add an --init-groups option which initializes the supplementary groups
from the system's group database (e.g /etc/group) using initgroups(3).

8 years agochsh: cleanup global_shells usage
Karel Zak [Mon, 5 Jun 2017 11:29:20 +0000 (13:29 +0200)] 
chsh: cleanup global_shells usage

* global variables are always initialized by NULL
* it seems we need it as global variable due to libreadline, then use it as
  global everywhere in the same .c file.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agochsh: split get_shell_list()
Karel Zak [Mon, 5 Jun 2017 11:15:59 +0000 (13:15 +0200)] 
chsh: split get_shell_list()

Let's use two functions is_known_shell() and print_shells() to make
the code more readable and to avoid complex semantic of the original
get_shell_list().

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agochsh: make readline completion to propose valid shells
Sami Kerola [Thu, 18 May 2017 21:19:36 +0000 (22:19 +0100)] 
chsh: make readline completion to propose valid shells

This is better than default readline completion, that gives paths from
current directory onwards.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agoChanged "override" to "overwrite" rename option.
Dov Grobgeld [Sat, 3 Jun 2017 20:40:47 +0000 (23:40 +0300)] 
Changed "override" to "overwrite" rename option.

8 years agofdformat: clear progress message before printing "done"
Jakub Wilk [Fri, 2 Jun 2017 21:54:10 +0000 (23:54 +0200)] 
fdformat: clear progress message before printing "done"

Before:

    Formatting ... done1

After:

    Formatting ... done

Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
8 years agobuild-sys: release++ (v2.30) v2.30
Karel Zak [Fri, 2 Jun 2017 10:22:29 +0000 (12:22 +0200)] 
build-sys: release++ (v2.30)

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agodocs: update v2.30-ReleaseNotes
Karel Zak [Fri, 2 Jun 2017 10:20:19 +0000 (12:20 +0200)] 
docs: update v2.30-ReleaseNotes

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agodocs: update AUTHORS file
Karel Zak [Fri, 2 Jun 2017 10:16:08 +0000 (12:16 +0200)] 
docs: update AUTHORS file

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agolib/pager: use xalloc
Karel Zak [Fri, 2 Jun 2017 10:07:36 +0000 (12:07 +0200)] 
lib/pager: use xalloc

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agotests: update build-sys test
Karel Zak [Fri, 2 Jun 2017 10:03:46 +0000 (12:03 +0200)] 
tests: update build-sys test

The libtinfo is enough (and libncurses optional for cal).

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agopo: merge changes
Karel Zak [Fri, 2 Jun 2017 09:30:19 +0000 (11:30 +0200)] 
po: merge changes

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoMerge branch 'master' of https://github.com/yurchor/util-linux
Karel Zak [Fri, 2 Jun 2017 09:13:39 +0000 (11:13 +0200)] 
Merge branch 'master' of https://github.com/yurchor/util-linux

* 'master' of https://github.com/yurchor/util-linux:
  Fix minor typos

8 years agopo: update uk.po (from translationproject.org)
Yuri Chornoivan [Fri, 2 Jun 2017 09:08:30 +0000 (11:08 +0200)] 
po: update uk.po (from translationproject.org)

8 years agopo: update tr.po (from translationproject.org)
Mesutcan Kurt [Fri, 2 Jun 2017 09:08:30 +0000 (11:08 +0200)] 
po: update tr.po (from translationproject.org)

8 years agopo: update sv.po (from translationproject.org)
Sebastian Rasmussen [Fri, 2 Jun 2017 09:08:30 +0000 (11:08 +0200)] 
po: update sv.po (from translationproject.org)

8 years agopo: update pl.po (from translationproject.org)
Jakub Bogusz [Fri, 2 Jun 2017 09:08:30 +0000 (11:08 +0200)] 
po: update pl.po (from translationproject.org)

8 years agopo: update ja.po (from translationproject.org)
Takeshi Hamasaki [Fri, 2 Jun 2017 09:08:30 +0000 (11:08 +0200)] 
po: update ja.po (from translationproject.org)

8 years agopo: update de.po (from translationproject.org)
Philipp Thomas [Fri, 2 Jun 2017 09:08:30 +0000 (11:08 +0200)] 
po: update de.po (from translationproject.org)

8 years agodocs: add information about mailing list rejection
J William Piggott [Thu, 1 Jun 2017 23:42:21 +0000 (19:42 -0400)] 
docs: add information about mailing list rejection

Signed-off-by: J William Piggott <elseifthen@gmx.com>
8 years agolib/pager: don't use pager if command not available
Karel Zak [Thu, 1 Jun 2017 12:20:20 +0000 (14:20 +0200)] 
lib/pager: don't use pager if command not available

for example:
 # PAGER=foo dmesg -H
 sh: foo: command not found

the same problem is we have with fdisk 'l' command:

 # PAGER=foo fdisk /dev/sda
 Welcome to fdisk (util-linux 2.30-rc2-33-41b71).
 ...
 Command (m for help): l
 sh: foo: command not found

It seems better to don't use pager at all if not available.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agoMerge branch 'travis-test' of https://github.com/rudimeier/util-linux
Karel Zak [Thu, 1 Jun 2017 10:30:14 +0000 (12:30 +0200)] 
Merge branch 'travis-test' of https://github.com/rudimeier/util-linux

* 'travis-test' of https://github.com/rudimeier/util-linux:
  tests: check for timeout command
  Revert "tests: use stdbuf when stderr and stdout is randomly ordered"

8 years agolscpu: make min/max freq arrays usage more robust
Karel Zak [Thu, 1 Jun 2017 10:15:23 +0000 (12:15 +0200)] 
lscpu: make min/max freq arrays usage more robust

The array members may be NULL on some architectures (e.g. AMD). Let's
be paranoid and check for the NULL independently on present/online
masks.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1457744
Signed-off-by: Karel Zak <kzak@redhat.com>
8 years agotests: check for timeout command
Ruediger Meier [Thu, 1 Jun 2017 09:23:26 +0000 (11:23 +0200)] 
tests: check for timeout command

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agoRevert "tests: use stdbuf when stderr and stdout is randomly ordered"
Ruediger Meier [Thu, 1 Jun 2017 09:20:02 +0000 (11:20 +0200)] 
Revert "tests: use stdbuf when stderr and stdout is randomly ordered"

stdbuf does not seem to work reliable. Failed on travis/OSX

This reverts commit 398b3148bedee936ee0b012b3b6e82b20547f218.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agocolumn: add missed semicolons in case of !HAVE_WIDECHAR
Alexander Kuleshov [Mon, 29 May 2017 18:49:17 +0000 (00:49 +0600)] 
column: add missed semicolons in case of !HAVE_WIDECHAR

In other case we will get:

  error: expected ‘;’ before ‘}’ token

error.

Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>
8 years agoMerge branch 'travis-test' of https://github.com/rudimeier/util-linux
Karel Zak [Thu, 1 Jun 2017 08:49:12 +0000 (10:49 +0200)] 
Merge branch 'travis-test' of https://github.com/rudimeier/util-linux

* 'travis-test' of https://github.com/rudimeier/util-linux:
  misc: fix some warnings
  tests: handle non glibc error message for fallocate
  tests: use stdbuf when stderr and stdout is randomly ordered
  build-sys: fix library order when linking
  tests: avoid diff of diffs
  tests: grep's short option -A is more portable

8 years agomisc: fix some warnings
Ruediger Meier [Wed, 31 May 2017 21:58:11 +0000 (23:58 +0200)] 
misc: fix some warnings

sys-utils/prlimit.c: In function 'do_prlimit':
sys-utils/prlimit.c:367:16: warning: format '%ju' expects argument of type 'uintmax_t', but argument 2 has type 'rlim_t {aka long long unsigned int}' [-Wformat=]
     printf("<%ju", new->rlim_cur);

lib/plymouth-ctrl.c: In function 'open_un_socket_and_connect':
lib/plymouth-ctrl.c:88:20: warning: passing argument 2 of 'connect' from incompatible pointer type [-Wincompatible-pointer-types]
  ret = connect(fd, &su, offsetof(struct sockaddr_un, sun_path) + 1 + strlen(su.sun_path+1));
                    ^
In file included from lib/plymouth-ctrl.c:35:0:
/usr/include/sys/socket.h:314:5: note: expected 'const struct sockaddr *' but argument is of type 'struct sockaddr_un *'
 int connect (int, const struct sockaddr *, socklen_t);

login-utils/last.c: In function 'list':
login-utils/last.c:506:54: warning: pointer targets in passing argument 4 of 'dns_lookup' differ in signedness [-Wpointer-sign]
   r = dns_lookup(domain, sizeof(domain), ctl->useip, p->ut_addr_v6);
                                                      ^
login-utils/last.c:291:12: note: expected 'int32_t * {aka int *}' but argument is of type 'unsigned int *'
 static int dns_lookup(char *result, int size, int useip, int32_t *a)
            ^~~~~~~~~~

In file included from sys-utils/hwclock-cmos.c:92:0:
sys-utils/hwclock.h:67:32: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration
 extern double time_diff(struct timeval subtrahend, struct timeval subtractor);

misc-utils/test_uuidd.c: In function 'create_nthreads':
misc-utils/test_uuidd.c:187:19: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
        proc->pid, (int) th->tid, th->index));

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agotests: handle non glibc error message for fallocate
Ruediger Meier [Wed, 31 May 2017 21:32:07 +0000 (23:32 +0200)] 
tests: handle non glibc error message for fallocate

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agotests: use stdbuf when stderr and stdout is randomly ordered
Ruediger Meier [Thu, 1 Jun 2017 01:17:25 +0000 (03:17 +0200)] 
tests: use stdbuf when stderr and stdout is randomly ordered

glibc seems to flush stdout before stderr.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agobuild-sys: fix library order when linking
Ruediger Meier [Wed, 31 May 2017 19:02:12 +0000 (21:02 +0200)] 
build-sys: fix library order when linking

We got some errors on Alpine Linux where $LTLIBINTL is non-empty:

./.libs/libcommon.a(libcommon_la-blkdev.o): In function `open_blkdev_or_file':
lib/blkdev.c:282: undefined reference to `libintl_gettext
collect2: error: ld returned 1 exit status

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
8 years agotests: avoid diff of diffs
Ruediger Meier [Wed, 31 May 2017 20:21:46 +0000 (22:21 +0200)] 
tests: avoid diff of diffs

Certain diff implementations do not produce comparable output.

Noticed on Alpine Linux/busybox.

CC: Sami Kerola <kerolasa@iki.fi>
Reported-by: Assaf Gordon <assafgordon@gmail.com>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>