[LCP]directory test
Jack Lloyd
lloyd at acm.jhu.edu
Fri Aug 9 04:21:05 UTC 2002
DIR is often opaque (certainly is with glibc 2.2). Thus the error.
I see on Solaris 2.6 DIR can have an entity dd_fd. But if _POSIX_C_SOURCE
or _XOPEN_SOURCE is defined, it's called d_fd instead! Yikes. Using (d)d_fd
seems like a good thing to avoid.
I think what you really want to do is call lstat with the name of the
directory.
-Jack
On Tue, 9 Jul 2002, Joachim Bauernberger wrote:
> Hi,
>
> I have some questions regarding opendir.
> After calling it I would like to check if the directory is a symbolic
> name or not. However compiling this gives me the following error:
>
> dereferencing pointer to incomplete type
>
>
> int
> islink(int fd)
> {
> struct stat st;
> if ((fstat(fd,&st))<0) return -1;
> if (S_ISLNK(st.st_mode)) return 1;
> else return 0;
> }
>
>
> void
> otherfunc(void)
> {
> DIR *d;
> ....
> d = opendir (abs_outdir);
> ...
> if (islink(d->dd_fd)!=0) return 1;
> ....
> }
>
> Somebody know how to check for something like this?
>
> Thanks & Best regards,
> Joachim Bauernberger
>
More information about the linuxCprogramming
mailing list