summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--disk-utils/mkswap.c10
-rw-r--r--disk-utils/swaplabel.c4
-rw-r--r--include/swapheader.h1
-rw-r--r--sys-utils/swapon.c10
4 files changed, 12 insertions, 13 deletions
diff --git a/disk-utils/mkswap.c b/disk-utils/mkswap.c
index ae73f80a3..cd96ad575 100644
--- a/disk-utils/mkswap.c
+++ b/disk-utils/mkswap.c
@@ -449,7 +449,7 @@ main(int argc, char **argv) {
unsigned long long sz;
off_t offset;
int force = 0;
- int version = 1;
+ int version = SWAP_VERSION;
char *block_count = 0;
char *opt_label = NULL;
unsigned char *uuid = NULL;
@@ -517,7 +517,7 @@ main(int argc, char **argv) {
usage(stderr);
}
- if (version != 1)
+ if (version != SWAP_VERSION)
errx(EXIT_FAILURE,
_("swapspace version %d is not supported"), version);
@@ -601,7 +601,7 @@ main(int argc, char **argv) {
wipe_device(DEV, device_name, force);
hdr = (struct swap_header_v1_2 *) signature_page;
- hdr->version = 1;
+ hdr->version = version;
hdr->last_page = PAGES - 1;
hdr->nr_badpages = badpages;
@@ -609,8 +609,8 @@ main(int argc, char **argv) {
errx(EXIT_FAILURE, _("Unable to set up swap-space: unreadable"));
goodpages = PAGES - badpages - 1;
- printf(_("Setting up swapspace version 1, size = %llu KiB\n"),
- goodpages * pagesize / 1024);
+ printf(_("Setting up swapspace version %d, size = %llu KiB\n"),
+ version, goodpages * pagesize / 1024);
write_signature("SWAPSPACE2");
write_uuid_and_label(uuid, opt_label);
diff --git a/disk-utils/swaplabel.c b/disk-utils/swaplabel.c
index 5d048aabb..8d5b260c5 100644
--- a/disk-utils/swaplabel.c
+++ b/disk-utils/swaplabel.c
@@ -67,10 +67,10 @@ static blkid_probe get_swap_prober(const char *devname)
warnx(_("%s: not a valid swap partition"), devname);
if (rc == 0) {
- /* supported is SWAPSPACE2 only */
+ /* Only the SWAPSPACE2 is supported. */
if (blkid_probe_lookup_value(pr, "VERSION", &version, NULL) == 0
&& version
- && strcmp(version, "1"))
+ && strcmp(version, stringify_value(SWAP_VERSION)))
warnx(_("%s: unsupported swap version '%s'"),
devname, version);
else
diff --git a/include/swapheader.h b/include/swapheader.h
index 42d521a49..80fa36b88 100644
--- a/include/swapheader.h
+++ b/include/swapheader.h
@@ -11,6 +11,7 @@ struct swap_header_v1 {
};
+#define SWAP_VERSION 1
#define SWAP_UUID_LENGTH 16
#define SWAP_LABEL_LENGTH 16
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,