Commit Graph

33 Commits

Author SHA1 Message Date
Karel Zak e0ecd19641 mountpoint: different exit status for errors and non-mountpoint situation
Fixes: https://github.com/karelzak/util-linux/issues/1260
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-03-11 10:48:36 +01:00
Sami Kerola 6d56251220
mountpoint: add --nofollow option
The no follow option will allow user to distinct mount points from symbolic
links pointing to them.  Arguably this is pretty pedantic option, mounting a
device or bind mount to a directory via symlink does not have or cause any
issues.

Addresses: https://github.com/karelzak/util-linux/issues/832
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-08-02 19:39:05 +01: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
Sami Kerola 8d69fd437a mountpoint: simplify test condition [cppcheck]
[sys-utils/mountpoint.c:79]: (style) Redundant condition:
ctl->st.st_dev==pst.st_dev. 'A || (!A && B)' is equivalent to 'A || B'

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-05-28 13:39:18 +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 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 6e1eda6f22 misc: never use usage(stderr)
Here we fix all cases where we have usage(FILE*)
functions.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-26 14:38:24 +02: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
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
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
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
Yuriy M. Kaminskiy 06fa581748 misc: safer (and uniform) handling of return value
When `rc` is `INT_MAX`, `rc + 1` result in signed integer overflow.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-03-07 15:11:06 +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
Sami Kerola ee5de88c51 mountpoint: simplify if statement
Returning straight after print_devno() makes the code to be more obvious
and removes need for long else statement.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-09-19 19:31:01 +01:00
Sami Kerola f112f41e05 mountpoint: add struct mountpoint_control
This unifies variable names in different functions, and removes redundant
stat() calls.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-09-19 19:31:01 +01:00
Dave Reisner fef4dfa174 mountpoint: drop S_ISDIR check
Files can be mountpoints, too.
2014-08-21 15:05:45 +02:00
Karel Zak 50fccba1ab misc: use libmnt_table reference counter
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-21 16:07:51 +02:00
Karel Zak 6195f9e6fa misc: use libmnt_cache reference counting
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-21 14:38:38 +02:00
Karel Zak 39edf68139 mountpoint: don't hardcode paths
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-14 15:46:06 +01:00
Sami Kerola efb8854f4c sys-utils: verify writing to streams was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-04 19:49:40 +02:00
Sami Kerola 30b61b7bd7 mountpoint: add --version & align with howto-usage-function.txt
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-30 16:48:11 +02:00
Dave Reisner eac83fbcf6 mountpoint: account for error from in mnt_fs_get_target
commit 04f087ec didn't take into consideration that mnt_fs_get_target()
could return an error, and would therefore show false positives, such
as:

$ mkdir foo; mountpoint foo
foo is a mountpoint

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-03-02 09:42:18 +01:00
Zhi Li 04f087eced mountpoint: fix a minor bug with 0:0 devno
zhi@debian-lizhi:~$ mountpoint /sys
/sys is not a mountpoint
zhi@debian-lizhi:~$

The problem is in mountpoint.c, function dir_to_device(), which uses 0 as an
error return value, but for sysfs 0 is its device number:

zhi@debian-lizhi:~$ cat /proc/self/mountinfo
14 19 0:0 / /sys rw,nosuid,nodev,noexec,relatime - sysfs none rw
15 19 0:3 / /proc rw,nosuid,nodev,noexec,relatime - proc none rw

My change is on dir_to_device, seperating device number from return value.

Signed-off-by: Zhi Li <lizhi1215@gmail.com>
2012-02-29 14:53:31 +01:00
Sami Kerola 7cebf0bb4f docs: corrections to FSF license files, and postal address
The COPYING and Documentation/licenses/COPYING* files are being
replaced by files from GNU web site.

http://www.gnu.org/licenses/gpl-2.0.txt
http://www.gnu.org/licenses/lgpl-2.1.txt

Postal addresses to FSF in other files are updated to match with the
address in license files.

Reference: http://lists.gnu.org/archive/html/freefont-announce/2005-04/msg00001.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-02-24 14:13:35 +01:00
Karel Zak eb9d3706aa mountpoint: support symbolic and relative paths
Reported-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-10-11 11:26:31 +02:00
Karel Zak b031befc25 Revert "mountpoint: refactor exit path"
This change is unnecessary, we can use libmount stuff for everything.

This reverts commit b16b56ec55.
2011-10-11 11:14:31 +02:00
Dave Reisner b16b56ec55 mountpoint: refactor exit path
There's only one condition for which we declare success, but many for
failure. Initialize rc as failure and set to success on this single
condition. In all cases, jump to a label to exit instead of exiting
immediately. This will be used later on to ease cleanup of any heap
allocations.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-10-11 11:03:45 +02:00
Karel Zak dfd2c71468 mountpoint: fallback on stat when /proc isn't mounted
Reported-by: <dreisner@archlinux.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-10-11 10:47:44 +02:00
Dave Reisner 7982e85a61 mountpoint: return dev_t from dir_to_device
The string returned from this function was never of much use other than
to stat the path when the user requested a major:minor pair beyond the
true/false exit. Save some processing and directly returning the dev_t
on success, and an impossible value on failure.

[kzak@redhat.com: - use 0 as dir_to_device() return value on failure]

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-10-11 09:56:07 +02:00
Karel Zak 4f92adb61a mountpoint: cleanup usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-16 13:25:28 +02:00
Karel Zak ce75b60528 build-sys: fix 'make checkincludes' warnings
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-07-28 13:21:00 +02:00
Karel Zak 0164c24595 mountpoint: add new command
This is libmount based re-implementation of the mountpoint(1) command.
The original implementation is maintained in sysvinit suite.

The mountpoint(1) in util-linux is not enabled by default (for now) --
use --enable-mountpoint to enable the util.

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-21 11:46:36 +02:00