summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/xlator.c
diff options
context:
space:
mode:
authorCsaba Henk <csaba@gluster.com>2010-10-02 07:30:37 +0000
committerVijay Bellur <vijay@dev.gluster.com>2010-10-02 06:30:14 -0700
commit1cc15f9b0057cd6c8843c8b9cbb36c02d334ec6f (patch)
treeb568ef8419466aa95e9822ba3a331f936f100e38 /libglusterfs/src/xlator.c
parent73c6b2f21a67bed186a279adacb4eb28eafcd853 (diff)
xlator: make it possible to do type setting and dynamic loading separately
Signed-off-by: Csaba Henk <csaba@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 1750 (clean up volgen) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1750
Diffstat (limited to 'libglusterfs/src/xlator.c')
-rw-r--r--libglusterfs/src/xlator.c38
1 files changed, 30 insertions, 8 deletions
diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c
index 105ee497b..66508966a 100644
--- a/libglusterfs/src/xlator.c
+++ b/libglusterfs/src/xlator.c
@@ -674,14 +674,8 @@ validate_xlator_volume_options (xlator_t *xl, volume_option_t *opt)
}
int32_t
-xlator_set_type (xlator_t *xl,
- const char *type)
+xlator_set_type_virtual (xlator_t *xl, const char *type)
{
- int ret = 0;
- char *name = NULL;
- void *handle = NULL;
- volume_opt_list_t *vol_opt = NULL;
-
if (xl == NULL || type == NULL) {
gf_log ("xlator", GF_LOG_DEBUG, "invalid argument");
return -1;
@@ -689,7 +683,22 @@ xlator_set_type (xlator_t *xl,
xl->type = gf_strdup (type);
- ret = gf_asprintf (&name, "%s/%s.so", XLATORDIR, type);
+ if (xl->type)
+ return 0;
+ else
+ return -1;
+}
+
+
+int32_t
+xlator_dynload (xlator_t *xl)
+{
+ int ret = 0;
+ char *name = NULL;
+ void *handle = NULL;
+ volume_opt_list_t *vol_opt = NULL;
+
+ ret = gf_asprintf (&name, "%s/%s.so", XLATORDIR, xl->type);
if (-1 == ret) {
gf_log ("xlator", GF_LOG_ERROR, "asprintf failed");
return -1;
@@ -779,6 +788,19 @@ xlator_set_type (xlator_t *xl,
}
+int32_t
+xlator_set_type (xlator_t *xl, const char *type)
+{
+ int ret = 0;
+
+ ret = xlator_set_type_virtual (xl, type);
+ if (!ret)
+ ret = xlator_dynload (xl);
+
+ return ret;
+}
+
+
void
xlator_foreach (xlator_t *this,
void (*fn)(xlator_t *each,