summaryrefslogtreecommitdiffstats
path: root/sys-utils/swapon.c
diff options
context:
space:
mode:
authorSami Kerola2014-04-25 22:37:58 +0200
committerSami Kerola2014-05-04 12:42:03 +0200
commit8a101b1447ce3f5c0286c5ebea452920b38133d3 (patch)
tree16970502d42818bd3052d733568e79114297504b /sys-utils/swapon.c
parentinclude/c.h: add macro to print definitions as string (diff)
downloadkernel-qcow2-util-linux-8a101b1447ce3f5c0286c5ebea452920b38133d3.tar.gz
kernel-qcow2-util-linux-8a101b1447ce3f5c0286c5ebea452920b38133d3.tar.xz
kernel-qcow2-util-linux-8a101b1447ce3f5c0286c5ebea452920b38133d3.zip
mkswap, swaplabel: move version number to header
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>
Diffstat (limited to 'sys-utils/swapon.c')
-rw-r--r--sys-utils/swapon.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/sys-utils/swapon.c b/sys-utils/swapon.c
index 3866ee70d..6c422ce41 100644
--- a/sys-utils/swapon.c
+++ b/sys-utils/swapon.c
@@ -402,21 +402,19 @@ static unsigned long long swap_get_size(const char *hdr, const char *devname,
unsigned int pagesize)
{
unsigned int last_page = 0;
- int swap_version = 0;
+ const unsigned int swap_version = SWAP_VERSION;
int flip = 0;
struct swap_header_v1_2 *s;
s = (struct swap_header_v1_2 *) hdr;
- if (s->version == 1) {
- swap_version = 1;
+ if (s->version == swap_version) {
last_page = s->last_page;
- } else if (swab32(s->version) == 1) {
+ } else if (swab32(s->version) == swap_version) {
flip = 1;
- swap_version = 1;
last_page = swab32(s->last_page);
}
if (verbose)
- warnx(_("%s: found swap signature: version %d, "
+ warnx(_("%s: found swap signature: version %ud, "
"page-size %d, %s byte order"),
devname,
swap_version,