Problems of readdir for cifs client

errik <[email protected]> Wed, 4 May 2011 11:27:38 +0800
Newsgroups gmane.linux.redhat.devel
Message-ID <[email protected]>
--===============0658789368318754510==
Content-Type: multipart/alternative; boundary=bcaec5215d49ad5fc304a26ad6e0

--bcaec5215d49ad5fc304a26ad6e0
Content-Type: text/plain; charset=ISO-8859-1

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;
}

+++


Is there any way that I can do this except that build the code on x86_64 OS.

Thanks,
Eric

--bcaec5215d49ad5fc304a26ad6e0
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div>Dears,</div><div>=A0=A0=A0=A0 Here is a problem when I try to list all=
 the files under a diretory. The directory is a cifs client directory.</div=
><div>=A0</div><div>readdir always failed and errno is 12.</div><div>/var/l=
og/messages shows: CIFS VFS: Filldir for current dir failed.</div>
<div>=A0</div><div>BTW, I compiled the code on redhat 6 i686 OS and run it =
on redhat 6 x86_64 OS.</div><div>=A0</div><div>=A0</div><div>Code is below:=
</div><div>+++</div><div>#include &lt;sys/types.h&gt;<br>#include &lt;errno=
.h&gt;<br>
#include &lt;dirent.h&gt;<br>#include &lt;stdio.h&gt;<br>#include &lt;unist=
d.h&gt;<br>int main(int argc, char **argv)<br>{<br>=A0printf(&quot;Try to l=
ist the directory: %s\n&quot;, argv[1]);<br>=A0DIR * dir =3D NULL;<br>=A0=
=A0=A0=A0=A0=A0=A0 char * path =3D argv[1];<br>
=A0=A0=A0=A0=A0=A0=A0 dir =3D opendir(path);<br>=A0=A0=A0=A0=A0=A0=A0 errno=
 =3D 0;<br>=A0 =A0if(NULL =3D=3D dir)<br>=A0{<br>=A0=A0printf(&quot;Failed =
to open the dir with errno: %d\n&quot;, errno);<br>=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0 return -1;<br>=A0}<br>=A0=A0=A0=A0=A0=A0=A0 struct di=
rent * dir_entry =3D NULL;<br>
=A0=A0=A0=A0=A0=A0=A0 while(dir_entry =3D readdir(dir))<br>=A0 =A0{<br>=A0=
=A0printf(&quot;file: %s\n&quot;, dir_entry-&gt;d_name);<br>=A0}<br>=A0=A0=
=A0=A0=A0=A0=A0 printf(&quot;error :%d\n&quot;, errno);<br>=A0=A0=A0=A0=A0=
=A0=A0 return 0;<br>}</div><div>=A0</div><div>+++</div>
<div>=A0</div><div>=A0</div><div>Is there any way that I can do this except=
 that build the code on x86_64 OS.</div><div>=A0</div><div>Thanks,</div><di=
v>Eric</div><div>=A0</div>

--bcaec5215d49ad5fc304a26ad6e0--

--===============0658789368318754510==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Redhat-devel-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/redhat-devel-list
--===============0658789368318754510==--