mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Libing Zhou <libing.zhou@nokia-sbell.com>
To: linux-kernel@vger.kernel.org
Cc: libing.zhou@nokia-sbell.com, akpm@linux-foundation.org,
	dhowells@redhat.com, viro@zeniv.linux.org.uk
Subject: [PATCH] ROMFS: support inode blocks calculation
Date: Tue, 11 Aug 2020 13:26:06 +0800	[thread overview]
Message-ID: <20200811052606.4243-1-libing.zhou@nokia-sbell.com> (raw)

When use 'stat' tool to display file status, the 'Blocks' field
always in '0', this is not good for tool 'du'(e.g.: busybox 'du'),
it always output '0' size for the files under ROMFS since such
tool calculates number of 512B Blocks.

This patch calculates approx. number of 512B blocks based on inode
size.

Signed-off-by: Libing Zhou <libing.zhou@nokia-sbell.com>
---
 fs/romfs/super.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/romfs/super.c b/fs/romfs/super.c
index e582d001f792..b1b7d3f5752f 100644
--- a/fs/romfs/super.c
+++ b/fs/romfs/super.c
@@ -356,6 +356,7 @@ static struct inode *romfs_iget(struct super_block *sb, unsigned long pos)
 	}
 
 	i->i_mode = mode;
+	i->i_blocks = (i->i_size + 511) >> 9;
 
 	unlock_new_inode(i);
 	return i;
-- 
2.22.0


             reply	other threads:[~2020-08-11  5:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-11  5:26 Libing Zhou [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-08-10  2:08 Libing Zhou
2020-07-29 10:09 Libing Zhou

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=20200811052606.4243-1-libing.zhou@nokia-sbell.com \
    --to=libing.zhou@nokia-sbell.com \
    --cc=akpm@linux-foundation.org \
    --cc=dhowells@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®