Re: file->f_dentry need to be check ?

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

 



On Saturday 26 February 2005 08:59 pm, Tyler wrote:
> Hi all,
>
> In some functions, like vfs_readdir (in fs/readdir.c), there is this
> kind of code :
> struct inode *inode = file->f_dentry->d_inode;
> file is a given parameter.
> So if f_dentry is NULL there is a bug. But can f_dentry be null on an
> opened file ?

Can't happen. One of the first steps in opening a file is to resolve it's 
path, which is done by the dcache subsystem. It's purpose is to link the 
dentry (the path) with the inode of the file and to keep this info available 
for further lookups. Thus, on any open file the dentry and the inode are 
there.

>If the file is deleted before it could be. But I'm not sure that's why I 
>post this notre here :)

If the file is deleted you can't open it. If the file is deleted while used 
it's a longer story, but nothing goes wrong either.

tavi


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux