]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: add FSLASTBLOCK for swaparea
authorKarel Zak <kzak@redhat.com>
Wed, 9 Oct 2024 07:54:41 +0000 (09:54 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 9 Oct 2024 10:57:13 +0000 (12:57 +0200)
Suggested-by: Peter Rajnoha <prajnoha@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid/src/superblocks/superblocks.c
libblkid/src/superblocks/swap.c
tests/expected/blkid/low-probe-swap-luks
tests/expected/blkid/low-probe-swap1
tests/expected/blkid/low-probe-swap1-big

index e89cb598d679b9b4f482b3b72780c0a69a3c54c7..82047f18644db499548648052214fb0276918527 100644 (file)
@@ -597,6 +597,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);
index 487690517fcc47a6c5ffcb579cfa5c483231dd91..2db1cdd8038e5491f257af39172f85d68d27f778 100644 (file)
@@ -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,
index 97cd5de7540575cfab1ea69c514968f3b3a41480..3f3c1b1006023b1b9376754dbb4b1a7b42aed07a 100644 (file)
@@ -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
index 89b2e0ed307085ff73aec3daaa214c43a3c2cab6..7606d3008c0eed742e8d8f286b1d5b4a88540094 100644 (file)
@@ -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
index e9439217ba60da241ad969855f1c1d85d6ffca26..b8b75e6e9bb2c2601a4468992c5472b08fe1271d 100644 (file)
@@ -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