summaryrefslogtreecommitdiffstats
path: root/sys-utils/swapon.c
Commit message (Collapse)AuthorAgeFilesLines
* misc: consolidate version printing and close_stdout()Karel Zak2019-04-161-7/+6Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* swapon: fix compiler warnings [-Wcast-qual]Karel Zak2018-07-231-3/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* swapon: add --output-all optionSami Kerola2018-05-031-1/+7
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* sys-utils: use errexec()Karel Zak2018-02-011-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: don't check for swapon() number of argumentsKarel Zak2017-12-181-2/+1Star
| | | | | | | | 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>
* misc: cleanup UUID_STR_LEN definitionsKarel Zak2017-09-151-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: replace magic number 37 with UUID_STR_LENPhilip Prindeville2017-09-051-1/+5
| | | | Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
* misc: consolidate macro style USAGE_HELP_OPTIONSRuediger Meier2017-06-291-2/+2
| | | | | | | | | 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>
* misc: introduce print_usage_help_options()Ruediger Meier2017-06-271-2/+1Star
| | | | | | | | | | | | 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>
* misc: never use usage(stderr)Ruediger Meier2017-06-261-5/+9
| | | | | | | Here we fix all cases where we have usage(FILE*) functions. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: consolidate usage() "Available columns"Karel Zak2017-06-261-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: fix reassigned values before old ones has been used [cppcheck]Sami Kerola2017-06-141-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: consolidate smartcols error messagesKarel Zak2017-05-181-5/+6
| | | | | | ... just to keep translators happy Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: add static keyword to where needed [smatch scan]Sami Kerola2017-02-201-1/+1
| | | | | | | text-utils/rev.c:68:9: warning: symbol 'buf' was not declared. Should it be static? Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: do not use plain 0 as NULL [smatch scan]Sami Kerola2017-02-201-16/+16
| | | | | | | | | | 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>
* docs: Fix word repetitionsYuri Chornoivan2017-02-131-1/+1
|
* Use --help suggestion on invalid optionKarel Zak2016-12-191-2/+1Star
| | | | | | | | 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>
* swapon: fix discard option parsingKarel Zak2016-09-211-3/+4
| | | | | | | | | | | | | | | | | | | 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>
* misc: Fix various typosSebastian Rasmussen2016-05-311-1/+1
| | | | | | | Fix various typos in error messages, warnings, debug strings, comments and names of static functions. Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
* swapon: rewrite control struct usageKarel Zak2016-03-181-117/+183
| | | | | | | | | | | | | | | | | | | | | | | 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>
* swapon: remove unnecessary assertKarel Zak2016-03-151-3/+0Star
| | | | | Addresses: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=818252 Signed-off-by: Karel Zak <kzak@redhat.com>
* swapon: drop perms if setuid before call mkswapKarel Zak2016-02-111-4/+8
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* swapon: simplify ctl->device usageKarel Zak2016-02-111-43/+37Star
| | | | | | | * 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: do not run execvp() calls when swapon is setuid binarySami Kerola2016-02-111-0/+4
| | | | | | | | 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>
* swapon: move function arguments to control structureSami Kerola2016-02-111-81/+77Star
| | | | | | | | 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>
* swapon: add control structSami Kerola2016-02-111-124/+129
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* swapon: fix stat(3) and open(3) raceSami Kerola2015-11-091-7/+7
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* swapon: fix restart waitpid with errno == EINTRKarel Zak2015-07-011-8/+7Star
| | | | | Reported-by: Maks Naumov (https://github.com/karelzak/util-linux/pull/205) Signed-off-by: Karel Zak <kzak@redhat.com>
* swapon: search for mkswap via PATHMike Frysinger2015-04-271-4/+2Star
| | | | | | | | 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>
* textual: grammarize and harmonize the stat error messageBenno Schulenberg2015-02-021-1/+1
| | | | | | | | | 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>
* textual: fix spellos and inconsistencies in several program messagesBenno Schulenberg2015-01-261-3/+3
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* maint: fix shadow declarationSami Kerola2015-01-071-7/+7
| | | | | | | | | | | | | | | | 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>
* textual: add a docstring to most of the utilitiesBenno Schulenberg2015-01-061-1/+3
| | | | | | | | | 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>
* swapon: reword some usage stringsBenno Schulenberg2014-11-071-3/+3
| | | | | | | Also remove some inconsistent periods and properly punctuate the closing sentence. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* swapon: remove extra word from usageKarel Zak2014-10-311-1/+1
| | | | | Reported-by: Benno Schulenberg <bensberg@justemail.net> Signed-off-by: Karel Zak <kzak@redhat.com>
* textual: slice up the usage text of swapon for ease of translationBenno Schulenberg2014-10-311-12/+12
| | | | | | | 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>
* swapon: add -o <list> for compatibility with mountKarel Zak2014-10-201-21/+68
| | | | | | | | | | | | | 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: align available columns section in usage()Sami Kerola2014-10-011-1/+1
| | | | | | Commit 5db57cfc469b45ada0162a64d627ce25a3d2431f missed doing this change. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* swapon: split swapon-common.cKarel Zak2014-09-221-4/+2Star
| | | | | | | | | | | 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>
* swapon: remove invalid error string print outsSami Kerola2014-08-111-2/+2
| | | | | | | | | To avoid messages like this: $ swapon /dev/zram0 swapon: /dev/zram0: read swap header failed: Success Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* swapon: don't print errors as data in smartcols tableKarel Zak2014-07-221-4/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* swapon: don't use empty strings for smartcols outputKarel Zak2014-07-221-6/+2Star
| | | | | | | The libsmartcols is smart enough to accept NULL for empty fields rather than empty strings. Signed-off-by: Karel Zak <kzak@redhat.com>
* swapon: share get_swap_prober() with swaplabel to print uuid and labelSami Kerola2014-07-221-2/+36
| | | | | | | | | | | | 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>
* swapon: clean up columns[] usageKarel Zak2014-07-181-6/+6
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* swapon: mark --sumarry as deprecatedKarel Zak2014-06-301-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* swapon: align --summary fieldsSami Kerola2014-06-301-1/+1
| | | | | | | | | | | | 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>
* libsmartcols: add debug messagesKarel Zak2014-06-061-0/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* swapon, swapheader, mkswap: move swap signature to headerSami Kerola2014-05-061-3/+0Star
| | | | | | | | | | 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>
* swapon: swaps with legacy version label are not supportedSami Kerola2014-05-061-2/+1Star
| | | | | Reviewed-by: Benno Schulenberg <bensberg@justemail.net> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* mkswap, swaplabel: move version number to headerSami Kerola2014-05-041-6/+4Star
| | | | | | | Corrently only the swap version 1 is supported, which is a magic value so move it to header. Signed-off-by: Sami Kerola <kerolasa@iki.fi>