From 96b687b9b8d58fc70dfaaed42dbe1b35799117f8 Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Tue, 31 Mar 2009 06:22:16 -0700 Subject: Add new type of option type INTERNET_ADDRESS for validation - used to validate options like remote-host, bind-address. - Also validate options of translators created during fetch of volume specification file from remote server. Signed-off-by: Anand V. Avati --- glusterfsd/src/fetch-spec.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'glusterfsd') diff --git a/glusterfsd/src/fetch-spec.c b/glusterfsd/src/fetch-spec.c index 6f2b991bc7b..f914a416dd4 100644 --- a/glusterfsd/src/fetch-spec.c +++ b/glusterfsd/src/fetch-spec.c @@ -107,16 +107,21 @@ get_shrub (glusterfs_ctx_t *ctx, const char *transport, uint32_t remote_port) { + volume_opt_list_t *vol_opt = NULL; + xlator_t *trav = NULL; int ret = 0; xlator_t *top = NULL; xlator_t *trans = NULL; xlator_list_t *parent = NULL, *tmp = NULL; - + top = CALLOC (1, sizeof (*top)); ERR_ABORT (top); trans = CALLOC (1, sizeof (*trans)); ERR_ABORT (trans); + INIT_LIST_HEAD (&top->volume_options); + INIT_LIST_HEAD (&trans->volume_options); + top->name = "top"; top->ctx = ctx; top->next = trans; @@ -145,9 +150,10 @@ get_shrub (glusterfs_ctx_t *ctx, } /* TODO: log on failure to set dict */ - if (remote_host) - ret = dict_set_static_ptr (trans->options, "remote-host", - (char *)remote_host); + if (remote_host) { + ret = dict_set (trans->options, "remote-host", + str_to_data ((char *)remote_host)); + } if (remote_port) ret = dict_set_uint32 (trans->options, "remote-port", @@ -174,7 +180,25 @@ get_shrub (glusterfs_ctx_t *ctx, } xlator_set_type (trans, "protocol/client"); - + + trav = top; + while (trav) { + /* Get the first volume_option */ + if (!list_empty (&trav->volume_options)) { + list_for_each_entry (vol_opt, + &trav->volume_options, list) + break; + if ((ret = + validate_xlator_volume_options (trav, + vol_opt->given_opt)) < 0) { + gf_log (trav->name, GF_LOG_ERROR, + "validating translator failed"); + return NULL; + } + } + trav = trav->next; + } + if (xlator_tree_init (top) != 0) return NULL; -- cgit