Commit Graph

1773 Commits

Author SHA1 Message Date
Michael Kerrisk (man-pages) ade04bb89c Manual pages: order AUTHORS / COPYRIGHT / SEE ALSO / AVAILABILITY consistently
There is value in ensuring that manual page sections use consistently
named sections, as far as possible, and also that sections have a
consistent order within manual pages. This is one of a series of patches
to place manual page sections in a consistent order.

In this patch, we ensure that the AUTHORS, COPYRIGHT, SEE ALSO, and
AVAILABILITY sections are always placed at the end of the page.

Testing that no gross editing mistake (causing accidental loss or addition
of text) was performed as follows:

    $ cat $(grep '\.SH' -l $(find . -name '*.[1-9]') |sort) | sort > a
    [Apply patch]
    $ cat $(grep '\.SH' -l $(find . -name '*.[1-9]') |sort) | sort > b
    $ diff a b
    $ echo $?
    0

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-22 10:25:49 +02:00
Michael Kerrisk (man-pages) a87f49f662 Manual pages: use the term "exit status"
The manual pages currently use a multitude of terms--"exit code",
"error code", "return code", "exit code", and so on--when what
is always meant is "exit status" (the POSIX term). This patch fixes
as many of these erroneous terms as I could find.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-20 12:56:52 +02:00
Michael Kerrisk (man-pages) 7e765c93dc Manual pages: Standardize on EXIT STATUS as section title
There is quite some value (in terms of readability and user
expectations) if consistent names are used for the sections
within manual pages. This patch is one of a series to bring
about this consistency.

Currently we have EXIT STATUS (18), EXIT CODES (3), RETURN CODE (7),
RETURN CODES (1), or RETURN VALUE (4 instances in pages that document
commands, rather than functions).

Let's standardize on the EXIT STATUS (which is also what is
suggested in man-pages(7), and is the POSIX terminology).

A subsequent patch will clean up corresponding miswordings in
manual page text.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-20 12:56:12 +02:00
Michael Kerrisk (man-pages) ef293e185e Manual pages: Standardize on CONFORMING TO as section title
There is quite some value (in terms of readability and user
expectations) if consistent names are used for the sections
within manual pages. This patch is one of a series to bring
about this consistency.

Currently we have STANDARDS (3) or CONFORMING TO (6).
Let's standardize on the latter (which is also what is
suggested in man-pages(7)).

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-20 12:56:12 +02:00
Michael Kerrisk (man-pages) bc281b0991 Manual pages: Standardize on EXAMPLE as section title
There is quite some value (in terms of readability and user
expectations) if consistent names are used for the sections
within manual pages. This patch is one of a series to bring
about this consistency.

Currently we have EXAMPLE (10) or EXAMPLES (23).
Let's standardize on the EXAMPLE (which is also what is
suggested in man-pages(7)) and used consistently across
a large number of pages in the Linux man-pages project.

(I realize the choice to go EXAMPLE, rather than EXAMPLES,
may be debatable. If necessary, I'd write a patch that instead
goes the other way, but I'd prefer to follow man-pages(7).)

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-20 12:56:12 +02:00
Michael Kerrisk (man-pages) a8d0d330cf Manual pages: Standardize on AUTHORS as section title
There is quite some value (in terms of readability and user
expectations) if consistent names are used for the sections
within manual pages. This patch is one of a series to bring
about this consistency.

In the Linux man-pages project, I long ago did away with the
AUTHOR(S) section, but I realize some projects like to keep this.

But, let's make sure that the section is consistently titled
across pages. Currently we have AUTHOR (47) or AUTHORS (41).
Let's standardize on the latter (which is also what is
suggested in man-pages(7)).

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-20 12:56:12 +02:00
Michael Kerrisk (man-pages) 5a82980632 docs: (man) remove double quotes (") in .SH lines
Using double quotes in .SH lines containing multiple words is unneeded,
and in any case is not consistently done in the util-linux manual pages,
where double quotes are used in only around half of the cases.
(This usage was long ago elminated in the man-pages project, with
no ill effects reported to date.)

Remove these quotes, so that .SH lines are more uniform, in preparation
for some (more easily) scripted doiscovery of consistency problems in
(and possibly global fixes to) the manual pages.

Other than stripping the double quotes, this patch makes no changes to
the content of the manual pages.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-19 12:15:34 +02:00
Karel Zak 9cdd10e82a Merge branch 'cal_column' of https://github.com/utix/util-linux
* 'cal_column' of https://github.com/utix/util-linux:
  cal: Remove todo
  cal: Add test, all are checked against ncal
  cal: Update man page
  cal: Add column mode
  cal: Add helper functions for left align
  cal: Add weekdays into cal_control
2020-05-18 11:21:22 +02:00
Bjarni Ingi Gislason c5178f2796 docs: Some minor fixes in some manuals
Output is from: test-groff -b -e -mandoc -T utf8 -rF0 -t -w w -z

  [ "test-groff" is a developmental version of "groff" ]

Input file is ././misc-utils/kill.1

<./misc-utils/kill.1>:173 (macro BR): only 1 argument, but more are expected

Input file is ././misc-utils/lsblk.8

troff: backtrace: '/home/bg/git/groff/build/s-tmac/an-old.tmac':478: macro 'BR'
troff: backtrace: file '<./misc-utils/lsblk.8>':122
troff: <./misc-utils/lsblk.8>:122: warning: trailing space

Input file is ././sys-utils/mount.8

an-old.tmac: <./sys-utils/mount.8>:2427 (.RE): warning: extra .RE or .RS is missing before it; "an-RS-open" is 0.

Input file is ././sys-utils/unshare.1

<./sys-utils/unshare.1>:176 (macro BR): only 1 argument, but more are expected
<./sys-utils/unshare.1>:181 (macro BR): only 1 argument, but more are expected
<./sys-utils/unshare.1>:240 (macro BR): only 1 argument, but more are expected
<./sys-utils/unshare.1>:246 (macro BR): only 1 argument, but more are expected

Input file is ././term-utils/agetty.8

troff: backtrace: file '<./term-utils/agetty.8>':130
troff: <./term-utils/agetty.8>:130: warning: trailing space

Input file is ././text-utils/more.1

troff: backtrace: file '<./text-utils/more.1>':91
troff: <./text-utils/more.1>:91: warning: macro 'b' not defined

  The output from nroff and troff is unchanged, except for the word
"number" in text-utils/more.1, that was missing.

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2020-05-18 10:35:25 +02:00
Ritika Srivastava c8487d854b lsblk: Ignore hidden devices
Lsblk throws the following error for nvmeNcXnY devices.

lsblk: nvme1c1n1: unknown device name

This is because nvmeNcXnY devices are hidden and do not have
the file /sys/block/<nvmeNcXnY>/dev.

Following patch was added
https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git/commit/?id=d51f05bfecb299a830897106460bf395be440c0a
Which made lsblk read from /sys/block/<nvmeNcXnY>/device/dev
which do exist for nvmeNcXnY devices.

After the above patch, the unknown error goes away.
However, another error is encountered in the very next step.

nvme1c1n1: failed to initialize sysfs handler

This is because lsblk looks for /sys/dev/block/242:1
(nvmeNcXnY major:minor) pathname which usually exists for other
block devices but not for the nvmeNcXnY devices as they are hidden.

Below patch does not even print this error for hidden devices
and exits silently.

[kzak@redhat.com: - add prefix to make sysfs_devname_is_hidden()
                    usable for  /sys dumps
                  - use the function in initialize_device() more early]

Signed-off-by: Ritika Srivastava <ritika.srivastava@oracle.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-05-14 15:48:26 +02:00
Aurelien LAJOIE 29d3a8f346 cal: Update man page 2020-05-11 17:41:33 +02:00
Aurelien LAJOIE 27fafcf8a8 cal: Add column mode
Add`-v` `--vertical` option to get a vertical output
Add it into relative bash-completion

For example `cal -yv`

                             2020

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

    April              May                June
Su     5 12 19 26         3 10 17 24 31      7 14 21 28
Mo     6 13 20 27         4 11 18 25      1  8 15 22 29
Tu     7 14 21 28         5 12 19 26      2  9 16 23 30
We  1  8 15 22 29         6 13 20 27      3 10 17 24
Th  2  9 16 23 30         7 14 21 28      4 11 18 25
Fr  3 10 17 24         1  8 15 22 29      5 12 19 26
Sa  4 11 18 25         2  9 16 23 30      6 13 20 27

    July               August             September
Su     5 12 19 26         2  9 16 23 30      6 13 20 27
Mo     6 13 20 27         3 10 17 24 31      7 14 21 28
Tu     7 14 21 28         4 11 18 25      1  8 15 22 29
We  1  8 15 22 29         5 12 19 26      2  9 16 23 30
Th  2  9 16 23 30         6 13 20 27      3 10 17 24
Fr  3 10 17 24 31         7 14 21 28      4 11 18 25
Sa  4 11 18 25         1  8 15 22 29      5 12 19 26

    October            November           December
Su     4 11 18 25      1  8 15 22 29         6 13 20 27
Mo     5 12 19 26      2  9 16 23 30         7 14 21 28
Tu     6 13 20 27      3 10 17 24         1  8 15 22 29
We     7 14 21 28      4 11 18 25         2  9 16 23 30
Th  1  8 15 22 29      5 12 19 26         3 10 17 24 31
Fr  2  9 16 23 30      6 13 20 27         4 11 18 25
Sa  3 10 17 24 31      7 14 21 28         5 12 19 26
2020-05-11 17:27:06 +02:00
Aurelien LAJOIE 4de7efb505 cal: Add helper functions for left align 2020-05-11 17:25:34 +02:00
Aurelien LAJOIE 0c440bd7a2 cal: Add weekdays into cal_control 2020-05-11 17:23:37 +02:00
Karel Zak 885336d9dc wipefs: fix man page --no-headings short option
Addresses: https://github.com/karelzak/util-linux/issues/1029
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-05-06 15:18:52 +02:00
Anthony Iliopoulos b239651bba lsblk: add dax (direct access) capability column
Signed-off-by: Anthony Iliopoulos <ailiop@suse.com>
2020-05-06 15:09:39 +02:00
Sven Wiltink e81d0f8006 lsblk: Fall back to ID_SERIAL
In some cases ID_SERIAL_SHORT isn't provided by libudev, but ID_SERIAL
is. An example of this are virtio devices. See the output of udevadm
info:
P: /devices/pci0000:00/0000:00:06.0/virtio2/block/vdb
N: vdb
S: disk/by-id/virtio-08491434ee711d3420e9
S: disk/by-path/pci-0000:00:06.0
S: disk/by-path/virtio-pci-0000:00:06.0
E: DEVLINKS=/dev/disk/by-id/virtio-08491434ee711d3420e9 /dev/disk/by-path/pci-0000:00:06.0 /dev/disk/by-path/virtio-pci-0000:00:06.0
E: DEVNAME=/dev/vdb
E: DEVPATH=/devices/pci0000:00/0000:00:06.0/virtio2/block/vdb
E: DEVTYPE=disk
E: ID_PATH=pci-0000:00:06.0
E: ID_PATH_TAG=pci-0000_00_06_0
E: ID_SERIAL=08491434ee711d3420e9
E: MAJOR=252
E: MINOR=16
E: SUBSYSTEM=block
E: TAGS=:systemd:
E: USEC_INITIALIZED=1403804

[kzak@redhat.com: - add ID_SERIAL also to get_properties_by_file()]

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-05-04 11:21:01 +02:00
Rosen Penev ad296391f9
[clang-tidy] fix wrong *cmp usage
Found with bugprone-suspicious-string-compare

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-20 13:21:00 -07:00
Rosen Penev 042f62dfc5
[clang-tidy] do not use else after return
Found with readability-else-after-return

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-20 13:20:59 -07:00
Rosen Penev bd89499e07
[clang-tidy] do not return in void functions
Found with readability-redundant-control-flow

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-19 14:03:21 -07:00
Aurelien LAJOIE a5e322f4f4 cal: correctly set the week width
There is seven values but only 6 spaces between them, that why the -1
The value is always used with a minus one, just set it correctly instead
of always fix when used

Signed-off-by: Aurelien LAJOIE <orel@melix.net>
2020-03-31 15:32:01 +02:00
Aurelien LAJOIE b908299188 cal: Correctly center the year
Signed-off-by: Aurelien LAJOIE <orel@melix.net>
2020-03-31 15:31:54 +02:00
Aurelien LAJOIE c1f1439316 cal: use a const char*
A put string function should not modify the char*

Signed-off-by: Aurelien LAJOIE <orel@melix.net>
2020-03-31 15:31:52 +02:00
Sami Kerola 735fd5ed2b
docs: kill.1 add note about shell-internal kill implementations
Requested-by: Ilia Baryshnikov <qwelias@gmail.com>
Reference: https://github.com/karelzak/util-linux/issues/991#issuecomment-602108648
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-03-22 09:37:41 +00:00
Karel Zak c6d8486aad findmnt: make xalloc use mroe robust
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1807003
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-02-27 10:02:39 +01:00
Karel Zak 91b636b565 lsblk: fix -P regression from v2.34
Since v2.34 --list prints devices only once to make the output
user-readable. Unfortunately, it's regression for scripts/applications
where we need to parse lsblk output. So, let's make --pairs and --raw
backwardly compatible with versions before 2.34 and print all hierarchy.

Addresses: https://github.com/ibm-s390-tools/s390-tools/issues/80
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-02-25 15:31:23 +01:00
Sami Kerola f6b6beaf6a
various: fix more lgtm scan warnings
The logger and rtwake time function changes continue the same fixes as
previous commit - use thread safe functions.  The libsmartcols condition
removal is possible because width must be greater than tb->termwidth that is
size_t and cannot be smaller than zero.  And remove couple FIXME's that are
old and unlikely ever to get fixed.

Reference: 3160589d86
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-20 20:18:46 +00:00
Sami Kerola 44702f12f7
getopt: use examples installation directory in man page
Addresses: https://bugs.debian.org/913049
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-15 15:24:01 +00:00
Sami Kerola 3160589d86
various: use threadsafe versions of time functions [lgtm scan]
Deprecating calls to not-thread safe asctime(), ctime(), and localtime()
calls is pretty close to pointless change.  Lets do it to reduce lgtm scan
warnings with justification it's nicer to use static analysis tools when
they have very few positives.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-15 15:23:44 +00:00
Karel Zak f1970cc557 docs: improve size arguments description in --help output
Let's add "Arguments:" section to the --help output and describe
{K,M,G...}iB suffixes there.

Addresses: https://github.com/karelzak/util-linux/pull/917
Co-Author: ed <ed@s5h.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-02-05 11:01:36 +01:00
Karel Zak dc30fd4383 libblkid: check for medium on CDMROMs probing
The commit 39f5af2598 introduces
O_NONBLOCK to avoid the tray close on open(). The side effect is that
open() is successful when there is no medium.

This is usually no problem for standard tools because the next read()
will fail. Unfortunately, libblkid ignores I/O errors for (and only
for) CDROMs to support some crazy hybrid data+audio disks. The final
result is many I/O errors in system log when O_NONBLOCK is enabled.

This patch add CDROM_DRIVE_STATUS to stop probing when there is no
disk or when the tray is open.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1787973
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-01-07 16:48:34 +01:00
Karel Zak 261cf85627 cal: (man) make -w, -m and --iso relation more obvious
Reported-by: Leah Neukirchen <leah@vuxu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-01-03 12:04:00 +01:00
Bjarni Ingi Gislason 1c4c602427 man pages: Change a HYPHEN-MINUS (-) to a minus (\-) for options and numbers
Change a HYPHEN-MINUS (code 0x55, 2D) to a minus (\-), if in front of

1) a name of an option

2) a negative number to be printed.

  See man-pages(7) [Debian package "manpages"].

  The output from "nroff" is unchanged.

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2019-12-17 12:32:43 +01:00
Bjarni Ingi Gislason eb02489380 man pages: Add a comma after "e.g." and "i.e."
Add a comma (,) after "e.g." and "i.e.", or use English words
(man-pages(7) [package "manpages"]).

  Abbreviation points should be protected (usually with the
non-printing, zero width character '\&') from being interpreted as an
end of sentence, if they are not, and that independent of their current
place on the line.

  This is important when typing, as one does not usually know in
advance when the editor jumps to a new line.

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2019-12-17 12:32:43 +01:00
Karel Zak bba1a60198 kill: add another ifdef
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-10 11:07:30 +01:00
Karel Zak 8aab38783a kill: add missing ifdefs
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-09 16:20:06 +01:00
Karel Zak ded3735ef4 kill: deallocate follow_ups [assan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-09 13:20:04 +01:00
Karel Zak 1395236acd kill: make man page more informative about --timeout
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-09 13:11:16 +01:00
Karel Zak 26c2ad6c38 kill: report features on -V, add lish_header initialization
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-09 12:40:53 +01:00
Karel Zak e601521259 Merge branch 'kill-pidfd' of https://github.com/kerolasa/util-linux
* 'kill-pidfd' of https://github.com/kerolasa/util-linux:
  kill: use pidfd system calls to implement --timeout option
  build-sys: add missing NR underscore to UL_CHECK_SYSCALL()
2019-12-09 12:20:22 +01:00
Karel Zak 107e955946 lsblk: add PARTTYPENAME column
Print also partition type in human-readable way.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1777261
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-12-04 12:38:57 +01:00
Sami Kerola 6e6b9a1d24
kill: use pidfd system calls to implement --timeout option
At times there is need in scripts to send multiple signals to a process.
Often these cases require some amount of waiting before follow-up signal
should be sent.

One common case is process termination, where first script tries to kill
process gracefully but if that does not work SIGKILL is sent.  Functionality
like that is commonly done by periodically checking if signalled pid exist
or not, and if it does another signal is sent possibly to an unrelated
process that reused pid number.  That means polling a pid is prone to a data
race.  Also if the first signal immediately kills the process one polling
interval is lost in sleep.

Another example when multiple signal need to be sent is various daemon
process control situations, such as Upgrading Executable on the Fly (see
reference).  This happens to be the case that inspired change author to make
sequential signaling a little bit easier.

Reference: http://nginx.org/en/docs/control.html#upgrade
Pull-request: https://github.com/karelzak/util-linux/pull/902
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-11-25 21:25:50 +00:00
Karel Zak 4631edaee2 lsblk: add FSVER to --fs
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-15 11:23:44 +01:00
Karel Zak 9cca1ef2d5 lsblk: add FSVER (filesystem version) column
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1764523
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-12 13:55:55 +01:00
Michal Suchanek 39f5af2598 libblkid: open device in nonblock mode.
When autoclose is set (kernel default but many distributions reverse the
setting) opening a CD-rom device causes the tray to close.

The function of blkid is to report the current state of the device and
not to change it. Hence it should use O_NONBLOCK when opening the
device to avoid closing a CD-rom tray.

blkid is used liberally in scripts so it can potentially interfere with
the user operating the CD-rom hardware.

[kzak@redhat.com: add O_NONBLOCK also to:
                  - wipefs
                  - blkid_new_probe_from_filename()
                  - blkid_evaluate_tag()]

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-06 09:55:49 +01:00
Karel Zak eea06b92dc lsblk: never fallback to udev/blkid on --sysroot
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-29 13:12:18 +01:00
Vladimir Slavik 2bbc962288 lsblk: update man description of -f / --fs for current columns
see lsblk.c line 1930
2019-10-17 13:51:02 +02:00
Karel Zak 6f74ede50a lsblk: read also GROUP,OWNER and MODE from dumps
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-15 13:08:09 +02:00
Karel Zak 7408a5d9c2 lsblk: on --sysroot read attributes from /dev/<devname> text file
The option --sysroot is used to read information from dumps rather
than from the current system. This patch allows to read also udev
attributes from text file in location /sysroot/dev/<devname>. The file
is text file in format NAME=value\n.

Suggested-by: Alasdair G Kergon <agk@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-15 12:36:16 +02:00
Elliott Mitchell 2bb3aa36b2 cleanup: Remove some spurious spaces
Sorry detail-oriented people tend to wipe these out if they notice them.
Add in automated tools and lots of excess end-of-line spaces get wiped
out.

Addresses: https://github.com/karelzak/util-linux/pull/849
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-01 13:01:43 +02:00
Karel Zak bce4a17b01 blkid: (man) add note about udev to --list-one
Addresses: https://github.com/karelzak/util-linux/issues/866
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-12 13:24:42 +02:00
Sami Kerola dbeb1d733e
docs: try to find broken man references and fix them
Unfortunately methods I used to find and fix were based on quite manual
process that cannot be easily repeated so I do not see how this fix could be
turned into a tools/checkmans.sh addition.  Well, lets hope doing this
manually twice every decade is good enough.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-08-26 19:43:40 +01:00
Sami Kerola a7466bdcbe
po: remove possibility to translate static option arguments
These strings are expected to be wrote exactly as they are parsed, so make
translating them impossible.  Since mkfs.cramfs -N option arguments need
this treatment use opportunity to slice usage() output to multiple lines.

Addresses: https://bugs.debian.org/907568
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-08-24 09:29:52 +01:00
Karel Zak 9e677de1ec lsblk: fix -E segfault
We need to check if referenced wholedisk defines the de-duplication
key...

Addresses: https://github.com/karelzak/util-linux/issues/819
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-07-15 12:28:26 +02:00
Sami Kerola f3aded3fdb
include/xalloc: ensure xstrdup() and xstrndup() returns nonnull attribute
Turned out lsblk is passing null as argument to xstrdup(), so fix that and
add assert() to make sure promise of not returning null is kept in future.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-07-14 11:52:13 +01:00
Karel Zak e3bb9bfb76 lsblk: force to print PKNAME for partition
PKNAME (parent kernel device name) is based on printed tree according
to parent -> child relationship. The tree is optional and not printed
if partition specified (.e.g "lsblk -o+PKNAME /dev/sda1"), but old
versions print the PKNAME also in this case.

Addresses: https://github.com/karelzak/util-linux/issues/813
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-06-27 09:22:18 +02:00
Karel Zak f5b7bf155b findmnt: (verify) ignore passno for XFS
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1719069
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-06-12 11:03:23 +02:00
Karel Zak f7c5507db6 hardlink: fix bad formatting in hardlink.1
* fix regex\f to regex\fR (issue #805)
* replace \fP with \fR to be consistent with our another man pages

Addresses: https://github.com/karelzak/util-linux/issues/805
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-31 11:57:29 +02:00
Karel Zak 21d93094d4 findmnt: fix filters use on --list
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1714826
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-29 17:59:33 +02:00
Karel Zak a2761af42b whereis: make subdirs scan more robust
* call strchr() only once
* avoid things like strcat(buf, strchr(dir, '*') + 1)
* make it more readable
* improve debug messages

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-23 13:53:00 +02:00
Karel Zak 106e696064 lsblk: make sure __process_one_device() has proper arguments [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-23 12:36:53 +02:00
Karel Zak 74152bf944 lsblk: check ul_path_scanf() return value [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-23 12:31:49 +02:00
Karel Zak 404eef654a lsblk: check stat() return code [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-23 12:28:13 +02:00
Karel Zak 7241dda191 logger: make code more robust for static analyzer [clang scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-23 12:14:10 +02:00
Karel Zak ac255c2b14 hardlink: avoid uninitialized variables [clang scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-23 12:12:07 +02:00
Karel Zak aa75c5eb74 whereis: use xstrncpy()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-20 12:59:02 +02:00
Karel Zak 002931c485 Merge branch '2019wk19' of https://github.com/kerolasa/util-linux
* '2019wk19' of https://github.com/kerolasa/util-linux:
  lib/colors: remove redundant if statement
  wipefs: fix variable / function shadowing [cppcheck]
  sulogin: fix variable / function shadowing [cppcheck]
  lscpu: remove redundant condition check [cppcheck]
  libmount: avoid possible null pointer dereference [cppcheck]
  lib/mangle: fix possible null pointer dereference [cppcheck]
  sfdisk: remove unnecessary size check [cppcheck]
2019-05-20 12:35:38 +02:00
Sami Kerola 9abc8a42aa
wipefs: fix variable / function shadowing [cppcheck]
[misc-utils/wipefs.c:636] -> [misc-utils/wipefs.c:310]: (style) Local
variable usage shadows outer function

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-05-18 22:42:13 +01:00
Karel Zak 778e2b2b7f findmnt: keep it easy for static analyzers 2019-05-16 14:38:12 +02:00
Karel Zak 097c067f5c findmnt: (verify) check mnt_table_next_fs() return code [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-16 14:33:47 +02:00
Karel Zak 374cb54381 fincore: remove unused variable [clang scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-16 14:27:15 +02:00
Karel Zak f06d8b69a9 cal: make sure months_in_row makes sense [coverity scan]
* avoid divide by zero in mountly() dues to wrong months_in_row
* make sure months_in_row is at least 1

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-16 14:22:43 +02:00
Karel Zak fa1b64da96 blkid: improve strcpy() usage [coverity scan]
The old deprecated list output format ("-o list") copies gettex string
into fixed buffer, that's really bad idea.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-16 13:56:34 +02:00
Austin English fd5f21ca45 lsblk: fix "maybe be" duplication
Signed-off-by: Austin English <austinenglish@gmail.com>
2019-05-15 13:48:54 +02:00
Karel Zak f6f8a671a9 lsblk: fix heap-use-after-free
Addresses: https://github.com/karelzak/util-linux/issues/787
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-06 12:39:07 +02:00
Karel Zak fe22543d6b lsblk: add more debug messages
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-02 15:51:48 +02:00
Karel Zak 74a4d22078 hardlink: fix compiler warnings [-Wsign-compare -Wmaybe-uninitialized]]
misc-utils/hardlink.c: In function ‘process_path’:
misc-utils/hardlink.c:287:30: warning: operand of ?: changes signedness from ‘off_t’ {aka ‘long int’} to ‘long unsigned int’ due to unsignedness of other operand [-Wsign-compare]

misc-utils/hardlink.c: In function ‘main’:
misc-utils/hardlink.c:455:5: warning: ‘exclude_pattern’ may be used uninitialized in this function [-Wmaybe-uninitialized]

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-02 12:48:05 +02:00
Sami Kerola e2aa5d82b9
hardlink: retire NIOBUF in favour of more common BUFSIZ
Reason to retire NIOBUF is that it is obscure local definition, while BUFSIZ
is well understood and commonly used constant.  Besized sizes of these are
not far off, the NIOBUF was 4096 bytes and BUFSIZ tends to be 8192 bytes.

Proposed-by: Karel Zak <kzak@redhat.com>
Reference: https://github.com/karelzak/util-linux/pull/783
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-05-01 20:19:19 +01:00
Sami Kerola 007b9874d8
hardlink: move global variables to a control structure
Well, sort of.  Due to use of ctl values in atexit() print_summary() there
is need for global control structure.

Secondly couple variables can be moved to more restricted scope, namely the
PCRE variables are now in main().

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-05-01 19:49:07 +01:00
Sami Kerola e87263aa13
hardlink: use flexible array member rather than zero-size array
This fixes two standards compliancy warnings.

hardlink.c:65:7: warning: ISO C forbids zero-size array ‘name’ [-Wpedantic]

Reference: https://en.wikipedia.org/wiki/Flexible_array_member
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-05-01 19:37:54 +01:00
Karel Zak 08a2cf7292 hardlink: remove \r from output
* remove \r from internationalized messages
* remove \r from all output to make it easy to use (see for example
  output file from "hardlink -vv --dry-run . &> log")

* remove unnecessary formatting stuff from output, just keep is simple
  and stupid...

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-24 18:31:08 +02:00
Karel Zak 2c308875a7 misc: consolidate version printing and close_stdout()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-16 15:14:13 +02:00
Karel Zak 68224d108d include/c: add print_version() macro
Let's consolidate the version printing code. It also seems better to
use exit() after --version, because it's handled in different way by
ASAN.

It's strange, but ASAN reports leaks after return in main(). Note that
we do not use free-before-exit.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-16 13:47:17 +02:00
Karel Zak 7761bd3bb6 lib/fileutils: add xreaddir()
Remove duplicate code and keep only one implementation in
include/fileutils.h.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-11 13:11:53 +02:00
Karel Zak a44cd89128 lscpu: fix excl[] array order
It (rows and columns) must be in ASCII order.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-03-19 16:56:28 +01:00
Karel Zak fb3761809f lsblk: force tree on --json --tree independently on used columns
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-03-18 16:58:41 +01:00
Karel Zak 5bf5752e28 blkid: (man) cleanup return code section
Addresses: https://github.com/karelzak/util-linux/issues/764
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-03-11 12:02:31 +01:00
Karel Zak b9c088f2f3 lsblk: allow to specify tree column
* document --tree (was missing in the man page)
* add optional argument to --tree to specify tree

For example:

$ lsblk -o KNAME,SIZE,MOUNTPOINT --tree=KNAME /dev/dm-0
KNAME      SIZE MOUNTPOINT
dm-0     232.9G
└─dm-1   232.9G
  └─dm-2 232.9G

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-20 12:49:24 +01:00
Sami Kerola 110260830d docs: fix typos [codespell]
Reference: https://github.com/codespell-project/codespell
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-02-18 13:22:43 +01:00
Sami Kerola 123eb9ef8c hardlink, wall: fix variable shadowing
misc-utils/hardlink.c:91:65: warning: declaration shadows a variable in the global scope [-Wshadow]
misc-utils/hardlink.c:73:5: note: previous declaration is here
int content_only = 0;

term-utils/wall.c:114:40: warning: declaration shadows a variable in the global scope [-Wshadow]
term-utils/wall.c:129:65: warning: declaration shadows a variable in the global scope [-Wshadow]
/usr/include/bits/getopt_core.h:36:14: note: previous declaration is here
extern char *optarg;

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-02-18 13:20:34 +01:00
Sami Kerola 4813a5210f various: fix 'uninitialized when used' warnings [clang]
This change fixes "warning: variable 'var' may be uninitialized when used
here [-Wconditional-uninitialized]" warnings reported in various files.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-02-18 13:19:24 +01:00
Karel Zak d135e1a1e3 cal: fix Sexit and Senter
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-18 13:10:58 +01:00
Karel Zak 985421192d hardlink: add long options
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-11 14:01:55 +01:00
Karel Zak c8ca29beb2 hardlink: rename function
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-11 13:30:46 +01:00
Karel Zak bd7722af02 hardlink: make code more readable
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-11 13:25:04 +01:00
Karel Zak 0b05aab402 hardlink: cleanup global variables
* remove NAMELEN, use PATH_MAX
* mark global variables as static
* move all global variables to the begin of the code

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-11 13:18:35 +01:00
Karel Zak 3807e71af4 hardlink: remove typedefs
- remove typedefs
- use long names for structs

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-11 13:00:18 +01:00
Sven Wiltink c2f6513c10 lsblk: use ID_SCSI_SERIAL when available
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-11 10:37:27 +01:00
Karel Zak d55db6724c hardlink: cleanup error messages, use xalloc.h
- do not use magical doexit(), just use err()
- print summary on exit

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-06 17:23:54 +01:00
Karel Zak c545e62c68 hardlink: cleanup verbose and warning messages
- use warn()
- use stdout rather than stderr

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-06 17:14:01 +01:00
Karel Zak bd9a35c6ce hardlink: (man) add AVAILABILITY
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-06 14:37:34 +01:00
Karel Zak 117f4d8bf4 Merge branch 'hardlink' of https://github.com/rudimeier/util-linux into hardlink
* 'hardlink' of https://github.com/rudimeier/util-linux: (25 commits)
  hardlink: add first simple tests
  hardlink: util-linux usage
  hardlink: fix compiler warnings
  hardlink: style indentations and license header
  hardlink: enable build with and without pcre2
  fixes for the fixes
  temporal fix before re-patch (updates from Fedora repo)
  Update hardlink.1
  Fixed version number, added changelog about Todd Lewis' patch
  exclude files via pcre
  Fixed 32 bit build with gcc7 (RH Bugzilla ID 1422989)
  spec file reflects the atomic hardlinking patch; removed cleaning buildroot (redundant); update FSF address at .c source file
  Revert "spec file reflects the atomic hardlinking patch; removed cleaning buildroot (redundant); current FSF address at .c source file"
  spec file reflects the atomic hardlinking patch; removed cleaning buildroot (redundant); current FSF address at .c source file
  Mention -f option in the man page
  do not allow to hardlink files across filesystems by default (#786719) (use -f option to override)
  fix possible buffer overflows, integer overflows, update man page
  fix URL and remove mmap() (#676962, #672917)
  - update docs to describe highest verbosity -vv option (#210816) - use dist Resolves: 210816
  mostly spec cleanup
  ...
2019-02-06 13:55:20 +01:00
Karel Zak f90d8b8bcc cal: use standout mode on monochrome terminals
The function colors_init() checks for colors, it means it fails
on monochrome terminals, but cal(1) in this case still need to
highlight the current day.

Reported-by: Nuno Silva <nunojsilva@ist.utl.pt>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-04 14:20:03 +01:00
Karel Zak 8fd512e932 logger: (man) add info about rewrite and authors
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-01-29 15:59:41 +01:00
Karel Zak bd0029f6be logger: (man) make more obvious that --server/socket is required
The options --tcp/udp specify only how, but no where.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-01-29 15:44:13 +01:00
Karel Zak 1c4a2600cc logger: concatenate multiple lines of MESSAGE into a single field.
this is deemed a useful special case since journalctl will only show
either the first or last element of the message array if the field
appears multiple times.

Based on patch from: Kjetil Torgrim Homme <kjetil.homme@redpill-linpro.com>
https://github.com/karelzak/util-linux/pull/743

Addresses: https://github.com/karelzak/util-linux/issues/742
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-01-23 11:41:43 +01:00
Karel Zak 9ed2117897 whereis: search in /(s)bin before /usr/lib
Addresses: https://github.com/karelzak/util-linux/issues/741
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-01-17 11:19:27 +01:00
Karel Zak 969e8cbeb1 libblkid: improve whole-disk detection when read /proc/partitions
blkid(8) in high-level mode checks partitions and unpartitioned
whole-disk devices from the file /proc/partitions.

The current heuristic assumes that partition name ends with a digit.
Unfortunately, this is not correct -- for example md0 or nvme0n1 are
whole-disk devices.

This commit uses sysfs_devno_is_wholedisk() to make sure the device is
a partition (according to kernel or DM). It's probably more expensive,
because this way requires more syscalls (to read stuff from /sys etc.).

The patch also adds more information to the blkid(8) man page.

Addresses: https://github.com/karelzak/util-linux/issues/728
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-01-08 12:07:18 +01:00
Sami Kerola e361253e88
lsblk: fix null pointer dereferences
Both catched with -Wnull-dereference compiler option:

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-12-10 20:25:58 +00:00
Karel Zak 0bd05f5ee4 lsblk: add --merge
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:57:49 +01:00
Karel Zak 0986f29a3f lsblk: make devtree dependences more generic
We also need reference from child to parent to implement multi-parent
view. This change allows to walk on tree in both directions.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:33:34 +01:00
Karel Zak dc4662f0e7 lsblk: add --dedup <column>
The target use-case are systems with large number of multi-path
devices or systems with duplicate (copied) filesystems.

The feature is flexible enough to use arbitrary column (for example
WWM or UUID, ...) as de-duplication key.

For example tree with multi-path devices sd{c,d,e,f}

./lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda           8:0    0 223.6G  0 disk
├─sda1        8:1    0   200M  0 part  /boot/efi
├─sda2        8:2    0   200M  0 part  /boot
├─sda3        8:3    0 130.3G  0 part
├─sda4        8:4    0    50G  0 part  /
└─sda5        8:5    0  42.9G  0 part
sdb           8:16   0  74.5G  0 disk
└─sdb1        8:17   0  74.5G  0 part  /home/archive
sdc           8:32   0   100M  0 disk
└─mpatha    253:0    0   100M  0 mpath
  ├─mpatha1 253:1    0    50M  0 part
  └─mpatha2 253:2    0    49M  0 part
sdd           8:48   0   100M  0 disk
└─mpatha    253:0    0   100M  0 mpath
  ├─mpatha1 253:1    0    50M  0 part
  └─mpatha2 253:2    0    49M  0 part
sde           8:64   0   100M  0 disk
└─mpatha    253:0    0   100M  0 mpath
  ├─mpatha1 253:1    0    50M  0 part
  └─mpatha2 253:2    0    49M  0 part
sdf           8:80   0   100M  0 disk
└─mpatha    253:0    0   100M  0 mpath
  ├─mpatha1 253:1    0    50M  0 part
  └─mpatha2 253:2    0    49M  0 part

De-duplicate by WWN:

./lsblk -M WWN
NAME        MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda           8:0    0 223.6G  0 disk
├─sda1        8:1    0   200M  0 part  /boot/efi
├─sda2        8:2    0   200M  0 part  /boot
├─sda3        8:3    0 130.3G  0 part
├─sda4        8:4    0    50G  0 part  /
└─sda5        8:5    0  42.9G  0 part
sdb           8:16   0  74.5G  0 disk
└─sdb1        8:17   0  74.5G  0 part  /home/archive
sdc           8:32   0   100M  0 disk
└─mpatha    253:0    0   100M  0 mpath
  ├─mpatha1 253:1    0    50M  0 part
  └─mpatha2 253:2    0    49M  0 part

Addresses: https://github.com/karelzak/util-linux/issues/616
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:33:34 +01:00
Karel Zak 10501add02 lsblk: remember whole-disk, remove unused struct member
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:33:34 +01:00
Karel Zak d81e32bde9 lsblk: make device_get_data() more generic
* independent on smartcols line
* keep sort data optional

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:58 +01:00
Karel Zak 57a061339b lsblk: apply --nodeps to partitions too
The new implementation differentiates between partitions and another
dependences -- this is regression, we need root devices only.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:58 +01:00
Karel Zak 8a2f175cbb lsblk: read queue/discard_granularity only when necessary
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:58 +01:00
Karel Zak 81a8936c56 lsblk: reuse 'removable' flag from parent
It's used in the default output, let's make it a little bit more
effective.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:58 +01:00
Karel Zak ff7992d631 lsblk: don't keep sysfs dirs open
Don't keep open sysfs file descriptors for all time to avoid problems
on systems with huge number of block devices.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:58 +01:00
Karel Zak b158bd29de lsblk: rename set_device()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:58 +01:00
Karel Zak b93585e8fc lsblk: add comments
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:58 +01:00
Karel Zak e7b5353e8b lsblk: add process_all_devices_inverse()
This is necessary to implement --inverse. Note that this new
implementation scans /sys/dev/block/ to get top-level devices
and than it calls process_one_device().

Note that standard non-inverse tree does not use process_one_device()
as it's more effective to scan /sys/block where are no partitions.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:58 +01:00
Karel Zak e15c9e3dc5 lsblk: reorder functions
The goal is to call process_one_device() from process_all_devices(),
so let's it keep in code in the right order.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak cf3c1bc77a lsblk: make process_partitions() more readable
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 0e086f8230 lsblk: remove unncessary parent pointer
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak ae4c2c375b lsblk: use real rather than hardcoded parent
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 4ca3c472f3 lsblk: use devtree functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak e2d7870b00 lsblk: add lsblk_device_has_dependence()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 291606faf9 lsblk: process_one_device() refactoring
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 583b6489f6 lsblk: add devtree_get_device_or_new()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 97c89dff13 lsblk: keep functions names consistent
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 9b4c648612 lsblk: remove unused reset_device()
Now all is maintained by reference counting ion the devtree.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 57502dd34c lsblk: fix devtree deallocation
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak f43b829759 lsblk: split sysfs reading and scols table filling
This change allows read devices from sysfs only once and reuse device
properties if the device is references more than once in the tree
(RAIDs, etc.).

* every device is in the tree only once (tree->devices list)

* iterate_block_devices() reuse already read devices (for example if
  already read for any dependence)

* the smartscols table is build from the final tree

The patch temporary disables dependencies evaluation (in
process_blkdev() to keep the patch small and simple.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 21d4a48c9c lsblk: cleanup device reference in the tree
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 3bf2a36cc5 lsblk: remove badly named debug interface name
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 5bb395f4f6 lsblk: add basic function to build devices tree
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak a0a76f4265 lsblk: properly initialize structs
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 7cd9de40fa lsblk: rename reset_lsblk_device() to reset_device()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak fed34a1e63 lsblk: rename blkdev_cxt to lsblk_device
The patch does not change code logic and semantic -- just rename.

* set_cxt() to set_device()
* struct blkdev_cxt to lsblk_device

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 6df5acf970 lib/timer: add fallback if timer_create() not available
* add struct ul_timer as API abstraction to hide differences between
timer_create() and setitimer()

* add setitimer() detection to ./configure.ac

* add fallback code to use setitimer() if timer_create() not available
  (for example on OSX)

Addresses: https://github.com/karelzak/util-linux/issues/584
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-03 11:23:33 +01:00
Karel Zak 0ab0817917 blkid: fix usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-11-29 13:30:11 +01:00
Karel Zak 5e91d5dd71 blkid: make PART_ENTRY_* tags optional (add --no-part-details)
blkid(8) returns information from partition table also for empty
partitions. This is necessary for example for udev, but it could be
confusing if you care about on-device content only.

Default:
 # blkid -p /dev/md0p1; echo $?
 /dev/md0p1: PART_ENTRY_SCHEME="dos" PART_ENTRY_UUID="6d8796b1-01" PART_ENTRY_TYPE="0x83" PART_ENTRY_NUMBER="1" PART_ENTRY_OFFSET="2048" PART_ENTRY_SIZE="204800" PART_ENTRY_DISK="9:0"
 0

With --no-part-details:
 # blkid -p /dev/md0p1 --no-part-details; echo $?
 2

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1653413
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-11-29 13:21:36 +01:00
Andreas Henriksson df8d991b24 uuidd: Add hardening settings to uuidd.service
This limits what the uuid daemon has access to when it runs.

Further improving this with additional option or making
things even tighter is most likely possible.

Signed-off-by: Andreas Henriksson <andreas@fatal.se>
2018-11-29 10:37:08 +01:00
Andreas Henriksson c8d61f361c uuidd: Add Documentation key to uuidd.service 2018-11-21 10:47:31 +01:00
Ruediger Meier 7d50d36121 hardlink: util-linux usage
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-11-14 00:37:14 +01:00
Ruediger Meier 53071734aa hardlink: fix compiler warnings
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-11-14 00:37:04 +01:00
Ruediger Meier 55c000e1eb hardlink: style indentations and license header
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-11-12 19:44:39 +01:00
Ruediger Meier 04ae85a7e5 hardlink: enable build with and without pcre2
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-11-12 19:40:33 +01:00
Patrick Steinhardt d2523d3dd2 rename: avoid undefined function prototype for `fpurge`
In case where the non-standard `fpurge` function is available, we
redefine `__fpurge` to `fpurge`. We can do so because the only
difference between both functions is that one returns an error code
while the other does not. But as we do not check the error code either
way, we do not care about which one of them we use.

The above redefinition happens unconditionally if we know that `fpurge`
exists. Most notably, we also redefine it if we already do have an
`__fpurge` function available that could be used. This causes problems
on musl-based platforms, where we detect availability of `fpurge` in
libc, but where no function declaration for it exists in "stdio_ext.h".
The compiler thus prints a warning due to an unknown function, even
though it will link just fine.

Avoid this warning by only redefining `__fpurge` to `fpurge` when
HAVE___FPURGE is not defined.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
2018-10-04 11:56:37 +02:00
Patrick Steinhardt 6529212d5b lsblk: fix unknown type `stat` caused by missing header
The structure `blkdev_cxt` has a `struct stat` member embedded, whose
size may not be known on some systems because of a missing include for
"sys/stat.h". On glibc-based systems, this header is included
transitively via "sys/statvfs.h", but on musl-based systems it is not.

Fix the resulting compile error due to unknown size of the struct by
including "sys/stat.h".

Signed-off-by: Patrick Steinhardt <ps@pks.im>
2018-10-04 11:56:35 +02:00