"Richard L. Hamilton" <[EMAIL PROTECTED]> wrote:

> > 
> > A function like dirfd() is probably needed for
> > completeness and
> > compatibility, though I wonder what people are using
> > it for....
>
> Supposedly to do an opendir() then convert the result to
> something they could use with fchdir(), although it seems
> to me that if one was always going to do both, one could
> open() the directory and then do fdopendir() just as well.

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));

Note: error handling omitted for readability.

If Linux is missing fdopendir(), you should better ask the Linux people
to add fdopendir(), as openat() is already accepted for the next POSIX
standard AFAIK.

Jörg

-- 
 EMail:[EMAIL PROTECTED] (home) Jörg Schilling D-13353 Berlin
       [EMAIL PROTECTED]                (uni)  
       [EMAIL PROTECTED]     (work) Blog: http://schily.blogspot.com/
 URL:  http://cdrecord.berlios.de/old/private/ ftp://ftp.berlios.de/pub/schily
_______________________________________________
opensolaris-discuss mailing list
[email protected]

Reply via email to