From: Thomas Weißschuh Date: Wed, 14 Dec 2022 00:13:19 +0000 (+0000) Subject: libblkid: swap: report endianess X-Git-Tag: v2.39-rc1~365^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1b883507b4d25537e079b840bda8ef7b0f76d549;p=thirdparty%2Futil-linux.git libblkid: swap: report endianess --- diff --git a/libblkid/src/superblocks/swap.c b/libblkid/src/superblocks/swap.c index fcdb13bd7c..6a05c257b6 100644 --- a/libblkid/src/superblocks/swap.c +++ b/libblkid/src/superblocks/swap.c @@ -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? */ diff --git a/tests/expected/blkid/low-probe-swap1 b/tests/expected/blkid/low-probe-swap1 index bfac28e3e8..3565ce236c 100644 --- a/tests/expected/blkid/low-probe-swap1 +++ b/tests/expected/blkid/low-probe-swap1 @@ -1,3 +1,4 @@ +ID_FS_ENDIANNESS=LITTLE ID_FS_LABEL=SWAP-TEST ID_FS_LABEL_ENC=SWAP-TEST ID_FS_TYPE=swap