From: "Américo Wang" <xiyou.wangcong@gmail.com>
To: "Helight.Xu" <helight.xu@gmail.com>
Cc: "Américo Wang" <xiyou.wangcong@gmail.com>, linux-kernel@vger.kernel.org
Subject: Re: 如何通过fd找到打开文件的路径及名称
Date: Mon, 23 Nov 2009 22:41:52 +0800 [thread overview]
Message-ID: <20091123144152.GC2412@hack> (raw)
In-Reply-To: <4B09DF29.8020003@gmail.com>
On Mon, Nov 23, 2009 at 09:02:33AM +0800, Helight.Xu wrote:
> Américo Wang wrote:
>> On Fri, Nov 20, 2009 at 02:33:48PM +0800, Helight.Xu wrote:
>>
>>> 在用户程序中打开文件进行编辑,那在内核中如何能通过open后的fd
>>> 来找到相应打开文件的路径及其名字呢?
>>>
>>>
>>
>> 问题是你为什么要在内核中做呢?在用户空间完全可以完成:
>>
>> % readlink /proc/<PID>/fd/X
>>
> 我是想在内核中实现一些功能,所以现在内核中找到文件的路径及其名称,
能在用户层完成的就不要跑到内核里去做,完全没必要。
而且,你在处理这个问题时还要考虑pipe和socket这些特殊的文件,
它们对应的fd可是没有file的。
> 现在只
> 能找到文件名,还在找路径。。。
你可以看看proc文件中对fd/X的处理,或许能帮上忙。
--
Live like a child, think like the god.
next prev parent reply other threads:[~2009-11-23 14:41 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-20 6:33 如何通过fd找到打开文件的路径及名称 Helight.Xu
2009-11-20 8:12 ` 如何通过fd找到打开文件的路径及名称 Xiaotian Feng
2009-11-20 9:55 ` 如何通过fd找到打开文件的路径及名称 Helight.Xu
2009-11-22 16:37 ` 如何通过fd找到打开文件的路径及名称 Américo Wang
2009-11-23 1:02 ` 如何通过fd找到打开文件的路径及名称 Helight.Xu
2009-11-23 14:41 ` Américo Wang [this message]
[not found] ` <alpine.LRH.2.00.0911231605340.3659@twin.jikos.cz>
2009-11-23 15:31 ` 如何通过fd找到打开文件的路径及名称 Américo Wang
2009-11-24 12:03 ` non-english on list (was Re: ????????????fd????????????????????????????????????) Pavel Machek
2009-11-24 14:10 ` David Newall
2009-11-24 14:58 ` non-english on list Américo Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20091123144152.GC2412@hack \
--to=xiyou.wangcong@gmail.com \
--cc=helight.xu@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox