Blame 0021-libblkid-implement-FSSIZE-calculation-for-XFS.patch

Karel Zak 18b0e4
From e81cc68312e91ab7086188542f3377605bf144a8 Mon Sep 17 00:00:00 2001
Karel Zak 18b0e4
From: Andrey Albershteyn <aalbersh@redhat.com>
Karel Zak 18b0e4
Date: Mon, 25 Apr 2022 17:08:38 +0200
Karel Zak 18b0e4
Subject: libblkid: implement FSSIZE calculation for XFS
Karel Zak 18b0e4
Karel Zak 18b0e4
The implementation is similar to one provided by statfs(2) + lsblk.
Karel Zak 18b0e4
Karel Zak 18b0e4
Upstream: http://github.com/util-linux/util-linux/commit/d7ec8fe8e
Karel Zak 18b0e4
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2064810
Karel Zak 18b0e4
Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
Karel Zak 18b0e4
---
Karel Zak 18b0e4
 libblkid/src/superblocks/xfs.c | 10 ++++++++++
Karel Zak 18b0e4
 1 file changed, 10 insertions(+)
Karel Zak 18b0e4
Karel Zak 18b0e4
diff --git a/libblkid/src/superblocks/xfs.c b/libblkid/src/superblocks/xfs.c
Karel Zak 18b0e4
index d8c6fb6d4..444050f55 100644
Karel Zak 18b0e4
--- a/libblkid/src/superblocks/xfs.c
Karel Zak 18b0e4
+++ b/libblkid/src/superblocks/xfs.c
Karel Zak 18b0e4
@@ -158,6 +158,15 @@ static int xfs_verify_sb(struct xfs_super_block *ondisk)
Karel Zak 18b0e4
 	return 1;
Karel Zak 18b0e4
 }
Karel Zak 18b0e4
 
Karel Zak 18b0e4
+static uint64_t xfs_fssize(struct xfs_super_block *xs)
Karel Zak 18b0e4
+{
Karel Zak 18b0e4
+	uint32_t lsize = xs->sb_logstart ? xs->sb_logblocks : 0;
Karel Zak 18b0e4
+	uint64_t avail_blocks = be64_to_cpu(xs->sb_dblocks) - be32_to_cpu(lsize);
Karel Zak 18b0e4
+	uint64_t fssize = avail_blocks*be32_to_cpu(xs->sb_blocksize);
Karel Zak 18b0e4
+
Karel Zak 18b0e4
+	return fssize;
Karel Zak 18b0e4
+}
Karel Zak 18b0e4
+
Karel Zak 18b0e4
 static int probe_xfs(blkid_probe pr, const struct blkid_idmag *mag)
Karel Zak 18b0e4
 {
Karel Zak 18b0e4
 	struct xfs_super_block *xs;
Karel Zak 18b0e4
@@ -173,6 +182,7 @@ static int probe_xfs(blkid_probe pr, const struct blkid_idmag *mag)
Karel Zak 18b0e4
 		blkid_probe_set_label(pr, (unsigned char *) xs->sb_fname,
Karel Zak 18b0e4
 				sizeof(xs->sb_fname));
Karel Zak 18b0e4
 	blkid_probe_set_uuid(pr, xs->sb_uuid);
Karel Zak 18b0e4
+	blkid_probe_set_fssize(pr, xfs_fssize(xs));
Karel Zak 18b0e4
 	blkid_probe_set_block_size(pr, be16_to_cpu(xs->sb_sectsize));
Karel Zak 18b0e4
 	return 0;
Karel Zak 18b0e4
 }
Karel Zak 18b0e4
-- 
Karel Zak 18b0e4
2.36.1
Karel Zak 18b0e4