summaryrefslogtreecommitdiffstats
path: root/booster/src
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@zresearch.com>2009-06-11 04:59:00 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-06-11 07:29:01 -0700
commit8ebb4499d0bf568ea58562708f8baaedfe9fa58a (patch)
tree4cfaca86935bdbe0d460ee326b6f90e407521d79 /booster/src
parent75f555fd89d2bf3dbd5aceeb112b748f4a8966e3 (diff)
booster: implement readdir_r and readdir64_r.
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
Diffstat (limited to 'booster/src')
-rw-r--r--booster/src/booster.c69
-rw-r--r--booster/src/booster_stat.c1
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);