[uClibc] readdir() doesn't set d_type to DT_DIR?

Kevin P. Fleming kpfleming at backtobasicsmgmt.com
Wed May 5 13:49:17 UTC 2004


I've got an application (the LVM2 userspace tools) that acts somewhat 
funny when built in a uClibc buildroot (using uClibc snapshot from a few 
days ago).

One of the processes in this tool scans the /sys hierarchy looking for 
particular files. On a glibc-based system this works just fine, but on a 
uClibc system it fails completely.

After much debugging, it appears that the recursive opendir/readdir loop 
in this tool is depending on the libc to set DT_DIR in the "struct 
dirent" returned by readdir(), but this is not happening on uClibc, so 
the application doesn't see any directories under /sys and stops 
scanning. According the Linux readdir(3) manpage using any field other 
than d_name is non-POSIX-conforming, so I presume this is why uClibc 
does not bother to fill this field in.

However, after looking over the code in uClibc and glibc, it appears 
that both of them just issue a getdents() syscall to the kernel and 
return the results. I'm at a loss to explain why the results are 
different between glibc and uClibc.



More information about the uClibc mailing list