linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chao Yu <chao@kernel.org>
To: akpm@linux-foundation.org, adobriyan@gmail.com
Cc: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org,
	linux-fsdevel@vger.kernel.org, Chao Yu <chao@kernel.org>
Subject: [PATCH] proc: introduce proc_statfs()
Date: Tue, 10 Jan 2023 23:20:03 +0800	[thread overview]
Message-ID: <20230110152003.1118777-1-chao@kernel.org> (raw)

Introduce proc_statfs() to replace simple_statfs(), so that
f_bsize queried from statfs() can be consistent w/ the value we
set in s_blocksize.

stat -f /proc/

Before:
    ID: 0        Namelen: 255     Type: proc
Block size: 4096       Fundamental block size: 4096
Blocks: Total: 0          Free: 0          Available: 0
Inodes: Total: 0          Free: 0

After:
    ID: 0        Namelen: 255     Type: proc
Block size: 1024       Fundamental block size: 1024
Blocks: Total: 0          Free: 0          Available: 0
Inodes: Total: 0          Free: 0

Signed-off-by: Chao Yu <chao@kernel.org>
---
 fs/proc/inode.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index f495fdb39151..d39e3b9b3135 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -25,6 +25,7 @@
 #include <linux/slab.h>
 #include <linux/mount.h>
 #include <linux/bug.h>
+#include <linux/statfs.h>
 
 #include "internal.h"
 
@@ -176,6 +177,14 @@ static inline const char *hidepid2str(enum proc_hidepid v)
 	return "unknown";
 }
 
+static int proc_statfs(struct dentry *dentry, struct kstatfs *buf)
+{
+	buf->f_type = dentry->d_sb->s_magic;
+	buf->f_bsize = dentry->d_sb->s_blocksize;
+	buf->f_namelen = PROC_NAME_LEN;
+	return 0;
+}
+
 static int proc_show_options(struct seq_file *seq, struct dentry *root)
 {
 	struct proc_fs_info *fs_info = proc_sb_info(root->d_sb);
@@ -195,7 +204,7 @@ const struct super_operations proc_sops = {
 	.free_inode	= proc_free_inode,
 	.drop_inode	= generic_delete_inode,
 	.evict_inode	= proc_evict_inode,
-	.statfs		= simple_statfs,
+	.statfs		= proc_statfs,
 	.show_options	= proc_show_options,
 };
 
-- 
2.25.1


             reply	other threads:[~2023-01-10 15:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-10 15:20 Chao Yu [this message]
2023-01-10 17:58 ` [PATCH] proc: introduce proc_statfs() Alexey Dobriyan
2023-01-11  9:20   ` Chao Yu

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=20230110152003.1118777-1-chao@kernel.org \
    --to=chao@kernel.org \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).