All of lore.kernel.org
 help / color / mirror / Atom feed
* 如何通过fd找到打开文件的路径及名称
@ 2009-11-20  6:33 Helight.Xu
  2009-11-20  8:12 ` 如何通过fd找到打开文件的路径及名称 Xiaotian Feng
  2009-11-22 16:37 ` 如何通过fd找到打开文件的路径及名称 Américo Wang
  0 siblings, 2 replies; 10+ messages in thread
From: Helight.Xu @ 2009-11-20  6:33 UTC (permalink / raw)
  To: linux-kernel

在用户程序中打开文件进行编辑,那在内核中如何能通过open后的fd
来找到相应打开文件的路径及其名字呢?

-- 
---------------------------------
Zhenwen Xu - Open and Free
Home Page:	http://zhwen.org


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

* Re: 如何通过fd找到打开文件的路径及名称
  2009-11-20  6:33 如何通过fd找到打开文件的路径及名称 Helight.Xu
@ 2009-11-20  8:12 ` Xiaotian Feng
  2009-11-20  9:55   ` 如何通过fd找到打开文件的路径及名称 Helight.Xu
  2009-11-22 16:37 ` 如何通过fd找到打开文件的路径及名称 Américo Wang
  1 sibling, 1 reply; 10+ messages in thread
From: Xiaotian Feng @ 2009-11-20  8:12 UTC (permalink / raw)
  To: Helight.Xu; +Cc: linux-kernel

in fs/open.c
   sys_open
             | --> do_sys_open
                          |--->  fd_install

Then fd is installed into file_fdtable

in fs/file_table.c
     fget_light/fget
            |----> fcheck_files

Then kernel get files from fd.

2009/11/20 Helight.Xu <helight.xu@gmail.com>:
> 在用户程序中打开文件进行编辑,那在内核中如何能通过open后的fd
> 来找到相应打开文件的路径及其名字呢?
>
> --
> ---------------------------------
> Zhenwen Xu - Open and Free
> Home Page:      http://zhwen.org
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>

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

* Re: 如何通过fd找到打开文件的路径及名称
  2009-11-20  8:12 ` 如何通过fd找到打开文件的路径及名称 Xiaotian Feng
@ 2009-11-20  9:55   ` Helight.Xu
  0 siblings, 0 replies; 10+ messages in thread
From: Helight.Xu @ 2009-11-20  9:55 UTC (permalink / raw)
  To: Xiaotian Feng; +Cc: linux-kernel

Xiaotian Feng wrote:
> in fs/open.c
>    sys_open
>              | --> do_sys_open
>                           |--->  fd_install
>
> Then fd is installed into file_fdtable
>
> in fs/file_table.c
>      fget_light/fget
>             |----> fcheck_files
>
> Then kernel get files from fd.
>   
struct file is easy to get : current->files->fd_array[fd]

but I didn't find the file name!
> 2009/11/20 Helight.Xu <helight.xu@gmail.com>:
>   
>> 在用户程序中打开文件进行编辑,那在内核中如何能通过open后的fd
>> 来找到相应打开文件的路径及其名字呢?
>>
>> --
>> ---------------------------------
>> Zhenwen Xu - Open and Free
>> Home Page:      http://zhwen.org
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at  http://www.tux.org/lkml/
>>
>>     
>
>   


-- 
---------------------------------
Zhenwen Xu - Open and Free
Home Page:	http://zhwen.org


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

* Re: 如何通过fd找到打开文件的路径及名称
  2009-11-20  6:33 如何通过fd找到打开文件的路径及名称 Helight.Xu
  2009-11-20  8:12 ` 如何通过fd找到打开文件的路径及名称 Xiaotian Feng
@ 2009-11-22 16:37 ` Américo Wang
  2009-11-23  1:02   ` 如何通过fd找到打开文件的路径及名称 Helight.Xu
  1 sibling, 1 reply; 10+ messages in thread
From: Américo Wang @ 2009-11-22 16:37 UTC (permalink / raw)
  To: Helight.Xu; +Cc: linux-kernel

On Fri, Nov 20, 2009 at 02:33:48PM +0800, Helight.Xu wrote:
> 在用户程序中打开文件进行编辑,那在内核中如何能通过open后的fd
> 来找到相应打开文件的路径及其名字呢?
>

问题是你为什么要在内核中做呢?在用户空间完全可以完成:

 % readlink /proc/<PID>/fd/X


-- 
Live like a child, think like the god.
 

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

* Re: 如何通过fd找到打开文件的路径及名称
  2009-11-22 16:37 ` 如何通过fd找到打开文件的路径及名称 Américo Wang
@ 2009-11-23  1:02   ` Helight.Xu
  2009-11-23 14:41     ` 如何通过fd找到打开文件的路径及名称 Américo Wang
  2009-11-24 12:03     ` non-english on list (was Re: ????????????fd????????????????????????????????????) Pavel Machek
  0 siblings, 2 replies; 10+ messages in thread
From: Helight.Xu @ 2009-11-23  1:02 UTC (permalink / raw)
  To: Américo Wang; +Cc: linux-kernel

Américo Wang wrote:
> On Fri, Nov 20, 2009 at 02:33:48PM +0800, Helight.Xu wrote:
>   
>> 在用户程序中打开文件进行编辑,那在内核中如何能通过open后的fd
>> 来找到相应打开文件的路径及其名字呢?
>>
>>     
>
> 问题是你为什么要在内核中做呢?在用户空间完全可以完成:
>
>  % readlink /proc/<PID>/fd/X
>   
我是想在内核中实现一些功能,所以现在内核中找到文件的路径及其名称,现在只 
能找到文件名,还在找路径。。。
>
>   


-- 
---------------------------------
Zhenwen Xu - Open and Free
Home Page:	http://zhwen.org


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

* Re: 如何通过fd找到打开文件的路径及名称
  2009-11-23  1:02   ` 如何通过fd找到打开文件的路径及名称 Helight.Xu
@ 2009-11-23 14:41     ` Américo Wang
       [not found]       ` <alpine.LRH.2.00.0911231605340.3659@twin.jikos.cz>
  2009-11-24 12:03     ` non-english on list (was Re: ????????????fd????????????????????????????????????) Pavel Machek
  1 sibling, 1 reply; 10+ messages in thread
From: Américo Wang @ 2009-11-23 14:41 UTC (permalink / raw)
  To: Helight.Xu; +Cc: Américo Wang, linux-kernel

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.
 

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

* Re: 如何通过fd找到打开文件的路径及名称
       [not found]       ` <alpine.LRH.2.00.0911231605340.3659@twin.jikos.cz>
@ 2009-11-23 15:31         ` Américo Wang
  0 siblings, 0 replies; 10+ messages in thread
From: Américo Wang @ 2009-11-23 15:31 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: Américo Wang, Helight.Xu, linux-kernel

On Mon, Nov 23, 2009 at 04:05:55PM +0100, Jiri Kosina wrote:

<snip>

>Come on guys, you keep CCing LKML with this :)
>

Wow, I missed the "lkml" label on this email in my inbox... :-/

I thought it was from linux-kernel@zh-kernel.org since $subject
is in Chinese.

I guess Helight wanted to send to zh-kernel.org, right?

-- 
Live like a child, think like the god.
 

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

* non-english on list (was Re: ????????????fd????????????????????????????????????)
  2009-11-23  1:02   ` 如何通过fd找到打开文件的路径及名称 Helight.Xu
  2009-11-23 14:41     ` 如何通过fd找到打开文件的路径及名称 Américo Wang
@ 2009-11-24 12:03     ` Pavel Machek
  2009-11-24 14:10       ` David Newall
  1 sibling, 1 reply; 10+ messages in thread
From: Pavel Machek @ 2009-11-24 12:03 UTC (permalink / raw)
  To: Helight.Xu; +Cc: Am??rico Wang, linux-kernel

On Mon 2009-11-23 09:02:33, 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
>>   
 
> ???????????????????????????????????????????????????????????????????????????????????????????????????????????? 
> ?????????????????????????????????????????????
>>
>>   

Could we keep the list english-only?

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

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

* Re: non-english on list (was Re: ????????????fd????????????????????????????????????)
  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
  0 siblings, 1 reply; 10+ messages in thread
From: David Newall @ 2009-11-24 14:10 UTC (permalink / raw)
  To: Pavel Machek; +Cc: Helight.Xu, Am??rico Wang, linux-kernel

Pavel Machek wrote:
> Could we keep the list english-only?

I thought that was the rule, but then concluded that there was probably 
good reason for using Chinese--perhaps insufficient skill in 
English--and why shouldn't people be allowed to post in a language they 
understand? Certainly less people can answer in other languages, but as 
we've seen, it's more than zero, and I gather a satisfactory result was 
achieved. If you don't understand the language just skip the thread and 
move on.

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

* Re: non-english on list
  2009-11-24 14:10       ` David Newall
@ 2009-11-24 14:58         ` Américo Wang
  0 siblings, 0 replies; 10+ messages in thread
From: Américo Wang @ 2009-11-24 14:58 UTC (permalink / raw)
  To: David Newall; +Cc: Pavel Machek, Helight.Xu, Am??rico Wang, linux-kernel

On Wed, Nov 25, 2009 at 12:40:05AM +1030, David Newall wrote:
> Pavel Machek wrote:
>> Could we keep the list english-only?
>
> I thought that was the rule, but then concluded that there was probably  
> good reason for using Chinese--perhaps insufficient skill in  
> English--and why shouldn't people be allowed to post in a language they  
> understand? Certainly less people can answer in other languages, but as  
> we've seen, it's more than zero, and I gather a satisfactory result was  
> achieved. If you don't understand the language just skip the thread and  
> move on.

Hi, sorry about this.

It was proved to be a mistake, I checked this with Helight, he wanted
to send to a Chinese lkml.

Don't worry, none of us has problems to write English emails. ;)

Thanks for your care.


-- 
Live like a child, think like the god.
 

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

end of thread, other threads:[~2009-11-24 14:58 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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     ` 如何通过fd找到打开文件的路径及名称 Américo Wang
     [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

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.