Commit Graph

1143 Commits

Author SHA1 Message Date
Karel Zak b97edfe731 build-sys: use REALTIME_LIBS
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-09 11:31:49 +02:00
Karel Zak b85df4b738 uuidd: use cxt->quiet
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-09 11:26:28 +02:00
Karel Zak 4b09b1c253 uuidd: fix compiler warning [-Wsign-compare]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-09 11:23:16 +02:00
Sami Kerola fd346daf89 uuidd: fix shadow declaration
misc-utils/uuidd.c:384:13: warning: declaration of 'ret' shadows a previous
			   local [-Wshadow]
misc-utils/uuidd.c:327:6: note: shadowed declaration is here

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-10-09 11:17:12 +02:00
Sami Kerola 25d66b4e32 uuidd: use signalfd() and setup_timer()
Point of this change is to replace use of signal() and alarm() system calls
using newer interfaces.  Nice side effect is that the point where timer was
earlier used cannot be distracted by sending rogue SIGALRM.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-10-09 11:17:11 +02:00
Sami Kerola 67791b7787 blkid, uuidd, uuidgen: assume getopt.h and getopt.h are available
These headers are in use allover this project without issues.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-10-09 11:17:09 +02:00
Sami Kerola 61b6427638 uuidd: slice up the usage text and normalize its layout
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-10-09 11:17:08 +02:00
Karel Zak fc20393cdb logger: fix messages separation on UNIX socket
The function write_output() add additional \n after each message on
TYPE_TPC. This is required by syslog daemons, otherwise you will see
multiple log messages merged together in your log file, for example:

  Oct  6 09:01:40 ws kzak: AAA<14>Oct  6 09:01:40 kzak: BBB

for

  printf "AAA\nBBB\n" | logger -p info -u <any-socket>

Unfortunately, the connection initialization functions keep the
default ALL_TYPES as connection type and nowhere in the control struct
is info about the final real connection type. The problem is invisible
when you specify --tpc or --udp on logger command line.

Addresses: https://github.com/karelzak/util-linux/issues/225
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-06 09:16:33 +02:00
Sami Kerola fa8945db4a uuidd: improve socket activation error messaging
Tell more exactly what is wrong and how, and give hint how to recover
when possible.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-10-02 12:38:30 +02:00
Karel Zak 4299ed1ce2 logger: add --sd-id and -sd-param
This patch add support for RFC 5424 structured data elements. For
example:

     logger --rfc5424 --sd-id zoo@123                \
                      --sd-param tiger=\"hungry\"    \
                      --sd-param zebra=\"running\"   \
                      --sd-id manager@123            \
                      --sd-param onMeeting=\"yes\"   \
                      "this is message"

produces:

     <13>1 2015-10-01T14:07:59.168662+02:00 ws kzak - - [timeQuality tzKnown="1" isSynced="1" syncAccuracy="218616"][zoo@123 tiger="hungry" zebra="running"][manager@123 onMeeting="yes"] this is message

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-01 14:48:15 +02:00
Michal Schmidt b632f55c29 logger: improve logger --journald man page example
The example use of logger --journald in the man page has a couple of flaws:
 - It's missing a "MESSAGE=" field. This is supposed to be the primary
   human readable text. Without it the log entry is invisible in a
   plain "journalctl" output.
 - The MESSAGE_ID is supposed to be a 128-bit hexadecimal string that
   globally uniquely identifies the message type.
   One can generate such an id with "journalctl --new-id".

This patches fixes the above and also changes the example to use a
here-document instead of printf. In my opinion it makes the expected
multi-line data format more obvious.

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
2015-09-07 08:54:15 +02:00
Sami Kerola 03f8bc1f32 cal: check biggest week number correctly when highlighting
This allows Sunday based week 54 be highlighted, and deny week 54 for
Monday based weeks when year has only 52 weeks.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-08-31 10:15:12 +02:00
Sami Kerola e1abe57e18 cal: replace magic constants with symbolical values
This makes it easier to know what the values in guestion represent.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-08-31 10:15:11 +02:00
Sami Kerola efafeaf684 cal: correct gregorian week numbering
Jan 1 is always First week, and year always has 53 weeks.  The week 53
may be cut short, e.g., it may and often has fewer than 7 days.  Every
year 28 year intervals US week numbering continues all the way to 54th
week, such as 1972, 2000, and 2028.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1249486
Reported-by: Michal Toth
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-08-31 10:15:09 +02:00
Andreas Henriksson 56e78cb532 lsblk: fix resource leak [coverity scan]
Signed-off-by: Andreas Henriksson <andreas@fatal.se>
2015-08-31 10:09:45 +02:00
Frederick Grose 8fef799d8b Fix typos in --target 2015-08-14 09:37:07 -04:00
Karel Zak 28bad822c4 logger: improve readability [smatch scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-08-05 13:23:34 +02:00
Benno Schulenberg 315be52f50 lslocks: slice up the recently modified usage text
For ease of translation when it changes.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-08-03 11:18:59 +02:00
Milan Broz c49ff158aa lsblk: Display mountpoint even for top-level device
If a filesystem is mounted on top-level block device
with existing partitions, the mountpoint is not displayed
in the lsblk output.

This situation can happen by a configuration mistake
and lsblk could be used to detect such a mistake.

This patch allows searching for a mountpoint for all displayed
devices, not only for leaf nodes.
(It should be pretty cheap operation, mtab is parsed only once.)

For example: lsblk /dev/loop1
NAME      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
loop1       7:1    0  128M  0 loop /mnt/tst
└─loop1p1 259:0    0  127M  0 loop

Signed-off-by: Milan Broz <gmazyland@gmail.com>
2015-07-31 10:44:57 +02:00
Karel Zak dd8dac1914 mcookie: fix -f usage [clang analyze]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-29 14:59:56 +02:00
Alex Bligh b6b67955ef logger: Add support to logger for RFC6587 octet counting
This patch adds support to logger for RFC6587 octet counting.
RFC6587 provides support for two sorts of framing:

1. Octet counting (at RFC6587 s3.4.1)

   In essence each frame is preceded by a decimal length and a
   space.

2. Non-transparent framing (at RFC6587 s3.4.2), also called
   'octet stuffing'

   In essence each frame is terminated by a `\n`

Prior to this patch, logger used option 2 (non-transparent framing)
on TCP, and used no framing on UDP. After this patch, the default
behaviour is unchanged, but if the '--octet-count' option is supplied,
option 1 is used for both TCP and UDP. Arguably octet count framing
makes little sense on UDP, but some servers provide it and this
allows testing of those servers.

Signed-off-by: Alex Bligh <alex@alex.org.uk>
2015-07-29 10:33:25 +02:00
Sami Kerola 9b83e7a48d logger: do not exit when socket errors are not enforced
The libc openlog(3) does not have error detection whether unix socket
could be opened.  As a side effect that made it possible to use logger
even if syslogd was not running.  Of course user message in these cases
were lost.  This change makes the logger do behave similar way again, so
that sysvinit scripts can successfully pipe messages to logger when ever.

Addresses: https://bugs.debian.org/787864
Addresses: https://bugs.debian.org/790875
Reported-by: Andreas Beckmann <anbe@debian.org>
Reported-by: Andreas Henriksson <andreas@fatal.se>
Tested-by: Robie Basak <robie.basak@ubuntu.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-07-20 10:54:44 +02:00
Raghavendra D Prabhu 1c23b1c5d3 kill: Add verbose to man page.
kill adds a verbose option to print the pid(s) and the signal. It is
added to man page here.
2015-07-03 09:11:04 +05:30
Sami Kerola 694562e3b8 getopt: use $(...) command substitution in example script [shellcheck]
Reference: https://github.com/koalaman/shellcheck/wiki/SC2006
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-29 12:06:12 +02:00
Boris Egorov 7508d991c5 libblkid/whereis: simplify some conditions [cppcheck]
[misc-utils/whereis.c:466]: (style) Redundant condition: uflag.
'A && (!A || B)' is equivalent to 'A || B'
[libblkid/src/tag.c:373]: (style) Redundant condition: dev.
'A && (!A || B)' is equivalent to 'A || B'

Signed-off-by: Boris Egorov <egorov@linux.com>
2015-06-25 12:08:50 +02:00
Andreas Henriksson 9fa6088aa9 rename: allow full-path renames
The command "touch b0;rename.ul -v ./b0 ./b1 ./b0" used to work
before "allow renaming in subdirectories" change.
(regression in commit bd9ced628b)

Addresses: https://bugs.debian.org/789240
Reported-by: gregrwm <bug-grub@whitleymott.net>
Reviewed-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Andreas Henriksson <andreas@fatal.se>
2015-06-25 12:01:36 +02:00
Benno Schulenberg e10f0d073f cal: correct the man page: the reformation eliminated eleven days, not ten
Also tweak some other wordings and formatting.

Reported-by: Felix Neumann <felix.neumann@inka.de>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-06-25 11:56:59 +02:00
Karel Zak 3c1a1bad73 logger: add note about kern->user conversion
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-24 12:17:32 +02:00
Karel Zak b3a2e889df lslocks: add --json
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-05 10:45:15 +02:00
Karel Zak 8449f2cb59 findmnt: add --json
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-05 09:47:59 +02:00
Karel Zak 4a102a4871 lsblk: add --json
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-04 15:49:52 +02:00
Stanislav Brabec a79b7cab66 lsblk.8: Fix description of output format
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2015-06-02 11:58:53 +02:00
Karel Zak 92441d5c1e lsblk: use internally sysfs devnames
It seems better to keep the strange sysfs devnames internally and
translate to real devnames only on output or when we read from /dev.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-05-29 10:55:01 +02:00
Karel Zak 6c62abc42b lib/sysfs: rename devname functions, cleanup
Well, I don't have mental power to use function names like

 sysfs_devname_to_dev_name()

so this patch renames to

 sysfs_devname_sys_to_dev()
 sysfs_devname_dev_to_sys()

It also cleanups usage of the functions. We have to be sure that
sysfs.c code returns regular devnames. The existence of the sysfs
devnames (with '!') should be completely hidden in sysfs specific
code.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-05-28 12:09:41 +02:00
Stanislav Brabec d0dc6c17c5 Fix /sys to /dev node name translation
linux/drivers/base/core.c: device_get_devnode() defines a translation of
'!' in sysfs nodes to '/' in /dev nodes. The same translation has to be
done to properly support device nodes with slash (e. g. device nodes of
cciss driver and several other drivers).

Introduce new helper sysfs_devname_to_devno() and use it where
appropriate.

Fixes for example lsblk -f on devices using cciss driver.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2015-05-26 11:42:38 +02:00
Karel Zak 5ec4a890a1 blkid: another hint to the man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-05-21 13:13:49 +02:00
Karel Zak f36522da5f blkid: be more precise in the man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-05-21 12:37:18 +02:00
Karel Zak f8098e2b2c blkid: don't ignore info about partitions on non-formated devices
# blkid -p /dev/sdc1; echo $?
 2

but libblkid provides information about partition, fixed version:

 # blkid -p /dev/sdc1; echo $?
 /dev/sdc1: PART_ENTRY_SCHEME="dos" PART_ENTRY_UUID="4c1e518c-01" PART_ENTRY_TYPE="0x83" PART_ENTRY_NUMBER="1" PART_ENTRY_OFFSET="2048" PART_ENTRY_SIZE="1021952" PART_ENTRY_DISK="8:32"
 0

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-05-21 12:14:55 +02:00
Sami Kerola c5ad7b59ac cal: fix January 1753 week number printout
Earlier output was clearly broken.

$ cal -w 1 1753
      January 1753
   Su Mo Tu We Th Fr Sa
51     1  2  3  4  5  6
52  7  8  9 10 11 12 13
52 14 15 16 17 18 19 20
52 21 22 23 24 25 26 27
52 28 29 30 31

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-05-18 11:41:48 +02:00
Karel Zak 40b175084f lib/strutils: fix string_add_to_idarray() int vs. size_t
The function uses "int" as argument, but for array size (and index) is better
to use unsigned type (size_t). If we mix "size_t" in util (e.g. fdisk)
and "int" in lib/strutils.c then result is unexpected behavior on
ppc64.

	# sfdisk --list -o DEVICE,START,SIZE /dev/sdb
	Disk /dev/sdb: 50 MiB, 52428800 bytes, 102400 sectors
	Units: sectors of 1 * 512 = 512 bytes
	Sector size (logical/physical): 512 bytes / 4096 bytes
	I/O size (minimum/optimal): 4096 bytes / 32768 bytes
	Disklabel type: gpt
	Disk identifier: 3B8559DB-33AF-43E9-BEFC-C331D829B539
	lt-sfdisk: libfdisk/src/label.c:178: fdisk_label_get_field: Assertion `id > 0' failed.

The patch cleanup all code to use size_t everywhere.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-04-22 11:08:05 +02:00
Ruediger Meier bcf7e14939 logger: --stderr and --no-act turn "auto-errors" on
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2015-04-09 17:55:17 +02:00
Max Klinger 7800509b21 cal: add -Y and -n <num>
[kzak@redhat.com: - add month_in_row to avoid extra meaning of num_month=-3,
                  - add header_year
                  - add long option for -Y
                  - define conflicts between -Y, -y and -n
                  - remove ctl.yflag]

Co-Author: Karel Zak <kzak@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-04-07 15:18:38 +02:00
Mike Place b1c9817eff whereis: trivial spelling and grammar fix
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-04-07 10:44:50 +02:00
Sami Kerola c3dd2ecd5f logger: fix memory leaks
Reported-by: Patrick Plagwitz <patrick.plagwitz@fau.de>
Signed-off-by: Sami Kerola <sami.kerola@lastminute.com>
2015-04-07 08:58:19 +01:00
Patrick Plagwitz 4a8919a4e5 logger: generate header when reading message from stdin
This change fixes crashing error, that ought not to be simply avoided.

$ echo foo | logger -n localhost
Segmentation fault (core dumped)

If the ctl->hdr is just checked not to be NULL syslog message will not
have valid header, so generating such is not optional when reading
message from stdin and writing it to remote destination.

Reviewed-by: Bernhard Voelker <mail@bernhard-voelker.de>
Signed-off-by: Patrick Plagwitz <patrick.plagwitz@fau.de>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-04-07 08:51:05 +01:00
Karel Zak 296dc15c24 lsblk: don't ignore dependences for partitioned devies
The code only lists partitions, but ignore another dependencies
on whole-disk device:

	$ lsblk /dev/sdb
	NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
	sdb      8:16   0 298.1G  0 disk
	└─sdb1   8:17   0 298.1G  0 part

	$ ls /sys/block/sdb/holders/
	dm-0

fixed version:

	$ lsblk /dev/sdb
	NAME        MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
	sdb           8:16   0 298.1G  0 disk
	├─sdb1        8:17   0 298.1G  0 part
	└─mpatha    253:0    0 298.1G  0 mpath
	  └─mpatha1 253:1    0 298.1G  0 part

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-04-01 12:23:23 +02:00
Karel Zak 92abdcaee0 lsblk: follow kernel for inverse tree
For multi-path devices kernel defines dependence between the device
and whole-list:

	$ ls /sys/block/dm-0/slaves/
	sdb

but lsblk inserts partition into the tree:

	$ lsblk -s -oNAME,KNAME /dev/dm-1
	mpatha1   dm-1
	└─mpatha  dm-0
	  └─sdb1  sdb1     <--- !
	    └─sdb sdb

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-04-01 12:06:41 +02:00
Karel Zak 7e786ecae1 lsblk: add debug support
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-04-01 12:06:15 +02:00
Karel Zak 98e90a4901 logger: fix LOGGER_TEST_TIMEOFDAY check
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-03-23 11:40:45 +01:00
Karel Zak 0009f510cb findmnt: add --mountpoint command line option
The current --target <path> implementation check the <path> elements in
reverse order to get the mountpoint. The feature may be inwanted in
some cases when we really want to check for mountpoint specified by
the <path>. The new option "--mountpoint <path>" allows to be strict.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-03-19 12:12:21 +01:00