All of lore.kernel.org
 help / color / mirror / Atom feed
* How to get dentry from inode number?
@ 2005-07-29 15:02 墳墓
  2005-07-29 15:11 ` Jörn Engel
  0 siblings, 1 reply; 3+ messages in thread
From: 墳墓 @ 2005-07-29 15:02 UTC (permalink / raw)
  To: linux-kernel

Hello, every body.

How can I get a full pathname from an inode number ? (Our data
structure only keep track inode number instead of pathname in
order to keep thin, so don't have any information but inode
number.)

I used iget_locked() to get a struct inode * from an inode number,
and use d_find_alias() to get a dentry, finally use d_path() to get
a absoulte path to the file.

But it only works when I opened the target file before I run
my program, or the d_find_alias() will return NULL.

I also tried d_alloc_anno() and d_splice_alias(), but it crashed
in the d_splice_alias().

So, which function should I check to find the answer?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to get dentry from inode number?
  2005-07-29 15:02 How to get dentry from inode number? 墳墓
@ 2005-07-29 15:11 ` Jörn Engel
  0 siblings, 0 replies; 3+ messages in thread
From: Jörn Engel @ 2005-07-29 15:11 UTC (permalink / raw)
  To: ?X??; +Cc: linux-kernel

On Fri, 29 July 2005 23:02:53 +0800, ?X?? wrote:
> 
> How can I get a full pathname from an inode number ?

That's fundamentally impossible to do.  Any given inode may have
multiple paths associated to it.  Think of hard links.

Jörn

-- 
"[One] doesn't need to know [...] how to cause a headache in order
to take an aspirin."
-- Scott Culp, Manager of the Microsoft Security Response Center, 2001

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to get dentry from inode number?
@ 2005-07-29 15:28 linux
  0 siblings, 0 replies; 3+ messages in thread
From: linux @ 2005-07-29 15:28 UTC (permalink / raw)
  To: brianhsu.hsu, linux-kernel

> How can I get a full pathname from an inode number ? (Our data
> structure only keep track inode number instead of pathname in
> order to keep thin, so don't have any information but inode
> number.)

Except in extreme circumstances (there's some horrible kludgery in the
NFS code), you don't.  Just store a dentry pointer to begin with; it's
easy to map from dentry to inode.

In addition to files with multiple names, you can have files with no
names, made by the usual Unix trick of deleting a file after opening it.


The NFS kludgery is required by the short-sighted design of the NFS
protocol.  Don't emulate it, or you will be lynched by a mob of angry
kernel developers with torches and pitchforks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-07-29 15:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-29 15:02 How to get dentry from inode number? 墳墓
2005-07-29 15:11 ` Jörn Engel
  -- strict thread matches above, loose matches on Subject: below --
2005-07-29 15:28 linux

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.