Karel Zak [Wed, 21 Jun 2017 09:54:51 +0000 (11:54 +0200)]
Merge branch 'master' of https://github.com/pali/util-linux
* 'master' of https://github.com/pali/util-linux:
tests: Add UDF hdd images with blocksize 1024 and 4096 created by Linux mkudffs 1.3
libblkid: udf: Fix detection of UDF images with block size 1024 and 4096
Karel Zak [Wed, 21 Jun 2017 09:16:23 +0000 (11:16 +0200)]
Merge branch '170427' of github.com:jwpi/util-linux
* '170427' of github.com:jwpi/util-linux:
hwclock: remove unused stdarg.h
Docs: update howto-usage-function.txt
hwclock: add --update-drift check
hwclock: slice up the usage text
hwclock: update --help content and grammar
hwclock: use RTC in help output
include: update pathnames.h
hwclock: add usage() functions heading
hwclock: update usage() FILE name
hwclock: update usage() to util-linux style
hwclock: remove dead code in usage()
Karel Zak [Wed, 21 Jun 2017 08:53:28 +0000 (10:53 +0200)]
wipefs: exit on failed erase
The current behavior is to report error and continue, it seems strange:
# blockdev --setro /dev/sdc
# wipefs -a /dev/sdc
wipefs: /dev/sdc: failed to erase xfs magic string at offset 0x00000000: Operation not permitted
/dev/sdc: 4 bytes were erased at offset 0x00000000 (xfs): 58 46 53 42
^^^^^^^^^^^
not true
The patch calls err() to exit.
Reported-by: Vratislav Podzimek <vpodzime@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* 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>
Karel Zak [Tue, 20 Jun 2017 10:46:02 +0000 (12:46 +0200)]
libmount: ignore "bind" from fstab on command line "remount"
The current code always apply all flags from /etc/fstab on remount.
Unfortunately remount+bind has special semantic and it's impossible
from command line to avoid interaction with the "bind" from fstab.
This changes the per-mountpoint (VFS) ro flag to rw, but doesn't
change the filesystem itself.
This patch forces libmount to ignore "bind" from fstab when "-o
remount" specified on command line. If you need remount+bind semantic
you have to specify the "bind" flag on command line. This allow to
differentiate between
# mount /foo -o remount,bind,rw --> mount(MS_REMOUNT|MS_BIND)
and
# mount /foo -o remount,rw --> mount(MS_REMOUNT)
Suggested-by: NeilBrown <neilb@suse.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Vinnie Magro [Mon, 19 Jun 2017 21:45:02 +0000 (14:45 -0700)]
dmesg: fragment concatenation
When extended console is enabled, the kernel doesn't internally
concatenate message fragments, this change adds log fragment
concatenation to dmesg: instead of being printed as separate messages,
fragments are combined onto one line and printed with the timestamp of
the first line.
This doesn't work in all cases - such as if another message is logged in
between two fragment lines, but in this case the behavior matches the
previous output format (printed on the separate lines).
[kzak@redhat.com: - rename kmsg_read_buf to kmsg_saved_size,
- minor coding style fixes]
Signed-off-by: Vinnie Magro <vmagro@fb.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 20 Jun 2017 08:20:49 +0000 (10:20 +0200)]
Merge branch '170424' of github.com:jwpi/util-linux
* '170424' of github.com:jwpi/util-linux:
parse-date: time_zone_hhmm() bug fixes
parse-date: remove unused ordinal_day_seen
parse-date: remove unused year_seen
parse-date: refactor tm_diff()
parse-date: use to_uchar() instead of assignment.
parse-date: use uintmax_t where appropriate
parse-date: use int where appropriate
parse-date: use intmax_t where appropriate
parse-date: remove unused EPOCH_YEAR
parse-date: replace ISDIGIT with c_isdigit
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
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.
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.
Pali Rohár [Wed, 14 Jun 2017 21:15:14 +0000 (23:15 +0200)]
libblkid: udf: Fix detection of UDF images with block size 1024 and 4096
When detecting block size of UDF filesystem, try to use also block size
512, 1024, 2048 and 4096. This would allow blkid to detect UDF filesystem
in image file created from 4K hard disk (which should have UDF block size
4096).
Before this patch only UDF images with block size of 512 and 2048 were
detected as only block size from blkid_probe_get_sectorsize() and 2048 were
used (blkid_probe_get_sectorsize() returns for disk images 512).
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>
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.
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
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'.
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>
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>
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))
^~~~~~~~~~~~
../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);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../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);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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);
^~~~~~~
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>
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))
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>
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.
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