summaryrefslogtreecommitdiffstats
path: root/api/src
diff options
context:
space:
mode:
authorAnand Avati <avati@redhat.com>2013-04-27 11:59:36 -0700
committerVijay Bellur <vbellur@redhat.com>2013-05-02 23:20:49 -0700
commit54b9cd3df357ac196af17f53282b3b1975dd4fb9 (patch)
treeaaa5cd8cdd22db32190536bbfab12562167ffcc9 /api/src
parentaec246459b4c82fd666a3de20a55700008a5f831 (diff)
gfapi: add new API glfs_set_xlator_option()
This is the equivalent of specifying --xlator-option command line argument to glusterfsd. Change-Id: I1171dd518a85db4bd456fa0790f450e889a956cd BUG: 953694 Signed-off-by: Anand Avati <avati@redhat.com> Reviewed-on: http://review.gluster.org/4927 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'api/src')
-rw-r--r--api/src/glfs-mem-types.h1
-rw-r--r--api/src/glfs.c42
-rw-r--r--api/src/glfs.h3
3 files changed, 45 insertions, 1 deletions
diff --git a/api/src/glfs-mem-types.h b/api/src/glfs-mem-types.h
index e2e9b4c1ed7..590acd03f11 100644
--- a/api/src/glfs-mem-types.h
+++ b/api/src/glfs-mem-types.h
@@ -22,6 +22,7 @@ enum glfs_mem_types_ {
glfs_mt_glfs_fd_t,
glfs_mt_glfs_io_t,
glfs_mt_volfile_t,
+ glfs_mt_xlator_cmdline_option_t,
glfs_mt_end
};
diff --git a/api/src/glfs.c b/api/src/glfs.c
index 01c3494e28e..ac55628bd55 100644
--- a/api/src/glfs.c
+++ b/api/src/glfs.c
@@ -21,7 +21,6 @@
- protocol/client to reconnect immediately after portmap disconnect.
- handle SEEK_END failure in _lseek()
- handle umask (per filesystem?)
- - implement glfs_set_xlator_option(), like --xlator-option
- make itables LRU based
- implement glfs_fini()
- 0-copy for readv/writev
@@ -279,6 +278,47 @@ out:
///////////////////////////////////////////////////////////////////////////////
+int
+glfs_set_xlator_option (struct glfs *fs, const char *xlator, const char *key,
+ const char *value)
+{
+ xlator_cmdline_option_t *option = NULL;
+
+ option = GF_CALLOC (1, sizeof (*option),
+ glfs_mt_xlator_cmdline_option_t);
+ if (!option)
+ goto enomem;
+
+ INIT_LIST_HEAD (&option->cmd_args);
+
+ option->volume = gf_strdup (xlator);
+ if (!option->volume)
+ goto enomem;
+ option->key = gf_strdup (key);
+ if (!option->key)
+ goto enomem;
+ option->value = gf_strdup (value);
+ if (!option->value)
+ goto enomem;
+
+ list_add (&option->cmd_args, &fs->ctx->cmd_args.xlator_options);
+
+ return 0;
+enomem:
+ errno = ENOMEM;
+
+ if (!option)
+ return -1;
+
+ GF_FREE (option->volume);
+ GF_FREE (option->key);
+ GF_FREE (option->value);
+ GF_FREE (option);
+
+ return -1;
+}
+
+
struct glfs *
glfs_from_glfd (struct glfs_fd *glfd)
{
diff --git a/api/src/glfs.h b/api/src/glfs.h
index 7fecffb697a..aeabfdf0b4f 100644
--- a/api/src/glfs.h
+++ b/api/src/glfs.h
@@ -301,6 +301,9 @@ int glfs_close (glfs_fd_t *fd);
glfs_t *glfs_from_glfd (glfs_fd_t *fd);
+int glfs_set_xlator_option (glfs_t *fs, const char *xlator, const char *key,
+ const char *value);
+
typedef void (*glfs_io_cbk) (glfs_fd_t *fd, ssize_t ret, void *data);
// glfs_{read,write}[_async]