文件描述中的文件名 [英] File name from file description

查看:72
本文介绍了文件描述中的文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我是这个小组的新手。我只有一个小问题


是否可以从文件描述符中取回文件名。


ie


我编写了一个函数来使用LD_PRELOAD重载libc写入


my_write(int fd,void * buf,size_t nbytes)


在此功能中,可以从fd中找到文件名。


谢谢

amit

解决方案

2006年3月28日11:45:02 -0800,在comp.lang.c中,poddar

< po*******@gmail.com>写道:



我是这个小组的新手。我只有一个小问题

是否可以从文件描述符中取回文件名。




C没有文件描述。你需要一个unix编程组,如果

你正在使用write()及其朋友。


Mark McIntyre

- -

调试是第一次编写代码的两倍。

因此,如果你尽可能巧妙地编写代码,那么,你是/>
的定义,不够聪明,无法调试它。

--Brian Kernighan


所以在这种情况下是它可以从文件指针(即FILE * fp)获得
文件名


amit


"波达" < PO ******* @ gmail.com>写道:

我是这个小组的新手。我只有一个小问题

是否有可能从文件描述符中取回文件名。




我假设,按文件描述符,你的意思是一个文件。

不,C没有办法只给一个FILE文件名。

-

"。我犯了什么蠢事,我奉献给你。

- 威廉·莎士比亚,_Troilus和Cressida_


Hi,

I am new to this group. I had just one small question

Is it possible to get the file name back from file descriptor.

i.e.

I have written a function to overload the libc write using LD_PRELOAD

my_write(int fd, void *buf, size_t nbytes)

In this function is it possible to find the filename from "fd".

thanks
amit

解决方案

On 28 Mar 2006 11:45:02 -0800, in comp.lang.c , "poddar"
<po*******@gmail.com> wrote:

Hi,

I am new to this group. I had just one small question

Is it possible to get the file name back from file descriptor.



C doesn''t have file descriptors. You want a unix programming group if
you''re using write() and its friends.

Mark McIntyre
--
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan


So in that case is it possible to get

file name from file pointer (i.e. FILE *fp)

amit


"poddar" <po*******@gmail.com> writes:

I am new to this group. I had just one small question

Is it possible to get the file name back from file descriptor.



I assume, by file descriptor, you mean a FILE.
No, C provides no way to get a file name given only a FILE.
--
"...what folly I commit, I dedicate to you."
--William Shakespeare, _Troilus and Cressida_


这篇关于文件描述中的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆