booster: seperate out the implementations of readdir and readdir64.
- readdir and readdir64 should not call same procedure booster_readdir in their implementation, since the layout of dirent structures returned by libc implementations of readdir and readdir64 is different (readdir returns struct dirent *, where as readdir64 returns struct dirent64 *). Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 333 (ls on paths not on virtual mounts report wrong directory contents) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=333
This commit is contained in:
parent
7445700d03
commit
106a651826
@ -151,6 +151,7 @@ static int (*real_readlink) (const char *path, char *buf, size_t bufsize);
|
||||
static char * (*real_realpath) (const char *path, char *resolved);
|
||||
static DIR * (*real_opendir) (const char *path);
|
||||
static struct dirent * (*real_readdir) (DIR *dir);
|
||||
static struct dirent64 * (*real_readdir64) (DIR *dir);
|
||||
static int (*real_readdir_r) (DIR *dir, struct dirent *entry,
|
||||
struct dirent **result);
|
||||
static int (*real_readdir64_r) (DIR *dir, struct dirent64 *entry,
|
||||
@ -1686,7 +1687,13 @@ out:
|
||||
}
|
||||
|
||||
struct dirent *
|
||||
booster_readdir (DIR *dir)
|
||||
__REDIRECT (booster_false_readdir, (DIR *dir), readdir) __nonnull ((1));
|
||||
|
||||
struct dirent64 *
|
||||
__REDIRECT (booster_false_readdir64, (DIR *dir), readdir64) __nonnull ((1));
|
||||
|
||||
struct dirent *
|
||||
booster_false_readdir (DIR *dir)
|
||||
{
|
||||
struct booster_dir_handle *bh = (struct booster_dir_handle *)dir;
|
||||
struct dirent *dirp = NULL;
|
||||
@ -1717,6 +1724,38 @@ out:
|
||||
return dirp;
|
||||
}
|
||||
|
||||
struct dirent64 *
|
||||
booster_false_readdir64 (DIR *dir)
|
||||
{
|
||||
struct booster_dir_handle *bh = (struct booster_dir_handle *)dir;
|
||||
struct dirent64 *dirp = NULL;
|
||||
|
||||
if (!bh) {
|
||||
errno = EFAULT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (bh->type == BOOSTER_GL_DIR) {
|
||||
gf_log ("booster", GF_LOG_TRACE, "readdir on gluster");
|
||||
dirp = glusterfs_readdir ((glusterfs_dir_t)bh->dirh);
|
||||
} else if (bh->type == BOOSTER_POSIX_DIR) {
|
||||
gf_log ("booster", GF_LOG_TRACE, "readdir on posix");
|
||||
if (real_readdir == NULL) {
|
||||
errno = ENOSYS;
|
||||
dirp = NULL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
dirp = real_readdir64 ((DIR *)bh->dirh);
|
||||
} else {
|
||||
dirp = NULL;
|
||||
errno = EINVAL;
|
||||
}
|
||||
|
||||
out:
|
||||
return dirp;
|
||||
}
|
||||
|
||||
int
|
||||
closedir (DIR *dh)
|
||||
{
|
||||
@ -2696,6 +2735,7 @@ booster_lib_init (void)
|
||||
RESOLVE (realpath);
|
||||
RESOLVE (opendir);
|
||||
RESOLVE (readdir);
|
||||
RESOLVE (readdir64);
|
||||
RESOLVE (closedir);
|
||||
RESOLVE (__xstat);
|
||||
RESOLVE (__xstat64);
|
||||
|
@ -169,18 +169,6 @@ statvfs64 (const char *pathname, void *buf)
|
||||
return booster_statvfs64 (pathname, buf);
|
||||
}
|
||||
|
||||
void *
|
||||
readdir (void *dir)
|
||||
{
|
||||
return booster_readdir (dir);
|
||||
}
|
||||
|
||||
void *
|
||||
readdir64 (void *dir)
|
||||
{
|
||||
return booster_readdir (dir);
|
||||
}
|
||||
|
||||
void
|
||||
rewinddir (void *dir)
|
||||
{
|
||||
|
@ -4141,7 +4141,7 @@ out:
|
||||
}
|
||||
|
||||
|
||||
struct dirent *
|
||||
void *
|
||||
glusterfs_readdir (glusterfs_dir_t dirfd)
|
||||
{
|
||||
int op_ret = -1;
|
||||
|
@ -633,7 +633,7 @@ glusterfs_rmdir (const char *path);
|
||||
* Returns the directory entry on success and NULL pointer on error
|
||||
* with errno set appropriately.
|
||||
*/
|
||||
struct dirent *
|
||||
void *
|
||||
glusterfs_readdir (glusterfs_dir_t dirfd);
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user