summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaushik BV <kaushikbv@gluster.com>2011-03-14 05:01:31 +0000
committerVijay Bellur <vijay@dev.gluster.com>2011-03-14 04:57:00 -0700
commit9043b0f8b927e687decc738cf736e603436e9e51 (patch)
treed9a16bf5040e33c1197e6d0ca31b265a5594dcda
parenteadce9083876fb71d1be8f77715866fc8af45ba4 (diff)
mgmt/Glusterd: Make use of regexp pattern-matching sections to set a sane value for remote-gsyncd
Signed-off-by: Kaushik BV <kaushikbv@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 2427 (set a proper default for remote syncdaemon) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2427
-rw-r--r--cli/src/cli-rpc-ops.c116
-rw-r--r--rpc/xdr/src/cli1-xdr.c3
-rw-r--r--rpc/xdr/src/cli1-xdr.h1
-rw-r--r--rpc/xdr/src/cli1-xdr.x1
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c194
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.h4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-rpc-ops.c8
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.c35
8 files changed, 200 insertions, 162 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index 31adfb33222..d2b0f5cc7f2 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -23,6 +23,10 @@
#include "config.h"
#endif
+#ifndef GSYNC_CONF
+#define GSYNC_CONF "gsync/gsyncd.conf"
+#endif
+
#include "cli.h"
#include "compat-errno.h"
#include "cli-cmd.h"
@@ -2400,27 +2404,30 @@ out:
int
gf_cli3_1_gsync_get_command (gf1_cli_gsync_set_rsp rsp)
{
- char cmd[1024] = {0,};
+ char cmd[PATH_MAX] = {0,};
if (rsp.op_ret < 0)
return 0;
- if (!rsp.gsync_prefix || !rsp.master || !rsp.slave)
+ if (!rsp.gsync_prefix || !rsp.master || !rsp.slave || !rsp.glusterd_workdir)
return -1;
if (rsp.config_type == GF_GSYNC_OPTION_TYPE_CONFIG_GET) {
if (!rsp.op_name)
return -1;
- snprintf (cmd, 1024, "%s/gsyncd %s %s --config-get %s ",
- rsp.gsync_prefix, rsp.master, rsp.slave,
- rsp.op_name);
+ snprintf (cmd, PATH_MAX, GSYNCD_PREFIX "/gsyncd -c %s/%s %s %s "
+ " --config-get %s ",
+ rsp.glusterd_workdir, GSYNC_CONF,
+ rsp.master, rsp.slave, rsp.op_name);
system (cmd);
goto out;
}
if (rsp.config_type == GF_GSYNC_OPTION_TYPE_CONFIG_GET_ALL) {
- snprintf (cmd, 1024, "%s/gsyncd %s %s --config-get-all ",
- rsp.gsync_prefix, rsp.master, rsp.slave);
+ snprintf (cmd, PATH_MAX, GSYNCD_PREFIX"/gsyncd -c %s/%s "
+ "%s %s --config-get-all ",
+ rsp.glusterd_workdir, GSYNC_CONF,
+ rsp.master, rsp.slave);
system (cmd);
@@ -2431,33 +2438,47 @@ out:
}
int
-gf_cli3_1_gsync_get_pid_file (char *pidfile, char *master, char *slave)
+gf_cli3_1_gsync_get_pid_file (char *pidfolder, char *pidfile, char *master, char *slave, char *gl_workdir)
{
- int ret = -1;
- int i = 0;
- char str[256] = {0, };
-
- GF_VALIDATE_OR_GOTO ("gsync", pidfile, out);
- GF_VALIDATE_OR_GOTO ("gsync", master, out);
- GF_VALIDATE_OR_GOTO ("gsync", slave, out);
+ FILE *in = NULL;
+ char buff[PATH_MAX] = {0, };
+ char cmd[PATH_MAX] = {0, };
+ char *ptr = NULL;
+ char buffer[PATH_MAX] = {0, };
+
+ snprintf (cmd, PATH_MAX, GSYNCD_PREFIX"/gsyncd --canonicalize-escape-url"
+ " %s %s", master, slave);
+ if (!(in = popen(cmd, "r"))) {
+ gf_log ("", GF_LOG_ERROR, "popen failed");
+ return -1;
+ }
- i = 0;
- //change '/' to '-'
- while (slave[i]) {
- (slave[i] == '/') ? (str[i] = '-') : (str[i] = slave[i]);
- i++;
+ ptr = fgets(buff, sizeof(buff), in);
+ if (ptr) {
+ buff[strlen(buff)-1]='\0'; //strip off \n
+ snprintf (buffer, PATH_MAX, "%s/gsync/%s", gl_workdir, buff);
+ strncpy (pidfolder, buffer, PATH_MAX);
+ }
+ else {
+ gf_log ("", GF_LOG_ERROR, "popen failed");
+ return -1;
}
- ret = snprintf (pidfile, 1024, "/etc/glusterd/gsync/%s/%s.pid",
- master, str);
- if (ret <= 0) {
- ret = -1;
- goto out;
+ memset (buff, 0, PATH_MAX);
+ memset (buffer, 0, PATH_MAX);
+
+ ptr = fgets(buff, sizeof(buff), in);
+ if (ptr) {
+ buff[strlen(buff)-1]='\0'; //strip off \n
+ snprintf (buffer, PATH_MAX, "%s/%s", pidfolder, buff);
+ strncpy (pidfile, buffer, PATH_MAX);
+ }
+ else {
+ gf_log ("", GF_LOG_ERROR, "popen failed");
+ return -1;
}
- ret = 0;
-out:
- return ret;
+ return 0;
}
/* status: 0 when gsync is running
@@ -2491,14 +2512,16 @@ out:
}
int
-gf_cli3_1_start_gsync (char *master, char *slave)
+gf_cli3_1_start_gsync (char *master, char *slave, char *gl_workdir)
{
int32_t ret = -1;
int32_t status = 0;
- char cmd[1024] = {0,};
- char pidfile[1024] = {0,};
+ char cmd[PATH_MAX] = {0,};
+ char pidfile[PATH_MAX] = {0,};
+ char pidfolder[PATH_MAX] = {0,};
- ret = gf_cli3_1_gsync_get_pid_file (pidfile, master, slave);
+ ret = gf_cli3_1_gsync_get_pid_file (pidfolder, pidfile, master,
+ slave, gl_workdir);
if (ret == -1) {
ret = -1;
gf_log ("", GF_LOG_WARNING, "failed to construct the "
@@ -2519,25 +2542,17 @@ gf_cli3_1_start_gsync (char *master, char *slave)
unlink (pidfile);
- ret = snprintf (cmd, 1024, "mkdir -p /etc/glusterd/gsync/%s",
- master);
- if (ret <= 0) {
- ret = -1;
- gf_log ("", GF_LOG_WARNING, "failed to construct the "
- "pid path");
- goto out;
- }
-
- ret = system (cmd);
- if (ret == -1) {
- gf_log ("", GF_LOG_WARNING, "failed to create the "
- "pid path for %s %s", master, slave);
+ ret = mkdir (pidfolder, 0777);
+ if (ret && (errno != EEXIST)) {
+ gf_log ("", GF_LOG_DEBUG, "mkdir failed, errno: %d",
+ errno);
goto out;
}
memset (cmd, 0, sizeof (cmd));
- ret = snprintf (cmd, 1024, GSYNCD_PREFIX "/gsyncd %s %s "
- "--config-set pid-file %s", master, slave, pidfile);
+ ret = snprintf (cmd, PATH_MAX, GSYNCD_PREFIX "/gsyncd -c %s/%s %s %s"
+ " --config-set pid-file %s", gl_workdir,
+ GSYNC_CONF, master, slave, pidfile);
if (ret <= 0) {
ret = -1;
gf_log ("", GF_LOG_WARNING, "failed to construct the "
@@ -2553,8 +2568,8 @@ gf_cli3_1_start_gsync (char *master, char *slave)
}
memset (cmd, 0, sizeof (cmd));
- ret = snprintf (cmd, 1024, GSYNCD_PREFIX "/gsyncd "
- "%s %s", master, slave);
+ ret = snprintf (cmd, PATH_MAX, GSYNCD_PREFIX "/gsyncd -c %s/%s %s %s"
+ , gl_workdir, GSYNC_CONF, master, slave);
if (ret <= 0) {
ret = -1;
goto out;
@@ -2598,7 +2613,8 @@ gf_cli3_1_gsync_set_cbk (struct rpc_req *req, struct iovec *iov,
}
else {
if (rsp.type == GF_GSYNC_OPTION_TYPE_START)
- ret = gf_cli3_1_start_gsync (rsp.master, rsp.slave);
+ ret = gf_cli3_1_start_gsync (rsp.master, rsp.slave,
+ rsp.glusterd_workdir);
else if (rsp.config_type == GF_GSYNC_OPTION_TYPE_CONFIG_GET_ALL)
ret = gf_cli3_1_gsync_get_command (rsp);
else
diff --git a/rpc/xdr/src/cli1-xdr.c b/rpc/xdr/src/cli1-xdr.c
index 8e9395a52bb..ba58992d838 100644
--- a/rpc/xdr/src/cli1-xdr.c
+++ b/rpc/xdr/src/cli1-xdr.c
@@ -712,6 +712,9 @@ xdr_gf1_cli_gsync_set_rsp (XDR *xdrs, gf1_cli_gsync_set_rsp *objp)
return FALSE;
if (!xdr_string (xdrs, &objp->gsync_prefix, ~0))
return FALSE;
+ if (!xdr_string (xdrs, &objp->glusterd_workdir, ~0))
+ return FALSE;
+
return TRUE;
}
diff --git a/rpc/xdr/src/cli1-xdr.h b/rpc/xdr/src/cli1-xdr.h
index 0ca38b36b20..fc84e48dd0f 100644
--- a/rpc/xdr/src/cli1-xdr.h
+++ b/rpc/xdr/src/cli1-xdr.h
@@ -440,6 +440,7 @@ struct gf1_cli_gsync_set_rsp {
char *master;
char *slave;
char *gsync_prefix;
+ char *glusterd_workdir;
};
typedef struct gf1_cli_gsync_set_rsp gf1_cli_gsync_set_rsp;
diff --git a/rpc/xdr/src/cli1-xdr.x b/rpc/xdr/src/cli1-xdr.x
index 61d0b8425ed..f47d18d887c 100644
--- a/rpc/xdr/src/cli1-xdr.x
+++ b/rpc/xdr/src/cli1-xdr.x
@@ -324,6 +324,7 @@ struct gf1_cli_gsync_set_rsp {
string master<>;
string slave<>;
string gsync_prefix<>;
+ string glusterd_workdir<>;
};
struct gf1_cli_stats_volume_req {
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 067956280c1..7c9430bc5dd 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -1672,33 +1672,53 @@ volname_from_master (char *master)
}
int
-gsync_get_pid_file (char *pidfile, char *master, char *slave)
+glusterd_gsync_get_pid_file (char *pidfile, char *master, char *slave)
{
- int ret = -1;
- int i = 0;
- char str[256] = {0, };
+ FILE *in = NULL;
+ char buff[PATH_MAX] = {0, };
+ char cmd[PATH_MAX] = {0, };
+ char *ptr = NULL;
+ char buffer[PATH_MAX] = {0, };
+ char pidfolder[PATH_MAX] = {0, };
+ glusterd_conf_t *priv = NULL;
- GF_VALIDATE_OR_GOTO ("gsync", pidfile, out);
- GF_VALIDATE_OR_GOTO ("gsync", master, out);
- GF_VALIDATE_OR_GOTO ("gsync", slave, out);
+ GF_ASSERT (THIS);
- i = 0;
- //change '/' to '-'
- while (slave[i]) {
- (slave[i] == '/') ? (str[i] = '-') : (str[i] = slave[i]);
- i++;
+ priv = THIS->private;
+
+ snprintf (cmd, PATH_MAX, GSYNCD_PREFIX"/gsyncd --canonicalize-escape-url"
+ " %s %s", master, slave);
+ if (!(in = popen(cmd, "r"))) {
+ gf_log ("", GF_LOG_ERROR, "popen failed");
+ return -1;
}
- ret = snprintf (pidfile, 1024, "/etc/glusterd/gsync/%s/%s.pid",
- master, str);
- if (ret <= 0) {
- ret = -1;
- goto out;
+ ptr = fgets(buff, sizeof(buff), in);
+ if (ptr) {
+ buff[strlen(buff)-1]='\0'; //strip off \n
+ snprintf (buffer, PATH_MAX, "%s/gsync/%s", priv->workdir, buff);
+ strncpy (pidfolder, buffer, PATH_MAX);
+ }
+ else {
+ gf_log ("", GF_LOG_ERROR, "popen failed");
+ return -1;
}
- ret = 0;
-out:
- return ret;
+ memset (buff, 0, PATH_MAX);
+ memset (buffer, 0, PATH_MAX);
+
+ ptr = fgets(buff, sizeof(buff), in);
+ if (ptr) {
+ buff[strlen(buff)-1]='\0'; //strip off \n
+ snprintf (buffer, PATH_MAX, "%s/%s", pidfolder, buff);
+ strncpy (pidfile, buffer, PATH_MAX);
+ }
+ else {
+ gf_log ("", GF_LOG_ERROR, "popen failed");
+ return -1;
+ }
+
+ return 0;
}
/* status: return 0 when gsync is running
@@ -1708,16 +1728,19 @@ int
gsync_status (char *master, char *slave, int *status)
{
int ret = -1;
- char pidfile[1024] = {0,};
+ char pidfile[PATH_MAX] = {0,};
FILE *file = NULL;
GF_VALIDATE_OR_GOTO ("gsync", master, out);
GF_VALIDATE_OR_GOTO ("gsync", slave, out);
GF_VALIDATE_OR_GOTO ("gsync", status, out);
- ret = gsync_get_pid_file (pidfile, master, slave);
- if (ret == -1)
+ ret = glusterd_gsync_get_pid_file (pidfile, master, slave);
+ if (ret == -1) {
+ ret = -1;
+ gf_log ("", GF_LOG_WARNING, "failed to create the pidfile string");
goto out;
+ }
file = fopen (pidfile, "r+");
if (file) {
@@ -3532,8 +3555,7 @@ stop_gsync (char *master, char *slave, char **op_errstr)
goto out;
}
- //change '/' to '-'
- ret = gsync_get_pid_file (pidfile, master, slave);
+ ret = glusterd_gsync_get_pid_file (pidfile, master, slave);
if (ret == -1) {
ret = -1;
gf_log ("", GF_LOG_WARNING, "failed to create the pidfile string");
@@ -3577,6 +3599,21 @@ gsync_config_set (char *master, char *slave,
char *op_name = NULL;
char *op_value = NULL;
char cmd[1024] = {0,};
+ glusterd_conf_t *priv = NULL;
+
+ if (THIS == NULL) {
+ gf_log ("", GF_LOG_ERROR, "THIS of glusterd not present");
+ *op_errstr = gf_strdup ("Error! Glusterd cannot start gsyncd");
+ goto out;
+ }
+
+ priv = THIS->private;
+
+ if (priv == NULL) {
+ gf_log ("", GF_LOG_ERROR, "priv of glusterd not present");
+ *op_errstr = gf_strdup ("Error! Glusterd cannot start gsyncd");
+ goto out;
+ }
ret = dict_get_str (dict, "op_name", &op_name);
if (ret < 0) {
@@ -3600,8 +3637,9 @@ gsync_config_set (char *master, char *slave,
goto out;
}
- ret = snprintf (cmd, 1024, GSYNCD_PREFIX "/gsyncd %s %s "
- "--config-set %s %s", master, slave, op_name, op_value);
+ ret = snprintf (cmd, 1024, GSYNCD_PREFIX"/gsyncd -c %s/%s %s %s"
+ "--config-set %s %s", priv->workdir,
+ GSYNC_CONF, master, slave, op_name, op_value);
if (ret <= 0) {
gf_log ("", GF_LOG_WARNING, "failed to "
"construct the gsyncd command");
@@ -3635,53 +3673,22 @@ gsync_config_del (char *master, char *slave,
{
int32_t ret = -1;
char *op_name = NULL;
- char cmd[1024] = {0,};
-
- ret = dict_get_str (dict, "op_name", &op_name);
- if (ret < 0) {
- gf_log ("", GF_LOG_WARNING, "failed to get "
- "the option for %s %s", master, slave);
+ char cmd[PATH_MAX] = {0,};
+ glusterd_conf_t *priv = NULL;
- *op_errstr = gf_strdup ("configure command "
- "failed, please check "
- "the log-file\n");
+ if (THIS == NULL) {
+ gf_log ("", GF_LOG_ERROR, "THIS of glusterd not present");
+ *op_errstr = gf_strdup ("Error! Glusterd cannot start gsyncd");
goto out;
}
- ret = snprintf (cmd, 4096, GSYNCD_PREFIX "/gsyncd %s %s "
- "--config-del %s", master, slave, op_name);
- if (ret <= 0) {
- gf_log ("", GF_LOG_WARNING, "failed to "
- "construct the gsyncd command");
- *op_errstr = gf_strdup ("configure command "
- "failed, please check "
- "the log-file\n");
- goto out;
- }
+ priv = THIS->private;
- ret = system (cmd);
- if (ret == -1) {
- gf_log ("", GF_LOG_WARNING, "failed to delete "
- "%s option for %s %s peer", op_name,
- master, slave);
- *op_errstr = gf_strdup ("configure command "
- "failed, please check "
- "the log-file\n");
+ if (priv == NULL) {
+ gf_log ("", GF_LOG_ERROR, "priv of glusterd not present");
+ *op_errstr = gf_strdup ("Error! Glusterd cannot start gsyncd");
goto out;
}
- ret = 0;
- *op_errstr = gf_strdup ("config-del successful");
-out:
- return ret;
-}
-
-int
-gsync_config_get (char *master, char *slave,
- dict_t *dict, char **op_errstr)
-{
- int32_t ret = -1;
- char *op_name = NULL;
- char cmd[1024] = {0,};
ret = dict_get_str (dict, "op_name", &op_name);
if (ret < 0) {
@@ -3694,8 +3701,9 @@ gsync_config_get (char *master, char *slave,
goto out;
}
- ret = snprintf (cmd, 4096, GSYNCD_PREFIX "/gsyncd %s %s "
- "--config-get %s", master, slave, op_name);
+ ret = snprintf (cmd, PATH_MAX, GSYNCD_PREFIX"/gsyncd -c %s/%s %s %s"
+ " --config-del %s ", priv->workdir,
+ GSYNC_CONF, master, slave, op_name);
if (ret <= 0) {
gf_log ("", GF_LOG_WARNING, "failed to "
"construct the gsyncd command");
@@ -3707,7 +3715,7 @@ gsync_config_get (char *master, char *slave,
ret = system (cmd);
if (ret == -1) {
- gf_log ("", GF_LOG_WARNING, "failed to get "
+ gf_log ("", GF_LOG_WARNING, "failed to delete "
"%s option for %s %s peer", op_name,
master, slave);
*op_errstr = gf_strdup ("configure command "
@@ -3716,44 +3724,11 @@ gsync_config_get (char *master, char *slave,
goto out;
}
ret = 0;
- *op_errstr = gf_strdup ("config-get successful");
+ *op_errstr = gf_strdup ("config-del successful");
out:
return ret;
}
-int
-gsync_config_get_all (char *master, char *slave, char **op_errstr)
-{
- int32_t ret = -1;
- char cmd[1024] = {0,};
-
- ret = snprintf (cmd, 4096, GSYNCD_PREFIX "/gsyncd %s %s "
- "config-get-all", master, slave);
- if (ret <= 0) {
- gf_log ("", GF_LOG_WARNING, "failed to "
- "construct the gsyncd command "
- "for config-get-all");
- *op_errstr = gf_strdup ("configure command "
- "failed, please check "
- "the log-file\n");
- goto out;
- }
-
- ret = system (cmd);
- if (ret == -1) {
- gf_log ("", GF_LOG_WARNING, "failed to get "
- "all options for %s %s peer", master,
- slave);
- *op_errstr = gf_strdup ("configure command "
- "failed, please check "
- "the log-file\n");
- goto out;
- }
- ret = 0;
- *op_errstr = gf_strdup ("config-get successful");
-out:
- return ret;
-}
int
gsync_configure (char *master, char *slave,
@@ -3781,15 +3756,10 @@ gsync_configure (char *master, char *slave,
goto out;
}
- if (config_type == GF_GSYNC_OPTION_TYPE_CONFIG_GET) {
- ret = gsync_config_get (master, slave, dict, op_errstr);
- goto out;
- }
-
- if (config_type == GF_GSYNC_OPTION_TYPE_CONFIG_GET_ALL) {
- ret = gsync_config_get_all (master, slave, op_errstr);
+ if ((config_type == GF_GSYNC_OPTION_TYPE_CONFIG_GET_ALL) ||
+ (config_type == GF_GSYNC_OPTION_TYPE_CONFIG_GET))
goto out;
- } else {
+ else {
gf_log ("", GF_LOG_WARNING, "Invalid config type");
*op_errstr = gf_strdup ("Invalid config type");
ret = -1;
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.h b/xlators/mgmt/glusterd/src/glusterd-op-sm.h
index c9c3889b57f..ff507abbac0 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.h
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.h
@@ -25,6 +25,10 @@
#include "config.h"
#endif
+#ifndef GSYNC_CONF
+#define GSYNC_CONF "gsync/gsyncd.conf"
+#endif
+
#include <pthread.h>
#include "uuid.h"
diff --git a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
index 8eba024a919..b46fb23db0f 100644
--- a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
@@ -56,6 +56,13 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret,
void *cli_rsp = NULL;
dict_t *ctx = NULL;
char *free_ptr = NULL;
+ glusterd_conf_t *conf = NULL;
+
+ GF_ASSERT (THIS);
+
+ conf = THIS->private;
+
+ GF_ASSERT (conf);
switch (op) {
case GD_OP_CREATE_VOLUME:
@@ -264,6 +271,7 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret,
rsp.op_name = "";
rsp.master = "";
rsp.slave = "";
+ rsp.glusterd_workdir = gf_strdup (conf->workdir);
rsp.gsync_prefix = gf_strdup (GSYNCD_PREFIX);
if (ctx) {
ret = dict_get_str (ctx, "errstr",
diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c
index 732a9a3e2b5..570fd1662a8 100644
--- a/xlators/mgmt/glusterd/src/glusterd.c
+++ b/xlators/mgmt/glusterd/src/glusterd.c
@@ -233,6 +233,7 @@ init (xlator_t *this)
char dirname [PATH_MAX];
char cmd_log_filename [PATH_MAX] = {0,};
int first_time = 0;
+ char cmd [PATH_MAX] = {0,};
dir_data = dict_get (this->options, "working-directory");
@@ -323,7 +324,41 @@ init (xlator_t *this)
" ,errno = %d", voldir, errno);
exit (1);
}
+#if (SYNCDAEMON_COMPILE)
+ snprintf (voldir, PATH_MAX, "%s/gsync", dirname);
+ ret = mkdir (voldir, 0777);
+ if ((-1 == ret) && (errno != EEXIST)) {
+ gf_log (this->name, GF_LOG_CRITICAL,
+ "Unable to create gsync directory %s"
+ " ,errno = %d", voldir, errno);
+ exit (1);
+ }
+
+ ret = snprintf (cmd, PATH_MAX, GSYNCD_PREFIX "/gsyncd -c %s/%s "
+ " --config-set-rx remote-gsyncd %s/gsyncd . ."
+ , dirname, GSYNC_CONF, GSYNCD_PREFIX);
+ if (ret <= 0) {
+ ret = -1;
+ goto out;
+ }
+
+ ret = system (cmd);
+ if (ret == -1)
+ goto out;
+ ret = snprintf (cmd, 1024, GSYNCD_PREFIX "/gsyncd -c %s/%s "
+ " --config-set-rx remote-gsyncd"
+ " /usr/local/libexec/glusterfs/gsyncd . ^ssh:"
+ , dirname, GSYNC_CONF);
+ if (ret <= 0) {
+ ret = -1;
+ goto out;
+ }
+
+ ret = system (cmd);
+ if (ret == -1)
+ goto out;
+#endif
rpc = rpcsvc_init (this->ctx, this->options);
if (rpc == NULL) {
gf_log (this->name, GF_LOG_ERROR,