Skip to contentSkip to conversation

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

DISCUSSION Al Viro 3 participants 4 messages Jun 4, 2024 – Jun 5, 2024

Subsystems (2)
lore
Share & tools
lore

Al Viro

author maintainer
#0 lore raw
	... 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?

#1 lore raw
Quoted 6 lines · Al Viro
        ... 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.

author maintainer
#2 lore raw
Quoted 9 lines · Ivan Babrou
Quoted 6 lines · Al Viro
        ... 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)

---

fs/proc/fd.c +1 -10
index 586bbc84ca04..bda7abcf29fa 100644
@@ -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 = {
maintainer Reviewed-by
#3 lore raw
Quoted 13 lines · Al Viro
Quoted 9 lines · Ivan Babrou
Quoted 6 lines · Al Viro
        ... 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?

Quoted 7 lines

[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)

---

Kill it,