lkml.org 
[lkml]   [2012]   [Aug]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch 1/9] procfs: Move /proc/pid/fd[info] handling code to fd.[ch]
On Sat, Aug 25, 2012 at 11:43:25PM +0400, Cyrill Gorcunov wrote:

> Would the patch below improve the code? Look, I've not dropped
> find_inode_number call since it's a bit unclear for me what
> would happen if !child case hit
>
> child = d_lookup(dir, &qname);
> if (!child) {
> struct dentry *new = d_alloc(dir, &qname);
> if (new) {
> child = instantiate(dir->d_inode, new, task, ptr);
> if (child)
> dput(new);
> else
> child = new;
> }
> }
>
> can we be sure that i_ino won't be zero here?

First of all, ->i_ino is not going to be zero for any procfs inode.
As for !child case, that's possible only if d_lookup() returns NULL
*and* d_alloc() fails. In that case find_inode_number() will call
d_hash_and_lookup(), which will call d_lookup(), get NULL from it and
return NULL to find_inode_number(). Which will return 0 to the
caller.

AFAICS, if find_inode_number() is called there at all, it will return 0.
IOW, this if (!ino) ino = find_inode_number(...); is a no-op.


\
 
 \ /
  Last update: 2012-08-26 00:01    [W:0.056 / U:1.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site