logger: add support for --prio-prefix when logging stdin

This patch adds a new option to logger that will make it look for a
priority prefix <n> at the beginning of every line. The priority is
a single decimal number formed as explained in syslog(3).

If a prefix is found logger will log the message using the found
facility and level in that prefix, if the prefix doesn't contain a
facility the default facility specified by the -p option will be used.
If no prefix is found, logger will use the priority specified by -p.

[kzak@redhat.com: - add --prio-prefix to usage() output]

Signed-off-by: Dennis H Jensen <dennis.h.jensen@siemens.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
logger: cleanup usage()

Signed-off-by: Karel Zak <kzak@redhat.com>
logger: small coding style changes

Signed-off-by: Karel Zak <kzak@redhat.com>
su: ignore --preserve-environment, it's mutually exclusive to --login

Addresses: http://bugs.gnu.org/10317
Reported-by: Bernhard Voelker <mail@bernhard-voelker.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount: more robust options string parsing

 # mount -o=rw /dev/sdb /mnt/test
 mount: libmount/src/optmap.c:212: mnt_optmap_get_entry: Assertion `namelen' failed.
 Aborted (core dumped)

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=968786
Signed-off-by: Karel Zak <kzak@redhat.com>
lib: remove unused code

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
lscpu: add max MHz value to make cpu governor effects more visible

The existing 'CPU MHz' is usually dynamic value, which CPU governor
changes up on needs of CPU demand.  Assuming lscpu is used to gather
information to a hardware inventory the dynamic value is misleading.  For
inventing the maximum MHz value is more sensible.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
docs: add lscpu max mhz to manual and bash completion

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
sfdisk: use libc error printing function, and symbolic exit values

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
sfdisk: clean up usage() functions

Includes removal of unhide usage function, which was never implemented.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
sfdisk: use program_invocation_short_name to determine program name

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
docs: correct sfdisk --activate instructions

The activate can be enabled by renaming the command to 'activate'.  Quite
confusingly the option and command arguments are interchangeable, and
depending on which one is defined as --activate option argument the
command will behave different rather different ways.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
sfdisk: remove --unhide and related functions

The --unhide was never implemented, and did not do anything.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
sfdisk: replace my_warn() with warnx()

This change adds program name in front of error messages.  Often that
helps user to know which command sent message, when the command is
executed as part of script.

Unfortunately the prefixing may break scripts, as there is no knowledge
whether some scripts are expecting not command name prefixed error
messages from this utility.  Same in programmer terms; the change
contains ABI change.

Karel: could you sign-off abi change, if not please drop this patch.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
rev: stop adding new line at the end when input does not have it

When the rev(1) is executed twice outcome is expected to be exactly what
it was originally.  That includes not adding new line at the end of the
output.  The oneliner below demonstrates earlier issue.

$ printf "abc\n123" | rev | rev

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
rev: simplify new line detection and impossible test

The new line detection is earlier using only '\n' so there should not be
need to search for '\r' later.

The detection whether allocated address is pointing to null seems to be
unnecessary.  Assuming xmalloc() returned valid address space the address
should never be 0.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
rev: reduce stream checking when closing read-only file descriptor

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
dmesg: add iso-8601 time format

The ISO-8601 should be welcomed by anyone who tries to parse dmesg time
stamp, and compare them across servers.  Time format tries to imitate
coreutils 'date --iso-8601=ns' output, but instead of having nanoseconds
the dmesg is using microseconds.

Reference: http://www.cs.tut.fi/~jkorpela/iso8601.html
Addresses: http://xkcd.com/1179/
Signed-off-by: Sami Kerola <kerolasa@iki.fi>