summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/transport.c
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfs/src/transport.c')
0 files changed, 0 insertions, 0 deletions
2.3qa6&id=a0aafa365dd355864d24232bd6d7f399ef38f9ef&id2=496a04f3b2d46893635f93e5a33032969a826cd2'>diff)
cli: gluster profile CLI
Signed-off-by: Pranith Kumar K <pranithk@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 1965 (need a cmd to get io-stat details) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1965
Diffstat (limited to 'cli/src')
-rw-r--r--cli/src/cli-cmd-parser.c326
-rw-r--r--cli/src/cli-cmd-volume.c48
-rw-r--r--cli/src/cli-cmd.h9
-rw-r--r--cli/src/cli-rpc-ops.c319
-rw-r--r--cli/src/cli.c9
-rw-r--r--cli/src/cli.h3
6 files changed, 534 insertions, 180 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index 8cfdc808a..b38cf24fa 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -37,28 +37,115 @@
#include "cli1-xdr.h"
int32_t
+cli_cmd_bricks_parse (const char **words, int wordcount, int brick_index,
+ char **bricks, int *brick_count)
+{
+ int ret = 0;
+ char *tmp_list = NULL;
+ char brick_list[120000] = {0,};
+ char *space = " ";
+ char *delimiter = NULL;
+ char *host_name = NULL;
+ char *tmp = NULL;
+ char *free_list_ptr = NULL;
+ char *tmpptr = NULL;
+ int j = 0;
+ int brick_list_len = 0;
+
+ GF_ASSERT (words);
+ GF_ASSERT (wordcount);
+ GF_ASSERT (bricks);
+ GF_ASSERT (brick_index > 0);
+ GF_ASSERT (brick_index < wordcount);
+
+ strncpy (brick_list, space, strlen (space));
+ brick_list_len++;
+ while (brick_index < wordcount) {
+ delimiter = strchr (words[brick_index], ':');
+ if (!delimiter || delimiter == words[brick_index]
+ || *(delimiter+1) != '/') {
+ cli_out ("wrong brick type: %s, use <HOSTNAME>:"
+ "<export-dir-abs-path>", words[brick_index]);
+ ret = -1;
+ goto out;
+ } else {
+ cli_path_strip_trailing_slashes (delimiter + 1);
+ }
+
+ if ((brick_list_len + strlen (words[brick_index]) + 1) > sizeof (brick_list)) {
+ gf_log ("cli", GF_LOG_ERROR,
+ "total brick list is larger than a request "
+ "can take (brick_count %d)", *brick_count);
+ ret = -1;
+ goto out;
+ }
+
+ host_name = gf_strdup (words[brick_index]);
+ if (!host_name) {
+ ret = -1;
+ gf_log("cli",GF_LOG_ERROR, "Unable to allocate "
+ "memory");
+ goto out;
+ }
+
+ strtok_r (host_name, ":", &tmp);
+ if (!(strcmp (host_name, "localhost") &&
+ strcmp (host_name, "127.0.0.1"))) {
+ cli_out ("Please provide a valid hostname/ip other "
+ "than localhost or 127.0.0.1");
+ ret = -1;
+ GF_FREE (host_name);
+ goto out;
+ }
+ GF_FREE (host_name);
+ tmp_list = gf_strdup (brick_list + 1);
+ if (free_list_ptr) {
+ GF_FREE (free_list_ptr);
+ free_list_ptr = NULL;
+ }
+ free_list_ptr = tmp_list;
+ j = 0;
+ while(j < *brick_count) {
+ strtok_r (tmp_list, " ", &tmpptr);
+ if (!(strcmp (tmp_list, words[brick_index]))) {
+ ret = -1;
+ cli_out ("Found duplicate"
+ " exports %s",words[brick_index]);
+ goto out;
+ }
+ tmp_list = tmpptr;
+ j++;
+ }
+ strcat (brick_list, words[brick_index]);
+ strcat (brick_list, " ");
+ brick_list_len += (strlen (words[brick_index]) + 1);
+ ++(*brick_count);
+ ++brick_index;
+ }
+
+ *bricks = gf_strdup (brick_list);
+ if (!*bricks)
+ ret = -1;
+out:
+ if (free_list_ptr)
+ GF_FREE (free_list_ptr);
+ return ret;
+}
+
+int32_t
cli_cmd_volume_create_parse (const char **words, int wordcount, dict_t **options)
{
dict_t *dict = NULL;
char *volname = NULL;
- char *delimiter = NULL;
int ret = -1;
gf1_cluster_type type = GF_CLUSTER_TYPE_NONE;
int count = 1;
- int brick_count = 0, brick_index = 0;
- int brick_list_size = 1;
- char brick_list[120000] = {0,};
+ int brick_index = 0;
int i = 0;
- char *tmp_list = NULL;
- char *tmpptr = NULL;
- int j = 0;
- char *host_name = NULL;
- char *tmp = NULL;
- char *freeptr = NULL;
char *trans_type = NULL;
int32_t index = 0;
- char *free_list_ptr = NULL;
char *bricks = NULL;
+ int32_t brick_count = 0;
GF_ASSERT (words);
GF_ASSERT (options);
@@ -187,77 +274,10 @@ cli_cmd_volume_create_parse (const char **words, int wordcount, dict_t **options
if (ret)
goto out;
- strcpy (brick_list, " ");
- while (brick_index < wordcount) {
- delimiter = strchr (words[brick_index], ':');
- if (!delimiter || delimiter == words[brick_index]
- || *(delimiter+1) != '/') {
- cli_out ("wrong brick type: %s, use <HOSTNAME>:"
- "<export-dir-abs-path>", words[brick_index]);
- ret = -1;
- goto out;
- } else {
- cli_path_strip_trailing_slashes (delimiter + 1);
- }
- if ((brick_list_size + strlen (words[brick_index]) + 1) > 120000) {
- gf_log ("cli", GF_LOG_ERROR,
- "total brick list is larger than a request "
- "can take (brick_count %d)", brick_count);
- ret = -1;
- goto out;
- }
-
- host_name = gf_strdup(words[brick_index]);
- if (!host_name) {
- ret = -1;
- gf_log("cli",GF_LOG_ERROR, "Unable to allocate "
- "memory");
- goto out;
- }
- freeptr = host_name;
-
- strtok_r(host_name, ":", &tmp);
- if (!(strcmp(host_name, "localhost") &&
- strcmp (host_name, "127.0.0.1"))) {
- cli_out ("Please provide a valid hostname/ip other "
- "than localhost or 127.0.0.1");
- ret = -1;
- GF_FREE(freeptr);
- goto out;
- }
- GF_FREE (freeptr);
- tmp_list = strdup(brick_list+1);
- f