summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/mgmt/glusterd')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c82
1 files changed, 34 insertions, 48 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 0bae57847b9..7003c579362 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -98,7 +98,6 @@ static char *glusterd_op_sm_event_names[] = {
static char *gsync_reserved_opts[] = {
"gluster-command",
"pid-file",
- "log-file",
"state-file",
"session-owner",
NULL
@@ -1724,33 +1723,21 @@ out:
}
-static int
-glusterd_get_canon_url (char *cann, char *name, gf_boolean_t cann_esc)
+int
+glusterd_query_extutil (char *resbuf, char *cmd)
{
- FILE *in = NULL;
- char buff[PATH_MAX] = {0, };
- char cmd[PATH_MAX] = {0, };
+ FILE *in = NULL;
char *ptr = NULL;
- glusterd_conf_t *priv = NULL;
int ret = 0;
- GF_ASSERT (THIS);
- GF_ASSERT (THIS->private);
-
- priv = THIS->private;
-
- snprintf (cmd, PATH_MAX, GSYNCD_PREFIX"/gsyncd --canonicalize-%surl %s",
- cann_esc? "escape-": "",name);
if (!(in = popen(cmd, "r"))) {
gf_log ("", GF_LOG_ERROR, "popen failed");
return -1;
}
- ptr = fgets(buff, sizeof(buff), in);
- if (ptr) {
- buff[strlen(buff)-1]='\0'; //strip off \n
- strncpy (cann, buff, PATH_MAX);
- }
+ ptr = fgets(resbuf, PATH_MAX, in);
+ if (ptr)
+ resbuf[strlen(resbuf)-1] = '\0'; //strip off \n
ret |= pclose (in);
@@ -1758,43 +1745,42 @@ glusterd_get_canon_url (char *cann, char *name, gf_boolean_t cann_esc)
gf_log ("", GF_LOG_ERROR, "popen failed");
return ret ? -1 : 0;
-
}
-int
-glusterd_gsync_get_param_file (char *prmfile, const char *ext, char *master,
- char *slave, char *gl_workdir)
+static int
+glusterd_get_canon_url (char *cann, char *name, gf_boolean_t cann_esc)
{
- char buff[PATH_MAX] = {0, };
- char *dotp = NULL;
- int ret = 0;
+ char cmd[PATH_MAX] = {0, };
+ glusterd_conf_t *priv = NULL;
+
+ GF_ASSERT (THIS);
+ GF_ASSERT (THIS->private);
- if (!(master && slave && gl_workdir)) {
- GF_ASSERT (!master && !slave && !gl_workdir);
- /* extension adjustment mode */
+ priv = THIS->private;
- dotp = strrchr (prmfile, '.');
- if (!dotp++ ||
- /* overflow */
- dotp - prmfile + strlen (ext) + 1 > PATH_MAX)
- return -1;
+ snprintf (cmd, PATH_MAX, GSYNCD_PREFIX"/gsyncd --canonicalize-%surl %s",
+ cann_esc? "escape-": "",name);
- strcpy (dotp, ext);
- return 0;
- }
+ return glusterd_query_extutil (cann, cmd);
+}
- ret = glusterd_get_canon_url (buff, slave, _gf_true);
+int
+glusterd_gsync_get_param_file (char *prmfile, const char *param, char *master,
+ char *slave, char *gl_workdir)
+{
+ char cmd[PATH_MAX] = {0, };
+ glusterd_conf_t *priv = NULL;
- if (ret) {
- gf_log ("", GF_LOG_WARNING, "Unable to cannonicalize slave URL"
- "of %s", slave);
- return -1;
- }
+ GF_ASSERT (THIS);
+ GF_ASSERT (THIS->private);
- snprintf (prmfile, PATH_MAX, "%s/"GEOREP"/%s/%s.%s", gl_workdir, master,
- buff, ext);
+ priv = THIS->private;
- return 0;
+ snprintf (cmd, PATH_MAX,
+ GSYNCD_PREFIX"/gsyncd -c %s/"GSYNC_CONF" :%s %s --config-get %s-file",
+ gl_workdir, master, slave, param);
+
+ return glusterd_query_extutil (prmfile, cmd);
}
static int
@@ -4303,8 +4289,8 @@ glusterd_read_status_file (char *master, char *slave,
GF_ASSERT (THIS->private);
priv = THIS->private;
- ret = glusterd_gsync_get_param_file (statusfile, "status", master,
- slave, priv->workdir);
+ ret = glusterd_gsync_get_param_file (statusfile, "state", master,
+ slave, priv->workdir);
if (ret) {
gf_log ("", GF_LOG_WARNING, "Unable to get the name of status"
"file for %s(master), %s(slave)", master, slave);