From 2e831a1fb4fa4a6843e154edb1d9e80a1c610803 Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Fri, 17 Jan 2020 12:41:39 +0100 Subject: [PATCH] udf: Handle metadata partition better for statfs(2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the filesystem uses Metadata partition, we need to look at the underlying partition to get real total number of blocks in the filesystem. Do the necessary remapping in udf_statfs(). Reported-by: Pali Rohár Signed-off-by: Jan Kara --- fs/udf/super.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/udf/super.c b/fs/udf/super.c index f747bf72edbe..3bb9793db3aa 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -2395,11 +2395,17 @@ static int udf_statfs(struct dentry *dentry, struct kstatfs *buf) struct udf_sb_info *sbi = UDF_SB(sb); struct logicalVolIntegrityDescImpUse *lvidiu; u64 id = huge_encode_dev(sb->s_bdev->bd_dev); + unsigned int part = sbi->s_partition; + int ptype = sbi->s_partmaps[part].s_partition_type; + if (ptype == UDF_METADATA_MAP25) { + part = sbi->s_partmaps[part].s_type_specific.s_metadata. + s_phys_partition_ref; + } lvidiu = udf_sb_lvidiu(sb); buf->f_type = UDF_SUPER_MAGIC; buf->f_bsize = sb->s_blocksize; - buf->f_blocks = sbi->s_partmaps[sbi->s_partition].s_partition_len; + buf->f_blocks = sbi->s_partmaps[part].s_partition_len; buf->f_bfree = udf_count_free(sb); buf->f_bavail = buf->f_bfree; /* -- 2.16.4