Dears,
Here is a problem when I try to list all the files under a diretory. The directory is a cifs client directory.
readdir always failed and errno is 12.
/var/log/messages shows: CIFS VFS: Filldir for current dir failed.
BTW, I compiled the code on redhat 6 i686 OS and run it on redhat 6 x86_64 OS.
Code is below:
+++
#include <sys/types.h>
#include <errno.h>
#include <dirent.h>
#include <stdio.h>
#include <unistd.h>
int main(int argc, char **argv)
{
printf("Try to list the directory: %s\n", argv[1]);
DIR * dir = NULL;
char * path = argv[1];
dir = opendir(path);
errno = 0;
if(NULL == dir)
{
printf("Failed to open the dir with errno: %d\n", errno);
return -1;
}
struct dirent * dir_entry = NULL;
while(dir_entry = readdir(dir))
{
printf("file: %s\n", dir_entry->d_name);
}
printf("error :%d\n", errno);
return 0;
}
#include <errno.h>
#include <dirent.h>
#include <stdio.h>
#include <unistd.h>
int main(int argc, char **argv)
{
printf("Try to list the directory: %s\n", argv[1]);
DIR * dir = NULL;
char * path = argv[1];
dir = opendir(path);
errno = 0;
if(NULL == dir)
{
printf("Failed to open the dir with errno: %d\n", errno);
return -1;
}
struct dirent * dir_entry = NULL;
while(dir_entry = readdir(dir))
{
printf("file: %s\n", dir_entry->d_name);
}
printf("error :%d\n", errno);
return 0;
}
+++
Is there any way that I can do this except that build the code on x86_64 OS.
Thanks,
Eric
_______________________________________________ Redhat-devel-list mailing list Redhat-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/redhat-devel-list