* why does proc_fd_getattr() bother with S_ISDIR(inode->i_mode)? @ 2024-06-04 3:40 Al Viro 2024-06-04 17:35 ` Ivan Babrou 0 siblings, 1 reply; 4+ messages in thread From: Al Viro @ 2024-06-04 3:40 UTC (permalink / raw) To: Ivan Babrou; +Cc: linux-fsdevel ... 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? ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: why does proc_fd_getattr() bother with S_ISDIR(inode->i_mode)? 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 0 siblings, 1 reply; 4+ messages in thread From: Ivan Babrou @ 2024-06-04 17:35 UTC (permalink / raw) To: Al Viro; +Cc: linux-fsdevel, kernel-team 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. ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: why does proc_fd_getattr() bother with S_ISDIR(inode->i_mode)? 2024-06-04 17:35 ` Ivan Babrou @ 2024-06-04 17:40 ` Al Viro 2024-06-05 14:26 ` Christian Brauner 0 siblings, 1 reply; 4+ messages in thread From: Al Viro @ 2024-06-04 17:40 UTC (permalink / raw) To: Ivan Babrou; +Cc: linux-fsdevel, kernel-team 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 = { ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: why does proc_fd_getattr() bother with S_ISDIR(inode->i_mode)? 2024-06-04 17:40 ` Al Viro @ 2024-06-05 14:26 ` Christian Brauner 0 siblings, 0 replies; 4+ messages in thread From: Christian Brauner @ 2024-06-05 14:26 UTC (permalink / raw) To: Al Viro; +Cc: Ivan Babrou, linux-fsdevel, kernel-team On Tue, Jun 04, 2024 at 06:40:59PM +0100, Al Viro wrote: > 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> > --- Kill it, Reviewed-by: Christian Brauner <brauner@kernel.org> ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-06-05 14:26 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 2024-06-05 14:26 ` Christian Brauner
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.