Why scandir(3) argument not const?

Aron Stansvik elvstone at gmail.com
Fri Dec 2 07:38:33 PST 2005


Hello. I read scandir(3).

Why:

scandir(const char *dirname, struct dirent ***namelist, int
(*select)(struct dirent *), int (*compar)(const void *, const void
*));

and not:

scandir(const char *dirname, struct dirent ***namelist, int
(*select)(const struct dirent *), int (*compar)(const void *, const
void *));

I.e. why is the dirent pointer in the third argument not a const
dirent pointer? I see that on Linux and NetBSD it is declared const,
but not so on FreeBSD and OpenBSD (don't know about other platforms).
Since this in not a POSIX function, but a BSD extension, it would be
nice if the prototypes for the function was compatible across
platforms. Is there any case where the filter function should need to
change the dirent structure? I think not.

Comments?

Best regards,
Aron Stansvik


More information about the freebsd-questions mailing list