[Gluster-devel] weird response of gluster_readdir
Shehjar Tikoo
shehjart at gluster.com
Fri Jul 31 12:33:49 UTC 2009
Dongmin Yu wrote:
> Hello,
>
>
>
> I’m using glusterfs-2.0.4 and building a c-program with libglusterfsclient.
>
>
>
> I’ve created a directory, ‘test’ and wrote a file, ‘hello.txt’, to the
> directory on glusterfs mounted volume.
>
> Then I wanted to list all the files/sub-directories in the directory.
>
>
>
> My code was as followings,
>
>
>
> ======
>
> struct dirent *dirp = NULL;
>
> glusterfs_dir_t dirfd = NULL;
>
> char *path = “/gfs_mount/test/”;
>
>
>
> dirfd = glusterfs_opendir(path);
>
Before you can use libglusterfsclient API, you need to set up
a few things using the glusterfs_mount call. If that wasnt done,
glusterfs_opendir should have returned a NULL, thats the first
bug here I think. Can you confirm if you called glusterfs_mount
in the full program?
Have you looked at booster? It is a library that you LD_PRELOAD
under your regular applications so that file system access
happens over libglusterfsclient, without the need to adapt
apps to libglusterfsclient.
For more info, see
http://www.gluster.org/docs/index.php/BoosterConfiguration
-Shehjar
> while( (dirp = glusterfs_readdir(dirfd) != NULL) ){
>
> printf("## %s %d %d\n", dirp->d_name, dirp->d_type, dirp->d_reclen );
>
> for( i = 0 ; i < 256; i++ ){
>
> printf("%d ", dirp->d_name[i]);
>
> }
>
> printf("\n");}
>
> glusterfs_closedir(dirfd);
>
> =====
>
>
>
> What I expected result was,
>
> ## Hello.txt 8 24
>
> ## . 4 16
>
> ## .. 4 16
>
>
>
> But
>
> ## 0 74
>
> 0 0 0 0 0 0 0 0 46 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0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0 0
> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0 0 0 0 0 0 0 0 0
>
>
>
> As you see, first 8 bytes has garbage data and d_type value is not correct.
>
>
>
> Is it a bug of readdir or am I mis-using the library?
>
>
>
> Thanks
>
>
>
> *DongMin Yu*
>
>
>
> HOSTWAY IDC Corp. / R&D Principal Researcher
>
> TEL. +822 2105 6037
>
> FAX. +822 2105 6019
>
> CELL. +8216 2086 1357
>
> EMAIL: min.yu at hostwaycorp.com <mailto:min.yu at hostwaycorp.com>
>
> Website: http://www.hostway.com
>
>
>
> *NOTICE: This email and any file transmitted are confidential and/or
> legally privileged and intended only for the person(s) directly
> addressed. If you are not the intended recipient, any use, copying,
> transmission, distribution, or other forms of dissemination is strictly
> prohibited. If you have received this email in error, please notify the
> sender immediately and permanently delete the email and files, if any.*
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Gluster-devel mailing list
> Gluster-devel at nongnu.org
> http://lists.nongnu.org/mailman/listinfo/gluster-devel
More information about the Gluster-devel
mailing list