Bug#210861: libc6: readdir always returns dtype as unknown
On Sun, 2003-09-14 at 13:38, Philip Blundell wrote:
> On Sun, 2003-09-14 at 11:33, Jacob Kolding wrote:
> > when using the readdir function from <dirent.h> to get dirents the
> > dtype member of dirent is always returned as unknown.
>
> Please supply a test program to demonstrate the problem. We also need
> some more information: what filesystem are you using, and which kernel
> version?
>
> p.
>
I'm running ext2 on linux 2.2.20 but a friend of mine is running
reiserfs on 2.4.22 and have the same problem.
/Jacob Kolding
#include <sys/types.h>
#include <dirent.h>
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
int main(){
dirent *theEnts;
DIR *theDir;
theDir = opendir(".");
while((theEnts = readdir(theDir)) != NULL){
printf("name: %s, type: ", theEnts->d_name);
switch(theEnts->d_type){
case DT_UNKNOWN:
printf("UNKNOWN");
break;
case DT_FIFO:
printf("FIFO");
break;
case DT_CHR:
printf("CHR");
break;
case DT_DIR:
printf("DIR");
break;
case DT_BLK:
printf("BLK");
break;
case DT_REG:
printf("REG");
break;
case DT_LNK:
printf("LNK");
break;
case DT_SOCK:
printf("SOCK");
break;
case DT_WHT:
printf("WHT");
break;
}
printf("\n");
}
}
Reply to: