Ruediger Meier [Sun, 25 Jun 2017 12:49:47 +0000 (14:49 +0200)]
misc: consolidate all --help option descriptions
Now we are always using the same text also for commands
which had still hardcoded descriptions or where we can't
use the standard print_usage_help_options macro.
Ruediger Meier [Sat, 24 Jun 2017 22:19:50 +0000 (00:19 +0200)]
misc: introduce print_usage_help_options()
Consolidate --help and --version descriptions. We are
now able to align them to the other options.
We changed include/c.h. The rest of this patch was
generated by sed, plus manually setting the right
alignment numbers. We do not change anything but
white spaces in the --help output.
Karel Zak [Mon, 26 Jun 2017 13:58:37 +0000 (15:58 +0200)]
Merge branch 'usage-part2' of https://github.com/rudimeier/util-linux
* 'usage-part2' of https://github.com/rudimeier/util-linux:
misc: cosmetics, remove argument from usage(FILE*)
misc: cosmetics, remove argument from usage(int)
misc: never use usage(stderr)
misc: never use usage(ERROR)
misc: cleanup and fix --unknownopt issues
flock, getopt: write --help to stdout and return 0
tools: add checkusage.sh
Sami Kerola [Sun, 18 Jun 2017 17:16:35 +0000 (17:16 +0000)]
uuidparse: add new command
This command will analyze and print information about UUID's. The command
is based on libuuid/src/uuid_time.c but modified to use libsmartcol.
[kzak@redhat.com: - minor coding style changes]
Reference: http://marc.info/?l=util-linux-ng&m=149735980715600&w=2 Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
Ruediger Meier [Tue, 20 Jun 2017 18:20:29 +0000 (20:20 +0200)]
misc: cosmetics, remove argument from usage(FILE*)
This patch is trivial and changes nothing, because
we were always using usage(stdout)
Now all our usage() functions look very similar. If wanted we
could auto-generate another big cosmetical patch to remove all
the useless "FILE *out" constants and use printf and puts
rather than their f* friends. Such patch could be automatically
synchronized with the translation project (newlines!) to not
make the translators sick.
Ruediger Meier [Sun, 18 Jun 2017 22:02:44 +0000 (00:02 +0200)]
flock, getopt: write --help to stdout and return 0
... and use errtryhelp() instead of usage().
Note in past "getopt --help" returned 2. But it is otherwise
documented and was just a mistake IMO. See the unreachable exit(0)
which was removed here: d1d03b54
Ruediger Meier [Sun, 18 Jun 2017 13:19:39 +0000 (15:19 +0200)]
tools: add checkusage.sh
Just some simple generic tests for our UL commands, regarding
options --help, --version and --unknownopt.
The script looks still a bit weired but could be polished to
be used in tests/. It would be the first time testing at least
"something" for *all* built binaries (currently 109! commands).
For the record here are the current candidates with possible
problems:
$ make checkusage
agetty: --unknownopt, stderr too long: 45
blockdev: --unknownopt, stderr too long: 28
flock: --help, no stdout
flock: --help, non-empty stderr
getopt: --help, returns error
kill: --unknownopt, stderr too short: 1
lsipc: --unknownopt, stderr too long: 77
pg: --unknownopt, stderr too long: 23
renice: --unknownopt, stderr too long: 18
rtcwake: --unknownopt, non-empty stdout
rtcwake: --unknownopt, stderr too long: 21
sulogin: --unknownopt, stderr too long: 17
write: --unknownopt, stderr too long: 12
Karel Zak [Mon, 26 Jun 2017 11:56:45 +0000 (13:56 +0200)]
Merge branch '170622' of github.com:jwpi/util-linux
* '170622' of github.com:jwpi/util-linux:
Docs: move option naming to howto-contribute.txt
Docs: update howto-usage-function.txt
Docs: add a comment for constants to boilerplate.c
include/c.h: add USAGE_COMMANDS and USAGE_COLUMNS
Karel Zak [Mon, 26 Jun 2017 11:42:25 +0000 (13:42 +0200)]
Merge branch 'usage-part1' of https://github.com/rudimeier/util-linux
* 'usage-part1' of https://github.com/rudimeier/util-linux:
misc: no more errtryh()
mkfs.cramfs: add --help and --version
more: add --help and --version
whereis: add --help and --version
login: add --help and --version
fsck: add --help and --version
setarch: use errtryhelp()
dmesg: do not accept any non-option arguments
blkid: use errtryhelp instead of errtryh
misc: remove superfluous null pointer checks for optarg
uuidd: remove unused define
Creating and naming options is not done when writing usage().
A contributor may not even read howto-usage-function.txt, but
they should read howto-contribute.txt. So move option naming
and change information there.
Signed-off-by: J William Piggott <elseifthen@gmx.com>
Karel Zak [Fri, 23 Jun 2017 12:26:47 +0000 (14:26 +0200)]
agetty: fix login name DEL/CTRL^U issue
agetty refresh prompt (/etc/issue file etc.) when requested by inotify
or netlink. For this purpose we monitor some file descriptors by
select().
The terminal input file descriptor is switched to non-canonical mode before
select(). The goal is to be informed about user activity before
new-line. The FD is immediately switched back to canonical mode when
activity is detected. The side effect is that all not-read-yet chars in
the input buffer are lost ... so we need to call read() before switch
to canonical mode to save the chars.
The original implementation has been based on TIOCSTI ioctl. It
returns already read chars back to the terminal input buffer to make
them useful for canonical mode. The problem was race (agetty writes to
input buffer in the same time as user) and result was reordered chars
in login name... so useless.
This issue has been later fixed by extra buffer (commit 790119b8850ae13bb4254c5096a54b2aeb355b20) for already read data. And
TIOCSTI ioctl has been removed. Unfortunately this solution is also
wrong, because the buffer is maintained only by agetty and
inaccessible for terminal when user edit (by DEL/CTRL^U) login name in
canonical mode.
The solution is simple -- just don't try to be smart and keep terminal
in canonical mode all time (so terminal controls DEL, CTRL^U, etc) and
flush input buffer (=discard unread data) and ask user for login name
again after prompt reload.
The agetty reload is very rarely situation and for user it's pretty
obvious that he has to type login name again (as all terminal has been
clear+redraw).
Addresses: https://github.com/karelzak/util-linux/issues/454
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1464148 Signed-off-by: Karel Zak <kzak@redhat.com>
Ivan Delalande [Wed, 21 Jun 2017 23:43:05 +0000 (16:43 -0700)]
dmesg: print only 2 hex digits for each hex-escaped byte
As buf is passed as a signed char buffer in fwrite_hex, fprintf will
print every byte from 0x80 as a signed-extended int causing each of
these bytes to be printed as "\xffffff80" and such, which can be pretty
confusing. Force fprintf to use the argument as a char to make it print
only 2 digits, e.g. "\x80".
Pali Rohár [Thu, 22 Jun 2017 08:38:24 +0000 (10:38 +0200)]
tests: Add UDF hdd image which label has length 30 characters
Structure dstring for label has 32 bytes, first byte is 8 (Compression ID),
last byte is 30 (count of 8bit characters in label). Therefore label is not
nul terminated and dstring parser needs to handle it (fixed in previous
commit).
Pali Rohár [Thu, 22 Jun 2017 08:38:08 +0000 (10:38 +0200)]
libblkid: udf: Fix parsing of UDF dstring structures
First byte of dstring is OSTA Compression ID and the last byte is length of
recorded bytes (including first byte). Last byte is not a part of recorded
characters, therefore it should not be treated as data to decode.
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>