Re: why does proc_fd_getattr() bother with S_ISDIR(inode->i_mode)?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxxxxxx>
---
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 = {




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux