]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: fix swap-area version
authorKarel Zak <kzak@redhat.com>
Mon, 4 Nov 2013 08:59:54 +0000 (09:59 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 4 Nov 2013 08:59:54 +0000 (09:59 +0100)
 * v1: hdr->version = 1, magic string = SWAPSPACE2
 * v0: no versio in header, magic string = SWAP-SPACE

The mistake has been introduced in the old udev volume_id
binary where the version was set according to magic string.

Reported-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid/src/superblocks/swap.c

index 679c818045fafe4495f12c81666d7c7ce91bee07..4297a9c4050df78e8d071c97e556a475fa81c2fc 100644 (file)
@@ -47,7 +47,7 @@ static int swap_set_info(blkid_probe pr, const char *version)
                return -1;
 
        /* SWAPSPACE2 - check for wrong version or zeroed pagecount */
-        if (strcmp(version, "2") == 0) {
+        if (strcmp(version, "1") == 0) {
                if (hdr->version != 1 && swab32(hdr->version) != 1) {
                        DBG(LOWPROBE, blkid_debug("incorrect swap version"));
                        return -1;
@@ -88,11 +88,11 @@ static int probe_swap(blkid_probe pr, const struct blkid_idmag *mag)
 
        if (!memcmp(mag->magic, "SWAP-SPACE", mag->len)) {
                /* swap v0 doesn't support LABEL or UUID */
-               blkid_probe_set_version(pr, "1");
+               blkid_probe_set_version(pr, "0");
                return 0;
 
        } else if (!memcmp(mag->magic, "SWAPSPACE2", mag->len))
-               return swap_set_info(pr, "2");
+               return swap_set_info(pr, "1");
 
        return -1;
 }