Commit Graph

51 Commits

Author SHA1 Message Date
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 25d3c40534
lslocks: add --output-all option
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-05-03 19:56:20 +01:00
Karel Zak fffdff1e61 lslocks: use scols_column_set_json_type()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-04-18 15:07:31 +02:00
Karel Zak 51b0bcf01d lslocks: add --bytes cleanup SIZE usage
The new command line option --bytes disables human readable output for
the SIZE and keep size in bytes. We use the same concept for all our
utils.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-04-18 15:01:31 +02:00
Karel Zak 6ceb17c8a7 lslocks: fix memory leak
Addresses: https://github.com/karelzak/util-linux/pull/618
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-04-16 10:27:29 +02:00
Karel Zak 2aaf56c45f lslocks: add info about OFD
It seems users are confused by PID -1 and missing path. This patch add
more information about OFD locks to the man page and "undefined" to
the COMMAND column.

References: http://austingroupbugs.net/view.php?id=768
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1527102
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-04-13 11:22:21 +02:00
Karel Zak 4707bc83e1 lslocks: add note about OFDLCK
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-03 11:20:41 +01: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 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
Karel Zak c3a4cfc579 misc: consolidate usage() "Available columns"
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-26 14:09:53 +02:00
Karel Zak 55548b14c1 lslocks: remove dead code
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-18 15:10:51 +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
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 f29bc6e1cc lslocks: add --noinaccessible
* add --noinaccessible to not print incomplete information

* make incomplete paths more visible (append "...")

* don't print 0B size if lock file inaccessible

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-07-01 14:45:04 +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
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
Ruediger Meier 2208b3ccb2 lib: remove openat fallback functions (include/at.h)
I have validated that we are still compatible at least back to
  - openSUSE 11.4
  - SLE 11
  - RHEL/CentOS 6
  - OSX 10.10.x, (Xcode 6.3)
  - FreeBSD 10.2

Confirmed incompatibility:
  - OSX 10.9.x, (Xcode 6.2)

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-07 15:33:56 +01:00
Karel Zak 0e756daeb6 lslocks: use stuff from lib/procutils
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-11-25 14:17:22 +01: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
Karel Zak b3a2e889df lslocks: add --json
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-05 10:45:15 +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
Sami Kerola 64a265bf8a lslocks: fix type warning
misc-utils/lslocks.c:229:2: warning: format '%x' expects argument of type
'unsigned int *', but argument 3 has type 'int *' [-Wformat=]

Reference: http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/fs/locks.c?id=5e0f872c7d7e371fbdf09e864eddd24bddfda8fe#n2533
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-01-07 10:14:11 +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
Karel Zak 21abf83d6d lslocks: clean up columns[] usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-18 13:48:31 +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
Ondrej Oprala ba1bf7164f lslocks: use libsmartcols
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-04-03 12:29:19 +02:00
Karel Zak 4bab4729e2 lslocks: use TT_FL_FREEDATA for tt table
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:46:59 +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 e68948e146 lslocks: support -o +<list> convention
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-18 13:21:42 +01:00
Karel Zak 7badb909e2 lslocks: add BLOCKER column
BLOCKER -  PID of the process blocking the lock

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-18 13:12:01 +01:00
Karel Zak 55c0d16bab lslocks: detect blocked locks, fix /proc/locks parser
$ flock foo -c "sleep 100" & flock foo -c "sleep 100"

old version:
  $ lslocks
  lslocks: failed to parse pid: 'WRITE'

new version:

COMMAND           PID  TYPE  SIZE MODE   M      START        END PATH
[...]
flock            1318 FLOCK    0B WRITE* 0          0          0 /home/projects/
flock            1319 FLOCK    0B WRITE  0          0          0 /home/projects/

 The asterisk (e.g. WRITE*) is used for blocked processes.

Reported-by: Mantas Mikulenas <grawity@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-14 16:29:51 +01:00
Karel Zak 07c916cfdd lslocks: use libmount to parse mountinfo
old version:
	$ strace -e open lslocks 2>&1 | grep mountinfo | wc -l
	118

new version:
	strace -e open ./lslocks 2>&1 | grep mountinfo | wc -l
	1

Reported-by: Bernhard Voelker <mail@bernhard-voelker.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-14 15:59:28 +01:00
Karel Zak 46d4ce56a7 lslocks: fix compiler warnings
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-20 19:57:48 +01:00
Karel Zak 0d7ebfc4a7 lslocks: don't care about xasprintf() return code
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-12 12:11:17 +01:00
Karel Zak 9f51089e7f misc: make readlink() usage more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-23 12:40:39 +02:00
Benno Schulenberg e9e7698eb4 textual: add missing comma and colon in some help texts
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2012-09-04 17:27:50 +02:00
Sami Kerola e35c4a12e1 lslocks: fix shadow declaration
misc-utils/lslocks.c:157:49: warning: declaration of 'pid' shadows a global declaration [-Wshadow]
misc-utils/lslocks.c:80:14: warning: shadowed declaration is here [-Wshadow]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-26 13:18:35 +02:00
Karel Zak db41a4298f misc-utils: cleanup strtoxx_or_err()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-15 17:44:37 +02:00
Davidlohr Bueso fbf9034e48 lslocks: fix bracket indentation
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-05-10 11:41:15 +02:00
Karel Zak 0bda832322 lslock: remove duplicate variable
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-03 16:01:04 +02:00
Karel Zak 6259c257d8 Merge branch 'close_stream' of git://github.com/kerolasa/lelux-utiliteetit
* 'close_stream' of git://github.com/kerolasa/lelux-utiliteetit:
  disk-utils: verify writing to streams was successful
  fdisk: verify writing to streams was successful
  getopt: verify writing to streams was successful
  hwclock: verify writing to streams was successful
  login-utils: verify writing to streams was successful
  misc-utils: verify writing to streams was successful
  mount: verify writing to streams was successful
  partx: verify writing to streams was successful
  schedutils: verify writing to streams was successful
  sys-utils: verify writing to streams was successful
  term-utils: verify writing to streams was successful
  text-utils: verify writing to streams was successful
  include: add stream error checking facility

Conflicts:
	fdisk/fdisk.c
2012-04-11 12:37:59 +02:00
Sami Kerola c05a80ca63 misc-utils: verify writing to streams was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-04 19:56:48 +02:00
Karel Zak e9b4675924 lslocks: minor fix in usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-27 13:41:25 +02:00
Sami Kerola fd2e8c693e lslocks: use xasprintf for safe allocation
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-18 14:29:38 +01:00
Davidlohr Bueso 74fa8244de lslocks: add TYPE column
By knowing the lock's type (flock or posix), the user can have more
information about the lock and how it was created.

[kzak@redhat.com: - rename PERSONALITY to TYPE,
                  - rename ACCESS to MODE]

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-06 17:07:40 +01:00
Karel Zak c4137d397c lslocks: add --notruncate, minor fixes in man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-29 14:26:46 +01:00