summaryrefslogtreecommitdiffstats
path: root/booster
diff options
context:
space:
mode:
authorShehjar Tikoo <shehjart@zresearch.com>2009-05-05 16:03:42 +0530
committerAnand V. Avati <avati@amp.gluster.com>2009-05-05 17:50:43 +0530
commitcec18ef672700dea563a8c899170ece4730257e5 (patch)
treedd696416739c1181c262348aa1be45e68deb5256 /booster
parentabeec15e1da0c40bee134253035af88739e09960 (diff)
booster: Add closedir API
Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'booster')
-rw-r--r--booster/src/booster.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/booster/src/booster.c b/booster/src/booster.c
index 7f3fc9beca2..ef866cb891c 100644
--- a/booster/src/booster.c
+++ b/booster/src/booster.c
@@ -170,6 +170,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 int (*real_closedir) (DIR *dh);
#define RESOLVE(sym) do { \
if (!real_##sym) \
@@ -1565,6 +1566,37 @@ out:
return dirp;
}
+int
+closedir (DIR *dh)
+{
+ struct booster_dir_handle *bh = (struct booster_dir_handle *)dh;
+ int ret = -1;
+
+ if (!bh) {
+ errno = EFAULT;
+ goto out;
+ }
+
+ if (bh->type == BOOSTER_GL_DIR)
+ ret = glusterfs_closedir ((glusterfs_dir_t)bh->dirh);
+ else if (bh->type == BOOSTER_POSIX_DIR) {
+ if (real_closedir == NULL) {
+ errno = ENOSYS;
+ ret = -1;
+ } else
+ ret = real_closedir ((DIR *)bh->dirh);
+ } else {
+ errno = EBADF;
+ }
+
+ if (ret == 0) {
+ free (bh);
+ bh = NULL;
+ }
+out:
+ return ret;
+}
+
pid_t
fork (void)
{
@@ -1634,6 +1666,7 @@ _init (void)
RESOLVE (realpath);
RESOLVE (opendir);
RESOLVE (readdir);
+ RESOLVE (closedir);
/* This must be called after resolving real functions
* above so that the socket based IO calls in libglusterfsclient