diff options
author | Raghavendra G <raghavendra@zresearch.com> | 2009-06-11 04:59:00 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2009-06-30 14:36:25 -0700 |
commit | f8cacccf10dc3f52c4d2e73d7408394eed8664e3 (patch) | |
tree | c42cc298d616490f54c4b5c1b37f294ca238c440 /booster | |
parent | 56ac05f7e74ed9dc1ce6748687109cc8723fe113 (diff) |
booster: implement readdir_r and readdir64_r.
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
Diffstat (limited to 'booster')
-rw-r--r-- | booster/src/booster.c | 69 | ||||
-rw-r--r-- | booster/src/booster_stat.c | 1 |
2 files changed, 70 insertions, 0 deletions
diff --git a/booster/src/booster.c b/booster/src/booster.c index 54f3411e368..27ff9278faf 100644 --- a/booster/src/booster.c +++ b/booster/src/booster.c @@ -176,6 +176,10 @@ 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 int (*real_readdir_r) (DIR *dir, struct dirent *entry, + struct dirent **result); +static int (*real_readdir64_r) (DIR *dir, struct dirent64 *entry, + struct dirent64 **result); static int (*real_closedir) (DIR *dh); static int (*real___xstat) (int ver, const char *path, struct stat *buf); static int (*real___xstat64) (int ver, const char *path, struct stat64 *buf); @@ -1394,6 +1398,69 @@ out: return (DIR *)bh; } +int +readdir_r (DIR *dir, struct dirent *entry, struct dirent **result) +{ + struct booster_dir_handle *bh = (struct booster_dir_handle *)dir; + int ret = 0; + + if (!bh) { + ret = errno = EFAULT; + goto out; + } + + if (bh->type == BOOSTER_GL_DIR) { + ret = glusterfs_readdir_r ((glusterfs_dir_t)bh->dirh, entry, + result); + + } else if (bh->type == BOOSTER_POSIX_DIR) { + if (real_readdir_r == NULL) { + ret = errno = ENOSYS; + goto out; + } + + ret = real_readdir_r ((DIR *)bh->dirh, entry, result); + } else { + ret = errno = EINVAL; + } + +out: + return ret; +} + + +#if !defined (__USE_LARGEFILE64) && !defined (__USE_FILE_OFFSET64) +int +readdir64_r (DIR *dir, struct dirent64 *entry, struct dirent64 **result) +{ + struct booster_dir_handle *bh = (struct booster_dir_handle *)dir; + int ret = 0; + + if (!bh) { + ret = errno = EFAULT; + goto out; + } + + if (bh->type == BOOSTER_GL_DIR) { + ret = glusterfs_readdir_r ((glusterfs_dir_t)bh->dirh, + (struct dirent *)entry, + (struct dirent **)result); + } else if (bh->type == BOOSTER_POSIX_DIR) { + if (real_readdir64_r == NULL) { + ret = errno = ENOSYS; + goto out; + } + + ret = real_readdir64_r ((DIR *)bh->dirh, entry, result); + } else { + ret = errno = EINVAL; + } + +out: + return ret; +} +#endif + struct dirent * booster_readdir (DIR *dir) { @@ -2139,6 +2206,8 @@ _init (void) RESOLVE (telldir); RESOLVE (sendfile); RESOLVE (sendfile64); + RESOLVE (readdir_r); + RESOLVE (readdir64_r); /* This must be called after resolving real functions * above so that the socket based IO calls in libglusterfsclient diff --git a/booster/src/booster_stat.c b/booster/src/booster_stat.c index 10d2dc2e28b..97a4f28a431 100644 --- a/booster/src/booster_stat.c +++ b/booster/src/booster_stat.c @@ -57,6 +57,7 @@ booster_statfs64 (const char *path, void *buf); extern int booster_statvfs (const char *path, void *buf); + extern int booster_statvfs64 (const char *path, void *buf); |