[prev in list] [next in list] [prev in thread] [next in thread]
List: util-linux-ng
Subject: [PATCH 2/2] libblkid: implement FSSIZE calculation for XFS
From: Andrey Albershteyn <aalbersh () redhat ! com>
Date: 2022-04-21 13:09:46
Message-ID: 20220421130946.318737-3-aalbersh () redhat ! com
[Download RAW message or body]
The implementation is similar to one provided by statfs(2) + lsblk.
Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
---
libblkid/src/superblocks/xfs.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/libblkid/src/superblocks/xfs.c b/libblkid/src/superblocks/xfs.c
index d8c6fb6d4..444050f55 100644
--- a/libblkid/src/superblocks/xfs.c
+++ b/libblkid/src/superblocks/xfs.c
@@ -158,6 +158,15 @@ static int xfs_verify_sb(struct xfs_super_block *ondisk)
return 1;
}
+static uint64_t xfs_fssize(struct xfs_super_block *xs)
+{
+ uint32_t lsize = xs->sb_logstart ? xs->sb_logblocks : 0;
+ uint64_t avail_blocks = be64_to_cpu(xs->sb_dblocks) - be32_to_cpu(lsize);
+ uint64_t fssize = avail_blocks*be32_to_cpu(xs->sb_blocksize);
+
+ return fssize;
+}
+
static int probe_xfs(blkid_probe pr, const struct blkid_idmag *mag)
{
struct xfs_super_block *xs;
@@ -173,6 +182,7 @@ static int probe_xfs(blkid_probe pr, const struct blkid_idmag *mag)
blkid_probe_set_label(pr, (unsigned char *) xs->sb_fname,
sizeof(xs->sb_fname));
blkid_probe_set_uuid(pr, xs->sb_uuid);
+ blkid_probe_set_fssize(pr, xfs_fssize(xs));
blkid_probe_set_block_size(pr, be16_to_cpu(xs->sb_sectsize));
return 0;
}
--
2.27.0
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic