Prev: NULL pointer dereference with 2.6.31 on OMAP243
Next: [PATCH] r8192U_core: test for negative error in rtl8192_rx_isr()?
From: Helight.Xu on 20 Nov 2009 01:40 在用户程序中打开文件进行编辑,那在内核中如何能通过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(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Xiaotian Feng on 20 Nov 2009 03:20 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(a)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(a)vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Helight.Xu on 20 Nov 2009 05:00 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(a)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(a)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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Américo Wang on 22 Nov 2009 11:40 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. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Helight.Xu on 22 Nov 2009 20:10
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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ |