]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: make swap detection arch independent
authorKarel Zak <kzak@redhat.com>
Thu, 18 Apr 2013 09:36:09 +0000 (11:36 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 18 Apr 2013 09:36:09 +0000 (11:36 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid/src/superblocks/swap.c

index 7ac119bedaf18e7bc7112726a4b5975ac20083e6..17f07255ce8ded73ee78f7dca56999dd13fcea81 100644 (file)
@@ -51,6 +51,17 @@ static int swap_set_info(blkid_probe pr, const char *version)
            (hdr->version != 1 || hdr->lastpage == 0))
                return -1;
 
+        if (strcmp(version, "2") == 0) {
+               if (hdr->version != 1 && swab32(hdr->version) != 1) {
+                       DBG(LOWPROBE, blkid_debug("incorrect swap version"));
+                       return -1;
+               }
+               if (hdr->lastpage == 0) {
+                       DBG(LOWPROBE, blkid_debug("not set last swap page"));
+                       return -1;
+               }
+        }
+
        /* arbitrary sanity check.. is there any garbage down there? */
        if (hdr->padding[32] == 0 && hdr->padding[33] == 0) {
                if (hdr->volume[0] && blkid_probe_set_label(pr, hdr->volume,