Commit Graph

44 Commits

Author SHA1 Message Date
Sami Kerola d0355b2e90
lsipc: make default output byte sizes to be in human units
Recent request to make ipcs(1) list sizes in human format caused the
observation lsipc(1) is not doing that either.  This commit changes sizes to
human format, assuming --bytes option is not used.

Reference: https://github.com/karelzak/util-linux/issues/1199
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-12-28 09:53:13 +00: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
Karel Zak 25b7045e5d misc: replaces atexit(close_stdout) with new close_stdout_atexit()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-06-17 15:46:10 +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 8941e5cbb8 lsipc: cleanup columns[] usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-04-18 15:51:17 +02:00
J William Piggott 4111bb3ab5 lib/timeutils: add common ISO timestamp masks
* Start the ISO format flags at bit 0 instead of bit 1.

* Remove unnecessary _8601 from ISO format flag names to
  avoid line wrapping and to ease readability.

* ISO timestamps have date-time-timzone in common, so move
  the TIMEZONE flag to bit 2 causing all timestamp masks
  to have the first three bits set and the last four bits
  as timestamp 'options'.

* Change the 'SPACE' flag to a 'T' flag, because it makes
  the code and comments more concise.

* Add common ISO timestamp masks.

* Implement the ISO timestamp masks in all applicable code
  using the strxxx_iso() functions.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-11-10 16:34:55 -05: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 9325dbfd20 misc: cleanup and fix --unknownopt issues
Fixed checkusage.sh warnings:

  rtcwake: --unknownopt, non-empty stdout

  rtcwake: --unknownopt, stderr too long: 21
  blockdev: --unknownopt, stderr too long: 28
  lsipc: --unknownopt, stderr too long: 77
  pg: --unknownopt, stderr too long: 23
  renice: --unknownopt, stderr too long: 18
  sulogin: --unknownopt, stderr too long: 17
  write: --unknownopt, stderr too long: 12

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-26 14:38:24 +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 1b71d08c63
lsipc: fix options parsing and sync with man page
Option --pid was never implemented so remove it from struct options and
manual page.  Interestingly this option was not in usage().  Short option
string had 'u' that has never appear anywhere else, so it is also removed.
Finally add options --bytes and --numeric-perms to manual page.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-05-02 23:22:04 +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
Sami Kerola eb2306e675
misc: fix declarations shadowing variables in the global scope [oclint]
Fixes multiple occurences of 'optarg' overwrites.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-21 21:14:33 +01:00
Karel Zak bcf720693d lsipc: use strtime_short()
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-05-24 13:22:40 +02:00
Karel Zak bbdfcbe9f0 lsipc: use strtm_iso()
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-05-24 11:10:57 +02:00
Romain Naour 90a9b9910c lsipc: don't free shm data if no shm id is found
There is a segfault in do_shm_global() when ipc_shm_get_info() return 0 and
ipc_shm_free_info() is called.

When no shm id is found, the memory allocated in shmds by ipc_shm_get_info() is
already free when ipc_shm_free_info() is called.

Move ipc_shm_free_info(shmds) inside the if statement where at least one shm id
is found.

Signed-off-by: Romain Naour <romain.naour@gmail.com>
2016-03-23 10:52:41 +01:00
Ruediger Meier eaac9f88f9 misc: fix some includes
features.h:  any glibc header includes this already
libgen.h:    was unused there
sys/uio.h:   for writev(3p)
sys/queue.h  seems like it was never used

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-29 13:04:56 +01:00
Ruediger Meier b0b24b11f8 lib: rename strmode() and setmode()
On BSD they are part of the standard C library.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-18 12:53:48 +01:00
Karel Zak a4839bc781 lsipc: add more resource to the limits list
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-08-12 10:21:48 +02:00
Karel Zak 71b63dc14f lsipc: cleanup usernames
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-08-04 14:22:31 +02:00
Karel Zak fadf556a70 lsipc: check scols_line_refer_data() return code
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-08-04 14:05:33 +02:00
Karel Zak cdb4a9464d lsipc: don't duplicate already allocated data
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-08-04 13:57:45 +02:00
Karel Zak 21ce5a5d70 lsipc: ifdef SHM_* macros
Reported-by: Andreas Henriksson <andreas@fatal.se>
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-08-03 13:20:56 +02:00
Benno Schulenberg 62eea9ce12 textual: adjust grammar and punctuation of some messages
Also equalize three messages to one other one,
and fix a typo in USE_COLORS_BY_DEFAULT.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-08-03 11:18:56 +02:00
Karel Zak d8461c4e4d lsipc: cleanup {user,group}name usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-30 09:18:33 +02:00
Karel Zak 9380fbefa6 lsipc: value is never read [clang analyze]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-29 13:54:54 +02:00
Karel Zak 2916afa3f5 lsipc: make --id usable with all output formats and with -o
This patch allows to use things like:

 # lsipc -m --id 47611910 -o COMMAND,SIZE,KEY --json

or

 # lsipc -m --id 47611910 -o SIZE --bytes --noheadings --raw

to get just one value for the resource.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-23 11:09:49 +02:00
Karel Zak 8f405a5bed lsipc: the default --global is mutually exclusive with -c --id and -t
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-23 10:36:02 +02:00
Karel Zak 2a7150ac2e lsipc: remove --print0 and -colon-separate
These options have been originally designed for lslogins for
compatibility another passwd-like tools. It does not make sense for
IPC.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-23 10:28:32 +02:00
Karel Zak cdedcbe603 lsipc: remove duplicate "Usage:"
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-23 10:20:06 +02:00
Karel Zak 25456d5da3 lsipc: default to --global
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-20 11:56:44 +02:00
Karel Zak 1a31107169 lsipc: add USE% to --global
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-20 11:48:09 +02:00
Karel Zak 624de257a6 lsipc: use sub-table for semphore elements
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-20 11:48:09 +02:00
Karel Zak 5de8fcfd36 lsipc: improve JSON output
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-20 11:48:09 +02:00
Karel Zak d7500c6a6b lsipc: move outmode to coltrol struct
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-20 11:48:09 +02:00
Karel Zak 91c92cb545 lsipc: fix coding style
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-20 11:48:09 +02:00
Karel Zak 7458c061db lsipc: differentiate between UID and USER names
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-20 11:48:09 +02:00
Karel Zak c8b47062ab lsipc: fix ID parsing, use full time for pretty print
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-20 11:48:09 +02:00
Karel Zak e015417306 lsipc: cleanup -o usage
* support -o+AAA,BBB,CCC
* keep default resource columns in getopt switch()

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-20 11:48:09 +02:00
Karel Zak 32cfe498b8 lsipc: improve --global
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-20 11:48:09 +02:00
Karel Zak 470a7332b3 lsipc: cleanup columns indexes
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-20 11:48:09 +02:00
Karel Zak be47528713 lsipc: add COMMAND for shmem
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-20 11:48:09 +02:00
Karel Zak be333373b5 lsipc: add CTIME to shmem default
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-20 11:48:09 +02:00
Karel Zak 9d20ffda79 lsipc: new command to list IPC facilities
Co-Author: Karel Zak <kzak@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2015-07-20 11:48:09 +02:00