linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: Ivan Babrou <ivan@cloudflare.com>
Cc: linux-fsdevel@vger.kernel.org, kernel-team <kernel-team@cloudflare.com>
Subject: Re: why does proc_fd_getattr() bother with S_ISDIR(inode->i_mode)?
Date: Tue, 4 Jun 2024 18:40:59 +0100	[thread overview]
Message-ID: <20240604174059.GQ1629371@ZenIV> (raw)
In-Reply-To: <CABWYdi0KTJVsuEokmUF+fQ6w9orGNeaJLyjni0E8T+A0-FHe7g@mail.gmail.com>

On Tue, Jun 04, 2024 at 10:35:43AM -0700, Ivan Babrou wrote:
> On Mon, Jun 3, 2024 at 8:40 PM Al Viro <viro@zeniv.linux.org.uk> wrote:
> >
> >         ... when the only way to get to it is via ->getattr() in
> > proc_fd_inode_operations?  Note that proc_fd_inode_operations
> > has ->lookup() in it; it _can't_ be ->i_op of a non-directory.
> >
> >         Am I missing something here?
> 
> It's been two years, but I think I was just extra cautious.

Does anyone have objections against the following?

[PATCH] proc_fd_getattr(): don't bother with S_ISDIR() check
    
that thing is callable only as ->i_op->getattr() instance and only
for directory inodes (/proc/*/fd and /proc/*/task/*/fd)

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
diff --git a/fs/proc/fd.c b/fs/proc/fd.c
index 586bbc84ca04..bda7abcf29fa 100644
--- a/fs/proc/fd.c
+++ b/fs/proc/fd.c
@@ -357,18 +357,9 @@ static int proc_fd_getattr(struct mnt_idmap *idmap,
 			u32 request_mask, unsigned int query_flags)
 {
 	struct inode *inode = d_inode(path->dentry);
-	int rv = 0;
 
 	generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat);
-
-	/* If it's a directory, put the number of open fds there */
-	if (S_ISDIR(inode->i_mode)) {
-		rv = proc_readfd_count(inode, &stat->size);
-		if (rv < 0)
-			return rv;
-	}
-
-	return rv;
+	return proc_readfd_count(inode, &stat->size);
 }
 
 const struct inode_operations proc_fd_inode_operations = {

  reply	other threads:[~2024-06-04 17:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-04  3:40 why does proc_fd_getattr() bother with S_ISDIR(inode->i_mode)? Al Viro
2024-06-04 17:35 ` Ivan Babrou
2024-06-04 17:40   ` Al Viro [this message]
2024-06-05 14:26     ` Christian Brauner

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=20240604174059.GQ1629371@ZenIV \
    --to=viro@zeniv.linux.org.uk \
    --cc=ivan@cloudflare.com \
    --cc=kernel-team@cloudflare.com \
    --cc=linux-fsdevel@vger.kernel.org \
    /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).