All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrey Albershteyn <aalbersh@redhat.com>
To: util-linux@vger.kernel.org
Cc: Andrey Albershteyn <aalbersh@redhat.com>
Subject: [PATCH 2/2] libblkid: implement FSSIZE calculation for XFS
Date: Thu, 21 Apr 2022 15:09:46 +0200	[thread overview]
Message-ID: <20220421130946.318737-3-aalbersh@redhat.com> (raw)
In-Reply-To: <20220421130946.318737-1-aalbersh@redhat.com>

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


  parent reply	other threads:[~2022-04-21 13:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-21 13:09 [PATCH 0/2] libblkid: add FSSIZE with XFS implementation Andrey Albershteyn
2022-04-21 13:09 ` [PATCH 1/2] libblkid: add interface for FSSIZE field Andrey Albershteyn
2022-04-25 13:40   ` Karel Zak
2022-04-21 13:09 ` Andrey Albershteyn [this message]
2022-04-25 13:43 ` [PATCH 0/2] libblkid: add FSSIZE with XFS implementation Karel Zak
2022-04-25 15:38   ` Eric Sandeen
2022-04-26  8:21     ` Karel Zak
     [not found]       ` <YmfPPbgZtZi1iSXv@aalbersh.remote.csb>
2022-04-27  4:10         ` Eric Sandeen
2022-04-29  8:43           ` Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220421130946.318737-3-aalbersh@redhat.com \
    --to=aalbersh@redhat.com \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.