Commit Graph

40 Commits

Author SHA1 Message Date
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 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 380fe6ac46 zramctl: use xstrncpy()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-20 12:59:40 +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 a6f0da166e zramctl: use new ul_path_* API
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:07:46 +02:00
Karel Zak c9fdebcf54 Merge branch 'output-all' of https://github.com/kerolasa/lelux-utiliteetit
* 'output-all' of https://github.com/kerolasa/lelux-utiliteetit:
  zramctl: add --output-all option
  swapon: add --output-all option
  rfkill: add --output-all option
  partx: add --output-all option
  lsns: add --output-all option
  lsmem: add --output-all option
  lslogins: add --output-all option
  lslocks: add --output-all option
  lscpu: add --output-all option
  losetup: add --output-all option
  findmnt: add --output-all option
2018-05-10 12:15:32 +02:00
Sami Kerola 8fd27bec0c zramctl: fix truncation warning
sys-utils/zramctl.c: In function ‘zram_get_sysfs’:
sys-utils/zramctl.c:220:52: warning: ‘%s’ directive output may be truncated
writing up to 4095 bytes into a region of size 27 [-Wformat-truncation=]
     snprintf(z->devname, sizeof(z->devname), "/dev/%s", name);

As an additional good thing zramctl will no longer allocate 4096 bytes from
stack when just 23 bytes is enough.

[kzak@redhat.com: - use macro rather than hardcoded string for the path]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-05-10 11:25:05 +02:00
Sami Kerola 2e7ccec7bb
zramctl: add --output-all option
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-05-03 19:56:21 +01:00
Karel Zak 63bf2439eb zramctl: use xstrdup()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-30 12:21:03 +01:00
Libor Bukata a3612b81fe Added the support for lz4hc, deflate, and 842
compression algorithms in zramctl utility.

Signed-off-by: Libor Bukata <lbukata@gmail.com>
2018-01-24 17:10:09 +01:00
James Sanford e1b1c7b082 zramctl: fix show all non-zero zram devices
Addresses: https://github.com/karelzak/util-linux/issues/521
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-16 11:04:03 +02:00
James Sanford 4847bb5ee9 zramctl: remove unused ZRAM_EMPTY and blank line 2017-10-14 00:57:05 -07: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 699ad3a1de zramctl: add mising line terminator
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-18 15:10:04 +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 2546d54bd8 zramctl: make mm_stat parser more robust
Let's fallback to attribute files if mm_stat file is incomplete. It
should not happen, but I have seen RHEL7 kernel where is no
num_migrated/pages_compacted attribute...

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-03-30 12:10:01 +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
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 627258104b ramctl: add support for zram-control
Based on patch from Timofey Titovets.

Addresses: https://github.com/karelzak/util-linux/issues/318
Reported-by: Timofey Titovets <nefelim4ag@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-05-11 12:43:40 +02:00
Karel Zak 1ab7abacce zramctl: fix typo
Reported-by: Rafael Fontenelle <rffontenelle@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-21 11:21:27 +01:00
Karel Zak 1ceb4077af zramctl: fix lists of the all devices
The command zramctl lists the same stat info for all devices (DATA COMPR TOTAL).

Reported-by: Oliver Freyermuth <o.freyermuth@googlemail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-09-24 12:46:21 +02:00
Yuri Chornoivan 75a8e726e9 Fix trivial typos 2015-08-25 20:02:53 +03:00
Sami Kerola 624e147ba2 misc: fix shadow declarations
sys-utils/zramctl.c: In function 'get_mm_stat':
sys-utils/zramctl.c:276:58: warning: declaration of 'inbytes' shadows a global declaration [-Wshadow]
 static char *get_mm_stat(struct zram *z, size_t idx, int inbytes)
sys-utils/zramctl.c:119:39: note: shadowed declaration is here
 static unsigned int raw, no_headings, inbytes;

libmount/src/tab.c: In function 'mnt_table_get_fs_root':
libmount/src/tab.c:1221:22: warning: declaration of 'fs' shadows a parameter [-Wshadow]
    struct libmnt_fs *fs = mnt_table_find_mountpoint(tb,
libmount/src/tab.c:1197:24: note: shadowed declaration is here
      struct libmnt_fs *fs,

disk-utils/fsck.minix.c: In function 'main':
disk-utils/fsck.minix.c:1364:17: warning: declaration of 'i' shadows a previous local [-Wshadow]
   unsigned long i, free;
disk-utils/fsck.minix.c:1250:6: note: shadowed declaration is here
  int i;

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-08-24 10:55:37 +02:00
Karel Zak bffc9174b8 zramctl: add MEM-LIMIT, MEM-USED and MIGRATED columns
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-05-18 11:30:56 +02:00
Karel Zak 5388c86260 zramctl: support /sys/block/zram<id>/mm_stat
Linux >= 4.1 provides all memory related statistics by one file.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-05-18 11:13:44 +02: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
Steven Honeyman 0a55b319d4 zramctl: fixed two -Wformat-security warnings
(they prevented compilation if -Werror=format-security is enabled)

Signed-off-by: Steven Honeyman <stevenhoneyman@users.noreply.github.com>
2014-09-15 21:59:31 +01:00
Sami Kerola 1fa6c3e0b9 zramctl: improve option combination error messaging
Use of --algorithm or --streams is not expected to work without
reseting device, that happens when --size is specified, so ensure the
former options to be combined with the later.

[kzak@redhat.com: - make it more generic]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-11 14:47:08 +02:00
Karel Zak 342436c66a zramctl: cannonicalize devname when no fullpath specified
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-11 14:39:46 +02:00
Sami Kerola 929c7b2817 zramctl: improve error message
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-08-11 14:27:13 +02:00
Karel Zak 116c9ce23d zramctl: fail status printout when device does not exist
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-11 14:26:20 +02:00
Karel Zak 423c0d75ec zramctl: remove extra \n from usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-06 15:04:58 +02:00
Karel Zak b07ca5160c zramctl: fix typo
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-06 09:02:09 +02:00
Karel Zak 6ed7f01127 zramctl: fix typo
Reported-by: Steven Honeyman
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-05 15:47:36 +02:00
Benno Schulenberg 1c35e62517 zramctl: fix the wording of some message strings
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-08-05 15:37:41 +02:00
Karel Zak 0624d8406b zrmactl: add new command to control /dev/zramN devices
Co-Author: Timofey Titovets <nefelim4ag@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-01 12:09:55 +02:00