diff options
| author | Pranith Kumar K <pkarampu@redhat.com> | 2015-02-25 11:37:57 +0530 | 
|---|---|---|
| committer | Vijay Bellur <vbellur@redhat.com> | 2015-02-27 01:28:35 -0800 | 
| commit | d5624b2d4baf509ad8d6037a0d9cabf9cd5ab1c5 (patch) | |
| tree | a5f257e370606282a1f9c98418e48c466077e5f3 /libglusterfs/src/common-utils.c | |
| parent | 6a77db6d19dba5367c02cbf2a5883ac49cef94e2 (diff) | |
libglusterfs: Moved common functions as utils in syncop/common-utils
These will be used by both afr and ec. Moved syncop_dirfd, syncop_ftw,
syncop_dir_scan functions also into syncop-utils.c
Change-Id: I467253c74a346e1e292d36a8c1a035775c3aa670
BUG: 1177601
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: http://review.gluster.org/9740
Reviewed-by: Krutika Dhananjay <kdhananj@redhat.com>
Reviewed-by: Anuradha Talur <atalur@redhat.com>
Reviewed-by: Ravishankar N <ravishankar@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'libglusterfs/src/common-utils.c')
| -rw-r--r-- | libglusterfs/src/common-utils.c | 51 | 
1 files changed, 51 insertions, 0 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index 39da27d83dd..cfbf3191eef 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -3648,3 +3648,54 @@ gf_get_index_by_elem (char **array, char *elem)          return -1;  } + +static int +get_pathinfo_host (char *pathinfo, char *hostname, size_t size) +{ +        char    *start = NULL; +        char    *end = NULL; +        int     ret  = -1; +        int     i    = 0; + +        if (!pathinfo) +                goto out; + +        start = strchr (pathinfo, ':'); +        if (!start) +                goto out; + +        end = strrchr (pathinfo, ':'); +        if (start == end) +                goto out; + +        memset (hostname, 0, size); +        i = 0; +        while (++start != end) +                hostname[i++] = *start; +        ret = 0; +out: +        return ret; +} + +/*Note: 'pathinfo' should be gathered only from one brick*/ +int +glusterfs_is_local_pathinfo (char *pathinfo, gf_boolean_t *is_local) +{ +        int             ret   = 0; +        char            pathinfohost[1024] = {0}; +        char            localhost[1024] = {0}; + +        *is_local = _gf_false; +        ret = get_pathinfo_host (pathinfo, pathinfohost, sizeof (pathinfohost)); +        if (ret) +                goto out; + +        ret = gethostname (localhost, sizeof (localhost)); +        if (ret) +                goto out; + +        if (!strcmp (localhost, pathinfohost)) +                *is_local = _gf_true; +out: +        return ret; +}  | 
