summaryrefslogtreecommitdiffstats
path: root/booster
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2009-11-18 01:15:30 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-11-18 21:14:04 -0800
commitc7dba5ff1468f5e56d22b47cc97ff6cd4937f98f (patch)
tree39c29a1e5b5f2750581b4eae4019e5ffaec80ce0 /booster
parent119b179fdc83d49e8242a93439fb043990eb74c9 (diff)
booster: implement fchdir.
Signed-off-by: Raghavendra G <raghavendra@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 369 (Samba does not work with booster.) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=369
Diffstat (limited to 'booster')
-rw-r--r--booster/src/booster.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/booster/src/booster.c b/booster/src/booster.c
index 6264695ab4e..540fd3c2404 100644
--- a/booster/src/booster.c
+++ b/booster/src/booster.c
@@ -191,6 +191,8 @@ static ssize_t (*real_sendfile64) (int out_fd, int in_fd, off_t *offset,
size_t count);
static int (*real_fcntl) (int fd, int cmd, ...);
static int (*real_chdir) (const char *path);
+static int (*real_fchdir) (int fd);
+static char * (*real_getcwd) (char *buf, size_t size);
#define RESOLVE(sym) do { \
if (!real_##sym) \
@@ -2740,6 +2742,45 @@ unlock:
}
+int
+fchdir (int fd)
+{
+ int ret = -1;
+ glusterfs_file_t glfs_fd = 0;
+ char cwd[PATH_MAX];
+ char *res = NULL;
+
+ glfs_fd = booster_fdptr_get (booster_fdtable, fd);
+
+ if (!glfs_fd) {
+ gf_log ("booster", GF_LOG_TRACE, "Not a booster fd");
+ if (real_write == NULL) {
+ errno = ENOSYS;
+ ret = -1;
+ } else {
+ ret = real_fchdir (fd);
+ if (ret == 0) {
+ res = real_getcwd (cwd, PATH_MAX);
+ if (res == NULL) {
+ gf_log ("booster", GF_LOG_ERROR,
+ "getcwd failed (%s)",
+ strerror (errno));
+ ret = -1;
+ } else {
+ glusterfs_chdir (cwd);
+ }
+ }
+ }
+ } else {
+ gf_log ("booster", GF_LOG_TRACE, "Is a booster fd");
+ ret = glusterfs_fchdir (glfs_fd);
+ booster_fdptr_put (glfs_fd);
+ }
+
+ return ret;
+}
+
+
void
booster_lib_init (void)
{
@@ -2818,6 +2859,8 @@ booster_lib_init (void)
RESOLVE (readdir64_r);
RESOLVE (fcntl);
RESOLVE (chdir);
+ RESOLVE (fchdir);
+ RESOLVE (getcwd);
/* This must be called after resolving real functions
* above so that the socket based IO calls in libglusterfsclient