summaryrefslogtreecommitdiffstats
path: root/booster
diff options
context:
space:
mode:
authorShehjar Tikoo <shehjart@zresearch.com>2009-05-05 16:03:24 +0530
committerAnand V. Avati <avati@amp.gluster.com>2009-05-05 17:50:34 +0530
commit792cd732264d751895e8469e7c5f3cb172574180 (patch)
tree98aab321d1780a33d6845e0d8767fef2b3b93eb1 /booster
parentfc602c0c17064dfbd81d3d85141b55a40c45d8d9 (diff)
booster: Add opendir API
Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'booster')
-rw-r--r--booster/src/booster.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/booster/src/booster.c b/booster/src/booster.c
index 45310ae55..03480cb3b 100644
--- a/booster/src/booster.c
+++ b/booster/src/booster.c
@@ -40,6 +40,7 @@
#include <ctype.h>
#include <logging.h>
#include <utime.h>
+#include <dirent.h>
#ifndef GF_UNIT_KB
#define GF_UNIT_KB 1024
@@ -167,6 +168,7 @@ static int (*real_unlink) (const char *path);
static int (*real_symlink) (const char *oldpath, const char *newpath);
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);
#define RESOLVE(sym) do { \
if (!real_##sym) \
@@ -1484,6 +1486,54 @@ realpath (const char *path, char *resolved_path)
return res;
}
+#define BOOSTER_GL_DIR 1
+#define BOOSTER_POSIX_DIR 2
+
+struct booster_dir_handle {
+ int type;
+ void *dirh;
+};
+
+DIR *
+opendir (const char *path)
+{
+ glusterfs_dir_t gdir = NULL;
+ struct booster_dir_handle *bh = NULL;
+ DIR *pdir = NULL;
+
+ bh = calloc (1, sizeof (struct booster_dir_handle));
+ if (!bh) {
+ errno = ENOMEM;
+ goto out;
+ }
+
+ gdir = glusterfs_opendir (path);
+ if (gdir) {
+ bh->type = BOOSTER_GL_DIR;
+ bh->dirh = (void *)gdir;
+ goto out;
+ }
+
+ if (real_opendir == NULL) {
+ errno = ENOSYS;
+ goto free_out;
+ }
+
+ pdir = real_opendir (path);
+
+ if (pdir) {
+ bh->type = BOOSTER_POSIX_DIR;
+ bh->dirh = (void *)pdir;
+ goto out;
+ }
+
+free_out:
+ free (bh);
+ bh = NULL;
+out:
+ return (DIR *)bh;
+}
+
pid_t
fork (void)
{
@@ -1551,6 +1601,7 @@ _init (void)
RESOLVE (symlink);
RESOLVE (readlink);
RESOLVE (realpath);
+ RESOLVE (opendir);
/* This must be called after resolving real functions
* above so that the socket based IO calls in libglusterfsclient