GNU bug report logs -
#8620
Strange problem for ls
Previous Next
Reported by: errik <waitingfor2009marry <at> gmail.com>
Date: Thu, 5 May 2011 06:02:02 UTC
Severity: normal
Tags: notabug
Done: Jim Meyering <jim <at> meyering.net>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Dears,
Actually this is not a bug report, so sorry to do this because I
don't know the mail address of Richard M. Stallman, and David
MacKenzie.
These days, there is a problem that trouble me so much. I write a
simple code to get all the files under a directory and compile the
code on RedHat 6 i686 machine. The code is as 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;
}
After compiled the code on RedHat 6 32 bits machine and then copy the
binary to RedHat 6 64 bits machine, it can work correctly when the
parameter for the program is a local directory.
But "readdir" always failed if the parameter is a cifs client
directory, the errno is 12.
Then I downloaded the souce code of "ls" from GNU site and compiled
it on RedHat 6 32 bits, the binary can also works with cifs client
directory.
From the code of ls, it also use opendir and readdir to list the directory.
It's strange ls can work but my simple code can't work.
Is there anyone can tell me the difference or forward the mail to
Richard M. Stallman, and David MacKenzie?
Thanks,
Erik
This bug report was last modified 14 years and 9 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.