>[EMAIL PROTECTED] wrote:
>
>>
>> >Linux started to support openat() recently and for this reason,
>> >the best way of implementing a portable way of directory search without
>> >path length limitation is to use:
>> >
>> >ndfd = openat(dfd, "dname", O_RDONLY);
>> >close(dfd);
>> >dfd = ndfd;
>> >dp = fdopendir(dup(dfd));
>>
>> Interesting is, of course, that /proc/self/fd has made this obsolete
>> in an interesting sense.
>>
>> (openat maps to:
>>      sprintf(buf, "/proc/self/%d/%s", dfd, dname);
>
>Do you mean:
>
>       sprintf(buf, "/proc/self/fd/%d/%s", dfd, dname);
>       dp = opendir(buf);

Yes.

>> Not sure why you have all the dup's in there.
>
>Because closedir() will also close the fd passed to fdopendir()
>and I need the fd for a reliable chdir("..") later.

You can do the chdir before the closedir.

The current rm source keeps a stack of open directories but, since it
must allow for unlimited depth trees it verifies it can go back up before
closing the parent directory.  And it uses only one filedescriptor per
level (including the one used for opendir)

Casper
_______________________________________________
opensolaris-discuss mailing list
[email protected]

Reply via email to