From d0adb1c01c273e0210f348f0bb549bea4f2165af Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 9 Oct 2024 09:54:41 +0200 Subject: [PATCH] libblkid: add FSLASTBLOCK for swaparea Suggested-by: Peter Rajnoha Signed-off-by: Karel Zak (cherry picked from commit 0567efc790d4426df3001c6f8a19e276f114a450) --- libblkid/src/superblocks/superblocks.c | 1 + libblkid/src/superblocks/swap.c | 3 +++ tests/expected/blkid/low-probe-swap-luks | 1 + tests/expected/blkid/low-probe-swap1 | 1 + tests/expected/blkid/low-probe-swap1-big | 1 + 5 files changed, 7 insertions(+) diff --git a/libblkid/src/superblocks/superblocks.c b/libblkid/src/superblocks/superblocks.c index dd1e6dcf31..2b836dee19 100644 --- a/libblkid/src/superblocks/superblocks.c +++ b/libblkid/src/superblocks/superblocks.c @@ -594,6 +594,7 @@ static int blkid_probe_set_usage(blkid_probe pr, int usage) (const unsigned char *) u, strlen(u) + 1); } +/* size used by filesystem for data */ int blkid_probe_set_fssize(blkid_probe pr, uint64_t size) { struct blkid_chain *chn = blkid_probe_get_chain(pr); diff --git a/libblkid/src/superblocks/swap.c b/libblkid/src/superblocks/swap.c index 487690517f..2db1cdd803 100644 --- a/libblkid/src/superblocks/swap.c +++ b/libblkid/src/superblocks/swap.c @@ -47,9 +47,12 @@ static void swap_set_info_swap1(blkid_probe pr, uint32_t pagesize = mag->sboff + mag->len; blkid_probe_set_fsblocksize(pr, pagesize); + /* note that "lastpage" in swap header means number of pages used by + * swap, see mkswap */ uint32_t lastpage = endianness == BLKID_ENDIANNESS_LITTLE ? le32_to_cpu(hdr->lastpage) : be32_to_cpu(hdr->lastpage); blkid_probe_set_fssize(pr, (uint64_t) pagesize * lastpage); + blkid_probe_set_fslastblock(pr, lastpage + 1); } static int swap_set_info(blkid_probe pr, const struct blkid_idmag *mag, diff --git a/tests/expected/blkid/low-probe-swap-luks b/tests/expected/blkid/low-probe-swap-luks index 97cd5de754..3f3c1b1006 100644 --- a/tests/expected/blkid/low-probe-swap-luks +++ b/tests/expected/blkid/low-probe-swap-luks @@ -1,5 +1,6 @@ ID_FS_ENDIANNESS=LITTLE ID_FS_FSBLOCKSIZE=4096 +ID_FS_FSLASTBLOCK=64 ID_FS_FSSIZE=258048 ID_FS_TYPE=swap ID_FS_USAGE=other diff --git a/tests/expected/blkid/low-probe-swap1 b/tests/expected/blkid/low-probe-swap1 index 89b2e0ed30..7606d3008c 100644 --- a/tests/expected/blkid/low-probe-swap1 +++ b/tests/expected/blkid/low-probe-swap1 @@ -1,5 +1,6 @@ ID_FS_ENDIANNESS=LITTLE ID_FS_FSBLOCKSIZE=4096 +ID_FS_FSLASTBLOCK=64 ID_FS_FSSIZE=258048 ID_FS_LABEL=SWAP-TEST ID_FS_LABEL_ENC=SWAP-TEST diff --git a/tests/expected/blkid/low-probe-swap1-big b/tests/expected/blkid/low-probe-swap1-big index e9439217ba..b8b75e6e9b 100644 --- a/tests/expected/blkid/low-probe-swap1-big +++ b/tests/expected/blkid/low-probe-swap1-big @@ -1,5 +1,6 @@ ID_FS_ENDIANNESS=BIG ID_FS_FSBLOCKSIZE=8192 +ID_FS_FSLASTBLOCK=128 ID_FS_FSSIZE=1040384 ID_FS_LABEL=big ID_FS_LABEL_ENC=big -- 2.47.2