2005-01-03 05:37:28

by selvakumar nagendran

[permalink] [raw]
Subject: Getting inode no from current process file descriptor table

Hello,
How can we get the inode number for a file provided
we have the corresponding file descriptor. Can we use
files_struct -> fd[fd] to get struct file ?. From that
how can we get the corresponding inode number?

Regards,
selva



__________________________________
Do you Yahoo!?
Yahoo! Mail - now with 250MB free storage. Learn more.
http://info.mail.yahoo.com/mail_250


2005-01-03 16:10:13

by Martin Waitz

[permalink] [raw]
Subject: Re: Getting inode no from current process file descriptor table

hoi :)

On Sun, Jan 02, 2005 at 09:37:24PM -0800, selvakumar nagendran wrote:
> How can we get the inode number for a file provided
> we have the corresponding file descriptor. Can we use
> files_struct -> fd[fd] to get struct file ?. From that
> how can we get the corresponding inode number?

#include <linux/dcache.h>
#include <linux/file.h>
#include <linux/fs.h>

struct file * file = fget(fd);
inode_number = file->f_dentry->d_inode->i_ino;
fput(file);

--
Martin Waitz


Attachments:
(No filename) (479.00 B)
signature.asc (189.00 B)
Digital signature
Download all attachments