]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: swap: report endianess
authorThomas Weißschuh <thomas@t-8ch.de>
Wed, 14 Dec 2022 00:13:19 +0000 (00:13 +0000)
committerThomas Weißschuh <thomas@t-8ch.de>
Wed, 14 Dec 2022 12:00:57 +0000 (12:00 +0000)
libblkid/src/superblocks/swap.c
tests/expected/blkid/low-probe-swap1

index fcdb13bd7c3eb93cf618a874b9369eaf77082eac..6a05c257b6cd13756f6dccf83174c1703dcdd566 100644 (file)
@@ -36,6 +36,14 @@ struct swap_header_v1_2 {
 #define TOI_MAGIC_STRING       "\xed\xc3\x02\xe9\x98\x56\xe5\x0c"
 #define TOI_MAGIC_STRLEN       (sizeof(TOI_MAGIC_STRING) - 1)
 
+static void swap_set_info_swap1(blkid_probe pr,
+               const struct swap_header_v1_2 *hdr)
+{
+       enum BLKID_ENDIANNESS endianness = le32_to_cpu(hdr->version) == 1 ?
+               BLKID_ENDIANNESS_LITTLE : BLKID_ENDIANNESS_BIG;
+       blkid_probe_set_fsendianness(pr, endianness);
+}
+
 static int swap_set_info(blkid_probe pr, const char *version)
 {
        struct swap_header_v1_2 *hdr;
@@ -56,6 +64,7 @@ static int swap_set_info(blkid_probe pr, const char *version)
                        DBG(LOWPROBE, ul_debug("not set last swap page"));
                        return 1;
                }
+               swap_set_info_swap1(pr, hdr);
        }
 
        /* arbitrary sanity check.. is there any garbage down there? */
index bfac28e3e8ff88c3c6fd39e87b60ee1a33ae90e2..3565ce236ccc36b4abfed044e064511b82d1b44b 100644 (file)
@@ -1,3 +1,4 @@
+ID_FS_ENDIANNESS=LITTLE
 ID_FS_LABEL=SWAP-TEST
 ID_FS_LABEL_ENC=SWAP-TEST
 ID_FS_TYPE=swap