Commit Graph

17 Commits

Author SHA1 Message Date
Karel Zak e4253d3ca4 swapoff: do not use 1 exist status at all
The make sure we are not in collision with old versions.

Addresses: https://github.com/karelzak/util-linux/issues/1050
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-05-28 12:51:26 +02:00
Karel Zak ecfa4dad6f swapoff: cleanup EXIT STATUS
The current code hides details about reason why swapoff(8) and swapoff(2) failed. For example
ENOMEM from swapoff(2) is important as it indicates OOM.

The patch also clean ups --all return codes to be more compatible for
example with [u]mount --all, etc.

Addresses: https://github.com/karelzak/util-linux/issues/1050
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-05-27 18:58:30 +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 cf9b16f1d4 build-sys: don't check for swapon() number of arguments
The syscall swapon() with two arguments is supported since Linux 1.3.2
and it's really long time ago... Let's assume that all libc header files
have been already fixed.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-18 13:57:20 +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 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
Karel Zak eeea7ef590 swapoff: fix mem leak [coverity scan] 2016-10-05 11:20:26 +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 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 52f2fd9bcc swapoff: swapoff swap files by LABEL and UUID
# swapon --show=NAME,UUID
 NAME                   UUID
 /dev/sda3              8d52fca3-bf48-41d6-b826-2315e518a305
 /home/fs-images/2g.img 6fa72b96-b802-441f-a31c-091d65c0212c

 # swapoff UUID=6fa72b96-b802-441f-a31c-091d65c0212c
 swapoff: cannot find the device for UUID=6fa72b96-b802-441f-a31c-091d65c0212c

Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-07 12:08:11 +01: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 7cf6a65476 swapoff: cleanup usage() and includes
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-18 12:38:03 +02:00
Karel Zak e7b63bea04 swapoff: use libmount to parse fstab
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-18 12:22:11 +02:00
Karel Zak 6cf8d46cee swapoff: move code from swapon.c to swapoff.c
* multipurpose binaries (symlinks) suck when used with autotools
 * swapoff shares small subset of the code with swapon
 * usage() and 'struct option' is unnecessary complex when shared
 * shorter and simple code is easer to maintain...

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-18 11:43:42 +02:00