From: Libing Zhou Date: Fri, 16 Oct 2020 03:13:42 +0000 (-0700) Subject: ROMFS: support inode blocks calculation X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=d9bc85de46cad90851c346b592005090674b7669;p=linux.git ROMFS: support inode blocks calculation 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 Signed-off-by: Andrew Morton Cc: David Howells Cc: Al Viro Link: http://lkml.kernel.org/r/20200811052606.4243-1-libing.zhou@nokia-sbell.com Signed-off-by: Linus Torvalds --- diff --git a/fs/romfs/super.c b/fs/romfs/super.c index e582d001f792e..b1b7d3f5752fa 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;