mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ROMFS: support inode blocks calculation
@ 2020-08-11  5:26 Libing Zhou
  0 siblings, 0 replies; 3+ messages in thread
From: Libing Zhou @ 2020-08-11  5:26 UTC (permalink / raw)
  To: linux-kernel; +Cc: libing.zhou, akpm, dhowells, viro

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] ROMFS: support inode blocks calculation
@ 2020-08-10  2:08 Libing Zhou
  0 siblings, 0 replies; 3+ messages in thread
From: Libing Zhou @ 2020-08-10  2:08 UTC (permalink / raw)
  To: viro, dhowells; +Cc: libing.zhou, darrick.wong, deepa.kernel, linux-kernel

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] ROMFS: support inode blocks calculation
@ 2020-07-29 10:09 Libing Zhou
  0 siblings, 0 replies; 3+ messages in thread
From: Libing Zhou @ 2020-07-29 10:09 UTC (permalink / raw)
  To: viro, dhowells; +Cc: linux-kernel

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-11  5:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-11  5:26 [PATCH] ROMFS: support inode blocks calculation Libing Zhou
  -- strict thread matches above, loose matches on Subject: below --
2020-08-10  2:08 Libing Zhou
2020-07-29 10:09 Libing Zhou

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®