summaryrefslogtreecommitdiffstats
path: root/booster
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2009-11-18 01:19:22 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-11-18 21:14:50 -0800
commit64a4b1f78ee719f33928f4de9abac2a09ce84f21 (patch)
treea04785ec6e398f36c4ab5775cbc8d96f9f5b28b3 /booster
parent95d31d089ed8e8a1bb90377160ac0bccdd47b6c0 (diff)
booster: implement xattr related apis.
- implement setxattr, fsetxattr, lsetxattr. 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.c101
1 files changed, 101 insertions, 0 deletions
diff --git a/booster/src/booster.c b/booster/src/booster.c
index 2e0d8de9d..338d6db73 100644
--- a/booster/src/booster.c
+++ b/booster/src/booster.c
@@ -197,6 +197,12 @@ static int (*real_fchdir) (int fd);
static char * (*real_getcwd) (char *buf, size_t size);
static int (*real_truncate) (const char *path, off_t length);
static int (*real_truncate64) (const char *path, loff_t length);
+static int (*real_setxattr) (const char *path, const char *name,
+ const void *value, size_t size, int flags);
+static int (*real_lsetxattr) (const char *path, const char *name,
+ const void *value, size_t size, int flags);
+static int (*real_fsetxattr) (int filedes, const char *name,
+ const void *value, size_t size, int flags);
#define RESOLVE(sym) do { \
@@ -2946,6 +2952,98 @@ out:
}
+int
+setxattr (const char *path, const char *name, const void *value, size_t size,
+ int flags)
+{
+ int ret = -1;
+
+ gf_log ("booster", GF_LOG_TRACE, "setxattr: path: %s", path);
+ ret = glusterfs_setxattr (path, name, value, size, flags);
+ if ((ret == -1) && (errno != ENODEV)) {
+ gf_log ("booster", GF_LOG_ERROR, "setxattr failed: %s",
+ strerror (errno));
+ goto out;
+ }
+
+ if (ret == 0) {
+ gf_log ("booster", GF_LOG_TRACE, "setxattr succeeded");
+ goto out;
+ }
+
+ if (real_setxattr != NULL)
+ ret = real_setxattr (path, name, value, size, flags);
+ else {
+ errno = ENOSYS;
+ ret = -1;
+ goto out;
+ }
+
+out:
+ return ret;
+}
+
+
+int
+lsetxattr (const char *path, const char *name, const void *value, size_t size,
+ int flags)
+{
+ int ret = -1;
+
+ gf_log ("booster", GF_LOG_TRACE, "lsetxattr: path: %s", path);
+ ret = glusterfs_lsetxattr (path, name, value, size, flags);
+ if ((ret == -1) && (errno != ENODEV)) {
+ gf_log ("booster", GF_LOG_ERROR, "lsetxattr failed: %s",
+ strerror (errno));
+ goto out;
+ }
+
+ if (ret == 0) {
+ gf_log ("booster", GF_LOG_TRACE, "lsetxattr succeeded");
+ goto out;
+ }
+
+ if (real_lsetxattr != NULL)
+ ret = real_lsetxattr (path, name, value, size, flags);
+ else {
+ errno = ENOSYS;
+ ret = -1;
+ goto out;
+ }
+
+out:
+ return ret;
+}
+
+
+int
+fsetxattr (int fd, const char *name, const void *value, size_t size, int flags)
+{
+ int ret = -1;
+ glusterfs_file_t fh = NULL;
+
+ gf_log ("booster", GF_LOG_TRACE, "fsetxattr: fd %d", fd);
+ fh = booster_fdptr_get (booster_fdtable, fd);
+ if (!fh) {
+ gf_log ("booster", GF_LOG_TRACE, "Not a booster fd");
+ if (real_fsetxattr != NULL)
+ ret = real_fsetxattr (fd, name, value, size, flags);
+ else {
+ ret = -1;
+ errno = ENOSYS;
+ goto out;
+ }
+ } else {
+ gf_log ("booster", GF_LOG_TRACE, "Is a booster fd");
+ ret = glusterfs_fsetxattr (fh, name, value, size, flags);
+ booster_fdptr_put (fh);
+ }
+
+out:
+ return ret;
+}
+
+
void
booster_lib_init (void)
{
@@ -3030,6 +3128,9 @@ booster_lib_init (void)
RESOLVE (getcwd);
RESOLVE (truncate);
RESOLVE (truncate64);
+ RESOLVE (setxattr);
+ RESOLVE (lsetxattr);
+ RESOLVE (fsetxattr);
/* This must be called after resolving real functions
* above so that the socket based IO calls in libglusterfsclient