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>
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>
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>
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>
The current code does not work as expected if there is an option
behind the discard=<arg>, for example:
swapon /dev/sdc -o discard=once,pri=10
ignores "once" the result is SWAP_FLAG_DISCARD; strace:
Old version:
swapon("/dev/sdc", SWAP_FLAG_PREFER|SWAP_FLAG_DISCARD|10) = 0
Fixed version:
swapon("/dev/sdc", SWAP_FLAG_PREFER|SWAP_FLAG_DISCARD|SWAP_FLAG_DISCARD_ONCE|10) = 0
Signed-off-by: Karel Zak <kzak@redhat.com>
Fix various typos in error messages, warnings, debug strings,
comments and names of static functions.
Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
The old version has been pretty broken... the most important is to
keep swap options specified on command line as read-only template.
For example if we call "swapon --all" then we cannot modify the global
options for each fstab swap entry.
The another story has been control struct modification due to device
reinitialization etc.
This patch splits all to:
* struct swapon_control; top-level struct with command line options
* struct swap_device; this is device specific and never globally
maintained by swapon_control.
* struct swap_prop; used as global read-only template swap options
and per device swap options (when parse fstab).
Addresses: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=818252
Signed-off-by: Karel Zak <kzak@redhat.com>
* use and initialize ctl->{label,uuid,device} by do_swapon() only
* remove ctl->canonic, function arguments are good enough for this
Signed-off-by: Karel Zak <kzak@redhat.com>
swapon(8) is not expected to be setuid binary, but if it is try to avoid
obvious security vulnerability of executing user preferred mkswap file as
someone else, such as root.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This makes reading what the code does easier. This change also makes error
messages to prefer none-canonical device path, e.g., the one user supplied
rather than the canonical path needed internally.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Rather than hardcode /sbin/mkswap all the time, use a normal PATH search.
This matches the normal behavior of other tools, and makes local testing
easier.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
The message "stat failed %s" seems to say that stat() failed to
do something, or failed to pass a test, but of course it means
that the statting of something failed. So say so. Also make
two very similar messages equal to this one.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
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>
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>
A new option was added recently; seize this opportunity to cut the
usage text into small and easily managed chunks.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
The new option allows to specify swap options by fstab compatible
string. The concept is the same as for mount(8).
swapon -o pri=1,discard=pages,nofail /dev/sda2
The advantage is that tools (like systmed) that parses fstab can call
swapon without translation from fstab options to swapon(8) command
line options.
Signed-off-by: Karel Zak <kzak@redhat.com>
swapon - requires libmount and libblkid
swapoff - requires libmount
swaplabel - requires libblkid
This patch add lib/swapprober.c with blkid stuff for swap. It allows
to use and link libblkid only when necessary.
Signed-off-by: Karel Zak <kzak@redhat.com>
The swapon(8) listing was almost complete, apart from label and uuid.
This change moves the code from swaplabel(8) to shared scope to be used
for printouts in other swap commands, such as swapon.
Adding this feature to lsblk(8) was a consideration, but lsblk is not
interested of swapfiles, so the swapon seems like a better option to add
this information.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit makes partitions and files to have remaining three columns
aligned. Below print out demonstrates earlier misalignment.
$ swapon -s
Filename Type Size Used Priority
/dev/sda2 partition 4194300 0 3
/home/src/util-linux/newswap file 496 0 -1
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Both swapon and mkswap need to know what is valid device signature, so
share the value.
[kzak@redhat.com: - use SWAP_SIGNATURE_SZ properly in write_signature()]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>