Commit Graph

155 Commits

Author SHA1 Message Date
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
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 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 778e2b2b7f findmnt: keep it easy for static analyzers 2019-05-16 14:38:12 +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
sluidfoe f920bfd5a8 misc-tools/findmnt: a few whitespace fixes 2018-05-10 11:58:31 -05:00
sluidfoe 4c856a471e misc-tools/findmnt: add --pseudo, --real filters 2018-05-10 11:58:30 -05:00
Sami Kerola 00147883de
findmnt: add --output-all option
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-05-03 19:56:20 +01:00
Karel Zak 3a645e3658 findmnt: use scols_column_set_json_type()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-04-18 14:45:21 +02:00
Ruediger Meier f45f3ec34a misc: consolidate macro style USAGE_HELP_OPTIONS
changed in include/c.h and applied via sed:

  sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c")
  sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c")

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-29 16:54:33 +02:00
Ruediger Meier b305445495 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.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-27 12:28:36 +02:00
Ruediger Meier b1a294c448 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.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-27 12:26:19 +02:00
Ruediger Meier 86be6a32d3 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.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-26 14:38:24 +02:00
J William Piggott 6e2d5a4460 include/c.h: add USAGE_COMMANDS and USAGE_COLUMNS
* login-utils/lslogins.c: all uses changed
* misc-utils/findmnt.c: likewise
* sys-utils/blkzone.c: likewise
* disk-utils/sfdisk.c: likewise
* sys-utils/lscpu.c: likewise
* sys-utils/lsmem.c: likewise
* sys-utils/wdctl.c: likewise

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-06-24 13:57:12 -04:00
Sami Kerola 1b5042636f misc: fix reassigned values before old ones has been used [cppcheck]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-06-14 12:19:20 +02:00
Karel Zak 780ce22cda misc: consolidate smartcols error messages
... just to keep translators happy

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-18 11:39:34 +02:00
Sami Kerola 2ba641e5f3 misc: add static keyword to where needed [smatch scan]
text-utils/rev.c:68:9: warning: symbol 'buf' was not declared. Should it be
static?

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-20 12:58:49 +01:00
Sami Kerola 8791804065 misc: do not use plain 0 as NULL [smatch scan]
text-utils/tailf.c:69:21: warning: Using plain integer as NULL pointer

Since many 'struct option' has used zero as NULL make them more readable in
same go by reindenting, and using named argument requirements.

Reference: https://lwn.net/Articles/93577/
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-20 12:58:49 +01:00
Yuri Chornoivan a7349ee315 docs: Fix word repetitions 2017-02-13 14:10:12 +01:00
Karel Zak 7ccc1643ab findmnt: use line separator for --poll output
Addresses: https://github.com/karelzak/util-linux/issues/409
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-02-10 17:28:07 +01:00
Pedro Miguel Carvalho 18efba189e findmnt: flush stdout after each (un)(re)mount event, when polling.
Addresses: karelzak#407
2017-01-29 12:03:23 +00:00
Karel Zak 677ec86cef Use --help suggestion on invalid option
The current default is to print all usage() output. This is overkill
in many case.

Addresses: https://github.com/karelzak/util-linux/issues/338
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-12-19 13:13:34 +01:00
Karel Zak 3ebe5477db findmnt: add --tree to allow to enable tree output for --mtab
The --mtab output is merge from kernel and utab on all modern systems
(without classic /etc/mtab). It means we have all necessary information
to generate tree output.

For the backward compatibility --mtab is the list by default, the new
option --tree allows to override the default and enable tree always
when the table contains child-parent relations.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-12-08 14:24:41 +01:00
Karel Zak de22cb2b12 findmnt: add note about mount options
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-12-08 14:11:02 +01:00
Karel Zak c768892f4c findmnt: add --verify and --verbose
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-09-23 13:21:02 +02:00
Sebastian Rasmussen 9e93004171 misc: Fix various typos
Fix various typos in error messages, warnings, debug strings,
comments and names of static functions.

Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
2016-05-31 23:40:21 +02:00
Benno Schulenberg b779c1aecb mount, umount, swapon, fsck, lsblk, findmnt: harmonize six error messages
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-03-16 10:39:38 +01:00
Karel Zak 3fe3f560b7 Revert "include sysmacros.h where used"
This reverts commit 46a40c0184.
2016-03-08 14:26:33 +01:00
Mike Frysinger 46a40c0184 include sysmacros.h where used
BSD/Linux systems stick major/minor/makedev in sysmacros.h.  Newer Linux
libraries have been moving away from including sysmacros.h implicitly via
sys/types.h, so include it directly.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2016-03-08 14:21:55 +01:00
Karel Zak c1d185c77b findmnt: use scols_table_print_range() for --poll
This change fixes problem with duplicate header line.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-24 12:04:24 +01:00
Karel Zak 1cd9d0d746 mount, umount, swapon, fsck, lsblk, findmnt: ignore malformed lines
The libmount provides way how to deal with parsing errors in fstab --
on error callback function is executed and according to the return
libmount manipulate with the malformed line, possible are three
states:

  1/ fatal error; all file ignored              (callback rc < 0)
  2/ recoverable error; malformed line ignored  (callback rc > 0)
  3/ ignore the error                           (callback rc == 0)

The 2/ is the default if no callback specified.

Unfortunately our utils uses 3/. The correct way is to use 2/.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-15 12:01:48 +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 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
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
Karel Zak cd41b385a0 findmnt: don't rely on st_dev for --target
The overlay filesystem does not provide usable st_dev (in traditional
UNIX way). It's necessary to search in /proc/self/mountinfo to detect
which path element is mountpoint.

$ findmnt --target /mnt/merged/dir-a/foo
TARGET      SOURCE  FSTYPE  OPTIONS
/mnt/merged overlay overlay rw,relatime,lowerdir=/mnt/low,upperdir=/mnt/high/data,workdir=/mnt/high/work

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-03-10 12:51:44 +01:00
Karel Zak 9c277ede65 findmnt: don't parse mountinfo twice
We parse /proc/self/mountinfo to initialize cache targets, this step
is unnecessary if --mtab reads all from kernel.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-12 12:57:03 +01:00
Karel Zak 4631e25427 findmnt: fix mem leaks [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-01-29 11:59:54 +01:00
Sami Kerola 7ee26cbf02 maint: fix shadow declaration
This change fixes all shadow declarations.  The worth while to mention
fix is with libfdisk sun geometry.  It comes from bitops.h cpu_to_be16
macro that further expands from include/bits/byteswap.h that has the
shadowing.

libfdisk/src/sun.c:961:173: warning: declaration of '__v' shadows a previous local [-Wshadow]
libfdisk/src/sun.c:961:69: warning: shadowed declaration is here [-Wshadow]
libfdisk/src/sun.c:961:178: warning: declaration of '__x' shadows a previous local [-Wshadow]
libfdisk/src/sun.c:961:74: warning: shadowed declaration is here [-Wshadow]

That could have caused earlier some unexpected results.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-07 10:08:21 +01:00
Benno Schulenberg 451dbcfae1 textual: add a docstring to most of the utilities
This adds a concise description of a tool to its usage text.

A first form of this patch was proposed by Steven Honeyman
(see http://www.spinics.net/lists/util-linux-ng/msg09994.html).

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-06 11:27:38 +01:00
Benno Schulenberg 1d23119072 textual: remove some inconsistent periods from error messages
While doing so, also improve translatability and some wordings.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-08-11 14:51:54 +02:00
Karel Zak edaf38cf8c findmnt: more robust usage of columns[]
For more details see commit dcc8dbdc8137cb3da5100158639b565565b89875.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-18 13:49:40 +02:00
Karel Zak aea3a3ba2c findmnt: fix memory leak [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-17 15:00:17 +02:00
Karel Zak 23deb5aca0 findmnt: simplify cache_set_targets()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-01 10:36:40 +02:00
Eric Rannaud fb329bbc04 findmnt: use mnt_cache_set_targets() for non-kernel table
findmnt compares the user-supplied path <target> with each entry in the
parsed table. To do this comparison, libmount attempts to canonicalize
the target path of each table entry, when the entry does not originate
from the kernel (kernel supplied target paths are already
canonicalized). However, if one of these entries is an active mount
point, stat(2) or readlink(2) on the mount target path can hang (e.g.
unreachable NFS server).

If the main table is not a kernel table, we parse /proc/self/mountinfo
into a secondary table and call mnt_cache_set_targets(). This allows
libmount to check that the target path of each entry in the main table
is not an active mount point, so it can avoid canonicalizing it.

Signed-off-by: Eric Rannaud <e@nanocritical.com>
2014-07-01 10:05:16 +02:00
Benno Schulenberg ab5b4f837d findmnt: minimally improve wording of usage text
Also sort the options better and tweak whitespace.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-06-30 10:22:26 +02:00
Karel Zak 097e7f2ff4 findmnt: add --nocanonicalize to avoid realpath()
* in some cases is realpath() overkill
 * sometimes you want to search for explicitly specified paths (e.g.
   "findmnt --fstab /mnt/symlink") rather than for real paths
 * you want to avoid readlink() and stat() on NFS

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-16 15:47:50 +02:00
Karel Zak 710ed55dcd libsmartcols: add debug messages
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-06 13:47:06 +02:00
Karel Zak 0925a9dd6c libsmartcols: clean up flags usage
* rename flags functions to scols_table_enable_*
 * rename *_no_foo() functions to _nofoo()
 * output formats are mutually exclusive, so don't use flags there
 * don't assume symbols in scols_new_table(), use scols_table_set_symbols()

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 16:09:57 +02:00
Karel Zak 85c9ca5adf findmnt: cleanup flags
Let's use one flags variable for everything.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 12:29:19 +02:00
Ondrej Oprala 218a3a9463 findmnt: use libsmartcols
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-04-03 12:29:18 +02:00