Skip to contentSkip to conversation

Getting dentry from inode

DISCUSSION UZAIR LAKHANI 2 participants 2 messages Apr 17, 2006 VFS

lore
Share & tools
lore
#0 lore raw

Hello All,

I want to know about these two questions.

(1) How to get a pointer to an inode if one has only the inode number available. May I use the iget() function. I only want a reference to the inode whose number I have.

(2) How to get the dentry from inode. Is d_find_alias ok. There can be multiple dentries attached to a single inode then which dentry will d_find_alias will return. I want only access to a dentry from inode number.

Thanks,
Uzair Lakhani

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

#1 lore raw
Quoted 8 lines · UZAIR LAKHANI

Hello All,

I want to know about these two questions.

(1) How to get a pointer to an inode if one has only the inode number available. May I use the iget() function. I only want a reference to the inode whose number I have.

It sounds like iget() is what you want.

Quoted 5 lines

(2) How to get the dentry from inode. Is d_find_alias ok. There can be multiple dentries attached to a single inode then which dentry will d_find_alias will return. I want only access to a dentry from inode number.

I think d_alloc_anon() may do what you want.

inode = iget(sb, inum);
if (!inode)

	bail out;
if (is_bad_inode(inode)) {
	iput(inode);
	bail out;
}
dentry = d_alloc_anon(inode);
if (!dentry) {
	iput(inode)
	bail out;
}

d_alloc_anon returns an existing dentry for the inode if it can find one. Otherwise, it will allocate a new, anonymous dentry.

Quoted 2 lines

Thanks,
Uzair Lakhani

Hope this helps,
Shaggy

Signature · 2 lines
David Kleikamp
IBM Linux Technology Center