summaryrefslogtreecommitdiffstats
path: root/sys-utils/swapon.c
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* libsmartcols: clean up flags usageKarel Zak2014-04-031-3/+3
| | | | | | | | | * rename flags functions to scols_table_enable_* * rename *_no_foo() functions to _nofoo() * output formats are mutually exclusive, so don't use flags there * don't assume symbols in scols_new_table(), use scols_table_set_symbols() Signed-off-by: Karel Zak <kzak@redhat.com>
* swapon: clean up scols usageKarel Zak2014-04-031-19/+11Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* swapon: use libsmartcolsOndrej Oprala2014-04-031-23/+30
| | | | Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
* swapon: use TT_FL_FREEDATA for tt tableKarel Zak2013-09-161-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* swapon: allow a more flexible swap discard policyRafael Aquini2013-08-231-21/+72
| | | | | | | | | | | | | | | | | | | | Introduce the necessary changes to swapon(8) allowing a sysadmin to leverage the new changes introduced to sys_swapon by "swap: discard while swapping only if SWAP_FLAG_DISCARD_PAGES", therefore allowing a more flexible set of choices when selection the discard policy for mounted swap areas. This patch introduces the following optional arguments to the already existent swapon(8) "--discard" option, in order to allow a discard type to be selected at swapon time: * once : only single-time area discards are issued. (swapon) * pages : discard freed pages before they are reused. If no policy is selected both discard types are enabled. (default) [kzak@redhat.com: - support <policy> argument for short -d option too, - add errx() on unsupported policy name] Signed-off-by: Rafael Aquini <aquini@redhat.com> Acked-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: use libmnt_cache reference countingKarel Zak2013-08-211-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* libmount: add mnt_table_is_empty(), improve table list usageKarel Zak2013-08-201-2/+4
| | | | | | | | Currently you have to use mnt_table_remove_fs() + mnt_free_fs() to destroy the list in the table. This is complicated in same situations. This patch allows to use mnt_free_fs() only. Signed-off-by: Karel Zak <kzak@redhat.com>
* swapon: check writing to a file descriptor was successfulSami Kerola2013-04-261-1/+4
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* translation: unify exec error messagesSami Kerola2013-02-061-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* swapon: default to --show if nothing is requestedSami Kerola2013-01-091-4/+1Star
| | | | | | Proposed-by: Karel Zak <kzak@redhat.com> References: http://www.spinics.net/lists/util-linux-ng/msg07301.html Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* swapon: print warning about insecure owner/permissionsKarel Zak2013-01-081-10/+6Star
| | | | | | | | | Let's make it more obvious if swap area is accessible for non-root users. The old version prints the warning only if --verbose is specified. Reported-by: mp.lists@free.fr Signed-off-by: Karel Zak <kzak@redhat.com>
* swapon: fix memmory leak [coverity scan]Karel Zak2012-12-121-4/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* swapon: don't care about xasprintf() return codeKarel Zak2012-12-121-7/+6Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* swapon: remove loop declaration [smatch scan]Sami Kerola2012-10-151-1/+2
| | | | | | | sys-utils/swapon.c:677:2: error: 'for' loop initial declarations are only allowed in C99 mode Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* swapon: check numeric user inputsSami Kerola2012-10-151-1/+2
| | | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* translation: unify file open error messagesSami Kerola2012-07-161-2/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* translation: unify stat error messagesSami Kerola2012-07-161-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* swapon: remove unused variablesSami Kerola2012-07-161-1/+0Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* swapon: fix --summary output regressionSami Kerola2012-07-101-1/+1
| | | | | | | Commit 64b588814e5f081a7ab37f820984aa7a2de9eee9 changed --summary header alignment, and usage of spaces vs tabs in output. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* swapon: make --show size to be human readable by defaultSami Kerola2012-07-101-7/+25
| | | | | | | Cc: Bernhard Voelker <mail@bernhard-voelker.de> Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* swapon: add --show optionSami Kerola2012-07-101-1/+186
| | | | | | | | | | | | The --show uses lib/tt.c, which allows user to specify columns he is interested of, and avoids using hard coded field sizes which may be problematic when system has large enough swap. [kzak@redhat.com: - improve usage(), remove unused code] Cc: Bernhard Voelker <mail@bernhard-voelker.de> Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* swapon: fix typoKarel Zak2012-06-271-1/+1
| | | | | Reported-by: Manan Tuli <mt_void@yahoo.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* swapon: add support for PARTUUID= and PARTLABEL=Karel Zak2012-04-191-5/+7
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* swapon: minor coding style changesKarel Zak2012-04-181-32/+23Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* swapon: cleanup usage()Karel Zak2012-04-181-54/+52Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* swapon: cleanup main()Karel Zak2012-04-181-32/+16Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* swapoff: move code from swapon.c to swapoff.cKarel Zak2012-04-181-169/+1Star
| | | | | | | | | * 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>
* swapon: move generic code to swapon-common.cKarel Zak2012-04-181-86/+21Star
| | | | | | This will allow to use separate binary for swapon and swapoff. Signed-off-by: Karel Zak <kzak@redhat.com>
* swapon: use libmount for fstab parsing (for swapon --all)Karel Zak2012-04-181-41/+51
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* swapon: use only libmount for paths/tags evealuationKarel Zak2012-04-171-15/+9Star
| | | | | | | libmount provides very simple API for paths and tags canonicalizations, let's use it, rather directly link to libblkid and lib/canonicalize.c. Signed-off-by: Karel Zak <kzak@redhat.com>
* swapon: use libmount for /proc/swaps parsingKarel Zak2012-04-171-99/+65Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>