linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Question] how to follow a symlink via a dentry?
@ 2006-05-23 16:56 Steven Rostedt
  2006-05-23 17:08 ` Stephen Hemminger
  0 siblings, 1 reply; 3+ messages in thread
From: Steven Rostedt @ 2006-05-23 16:56 UTC (permalink / raw)
  To: LKML

What is the best way from inside the kernel, to find the dentry that
another dentry points to via symlink?

Scenario:

I have a kobj of a device in the sysfs system.  Inside a directory of
the kobj, is a symlink to another device I need to get.  I can find the
dentry of the symlink, but I haven't found a good way to get to the
dentry of what the symlink points to.

Is there a standard way to do this, or do I need to start hacking at the
follow_link of the sysfs directory to get what I want?

Do I need to hack up something like page_readlink to get the path, and
then do vfs_follow_link to get the rest.  Another thing is that I can't
rely on what current->fs points to.

Thanks,

-- Steve



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

* Re: [Question] how to follow a symlink via a dentry?
  2006-05-23 16:56 [Question] how to follow a symlink via a dentry? Steven Rostedt
@ 2006-05-23 17:08 ` Stephen Hemminger
  2006-05-23 20:56   ` Steven Rostedt
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2006-05-23 17:08 UTC (permalink / raw)
  To: linux-kernel

On Tue, 23 May 2006 12:56:03 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> What is the best way from inside the kernel, to find the dentry that
> another dentry points to via symlink?
> 
> Scenario:
> 
> I have a kobj of a device in the sysfs system.  Inside a directory of
> the kobj, is a symlink to another device I need to get.  I can find the
> dentry of the symlink, but I haven't found a good way to get to the
> dentry of what the symlink points to.
> 
> Is there a standard way to do this, or do I need to start hacking at the
> follow_link of the sysfs directory to get what I want?
> 
> Do I need to hack up something like page_readlink to get the path, and
> then do vfs_follow_link to get the rest.  Another thing is that I can't
> rely on what current->fs points to.
> 
> Thanks,
> 
> -- Steve
>

Sysfs reflects kernel object linkage, you should not be using
file access to find kernel objects.  You should use the pointers
instead.

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

* Re: [Question] how to follow a symlink via a dentry?
  2006-05-23 17:08 ` Stephen Hemminger
@ 2006-05-23 20:56   ` Steven Rostedt
  0 siblings, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2006-05-23 20:56 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: linux-kernel

On Tue, 2006-05-23 at 10:08 -0700, Stephen Hemminger wrote:
> On Tue, 23 May 2006 12:56:03 -0400
> Steven Rostedt <rostedt@goodmis.org> wrote:
> 
> > What is the best way from inside the kernel, to find the dentry that
> > another dentry points to via symlink?
> > 
> > Scenario:
> > 
> > I have a kobj of a device in the sysfs system.  Inside a directory of
> > the kobj, is a symlink to another device I need to get.  I can find the
> > dentry of the symlink, but I haven't found a good way to get to the
> > dentry of what the symlink points to.
> > 
> > Is there a standard way to do this, or do I need to start hacking at the
> > follow_link of the sysfs directory to get what I want?
> > 
> > Do I need to hack up something like page_readlink to get the path, and
> > then do vfs_follow_link to get the rest.  Another thing is that I can't
> > rely on what current->fs points to.
> > 
> > Thanks,
> > 
> > -- Steve
> >
> 
> Sysfs reflects kernel object linkage, you should not be using
> file access to find kernel objects.  You should use the pointers
> instead.

What pointers are you talking about?  Let me ask a better question. If
I have a pointer to an ide_drive_t or ide_driver_t or just the struct
device, how do I get to the block_device (bdev) that points to it?

So I have the /sys/block/hda/device object (which really is a symlink to
the /sys/devices/...) but I want to get to the object that
represents /sys/block/hda/device/block:hda which is also a symlink back
to /sys/block/hda. Right now the only way I know to do that is to follow
the sysfs.

-- Steve



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

end of thread, other threads:[~2006-05-23 20:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-23 16:56 [Question] how to follow a symlink via a dentry? Steven Rostedt
2006-05-23 17:08 ` Stephen Hemminger
2006-05-23 20:56   ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).