From 28397cae4102ac3f08576ebaf071ad92683097e8 Mon Sep 17 00:00:00 2001 From: Emmanuel Dreyfus Date: Thu, 2 Apr 2015 15:51:30 +0200 Subject: Avoid conflict between contrib/uuid and system uuid glusterfs relies on Linux uuid implementation, which API is incompatible with most other systems's uuid. As a result, libglusterfs has to embed contrib/uuid, which is the Linux implementation, on non Linux systems. This implementation is incompatible with systtem's built in, but the symbols have the same names. Usually this is not a problem because when we link with -lglusterfs, libc's symbols are trumped. However there is a problem when a program not linked with -lglusterfs will dlopen() glusterfs component. In such a case, libc's uuid implementation is already loaded in the calling program, and it will be used instead of libglusterfs's implementation, causing crashes. A possible workaround is to use pre-load libglusterfs in the calling program (using LD_PRELOAD on NetBSD for instance), but such a mechanism is not portable, nor is it flexible. A much better approach is to rename libglusterfs's uuid_* functions to gf_uuid_* to avoid any possible conflict. This is what this change attempts. BUG: 1206587 Change-Id: I9ccd3e13afed1c7fc18508e92c7beb0f5d49f31a Signed-off-by: Emmanuel Dreyfus Reviewed-on: http://review.gluster.org/10017 Tested-by: Gluster Build System Reviewed-by: Niels de Vos --- libglusterfs/src/xlator.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'libglusterfs/src/xlator.c') diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c index 5b6a4b52e33..c670ee97aee 100644 --- a/libglusterfs/src/xlator.c +++ b/libglusterfs/src/xlator.c @@ -711,9 +711,9 @@ loc_path (loc_t *loc, const char *bname) if (!bname) goto inode_path; - if (loc->parent && !uuid_is_null (loc->parent->gfid)) { + if (loc->parent && !gf_uuid_is_null (loc->parent->gfid)) { ret = inode_path (loc->parent, bname, (char**)&loc->path); - } else if (!uuid_is_null (loc->pargfid)) { + } else if (!gf_uuid_is_null (loc->pargfid)) { ret = gf_asprintf ((char**)&loc->path, INODE_PATH_FMT"/%s", uuid_utoa (loc->pargfid), bname); } @@ -722,9 +722,9 @@ loc_path (loc_t *loc, const char *bname) goto out; inode_path: - if (loc->inode && !uuid_is_null (loc->inode->gfid)) { + if (loc->inode && !gf_uuid_is_null (loc->inode->gfid)) { ret = inode_path (loc->inode, NULL, (char **)&loc->path); - } else if (!uuid_is_null (loc->gfid)) { + } else if (!gf_uuid_is_null (loc->gfid)) { ret = gf_asprintf ((char**)&loc->path, INODE_PATH_FMT, uuid_utoa (loc->gfid)); } @@ -737,14 +737,14 @@ loc_gfid (loc_t *loc, uuid_t gfid) { if (!gfid) goto out; - uuid_clear (gfid); + gf_uuid_clear (gfid); if (!loc) goto out; - else if (!uuid_is_null (loc->gfid)) - uuid_copy (gfid, loc->gfid); - else if (loc->inode && (!uuid_is_null (loc->inode->gfid))) - uuid_copy (gfid, loc->inode->gfid); + else if (!gf_uuid_is_null (loc->gfid)) + gf_uuid_copy (gfid, loc->gfid); + else if (loc->inode && (!gf_uuid_is_null (loc->inode->gfid))) + gf_uuid_copy (gfid, loc->inode->gfid); out: return; } @@ -771,12 +771,12 @@ loc_touchup (loc_t *loc, const char *name) if (path) /*Guaranteed to have trailing '/' */ loc->name = strrchr (path, '/') + 1; - if (uuid_is_null (loc->pargfid)) - uuid_copy (loc->pargfid, loc->parent->gfid); + if (gf_uuid_is_null (loc->pargfid)) + gf_uuid_copy (loc->pargfid, loc->parent->gfid); } else if (loc->inode) { ret = inode_path (loc->inode, 0, &path); - if (uuid_is_null (loc->gfid)) - uuid_copy (loc->gfid, loc->inode->gfid); + if (gf_uuid_is_null (loc->gfid)) + gf_uuid_copy (loc->gfid, loc->inode->gfid); } if (ret < 0 || !path) { @@ -799,8 +799,8 @@ loc_copy_overload_parent (loc_t *dst, loc_t *src, inode_t *parent) GF_VALIDATE_OR_GOTO ("xlator", src, err); GF_VALIDATE_OR_GOTO ("xlator", parent, err); - uuid_copy (dst->gfid, src->gfid); - uuid_copy (dst->pargfid, parent->gfid); + gf_uuid_copy (dst->gfid, src->gfid); + gf_uuid_copy (dst->pargfid, parent->gfid); if (src->inode) dst->inode = inode_ref (src->inode); @@ -839,8 +839,8 @@ loc_copy (loc_t *dst, loc_t *src) GF_VALIDATE_OR_GOTO ("xlator", dst, err); GF_VALIDATE_OR_GOTO ("xlator", src, err); - uuid_copy (dst->gfid, src->gfid); - uuid_copy (dst->pargfid, src->pargfid); + gf_uuid_copy (dst->gfid, src->gfid); + gf_uuid_copy (dst->pargfid, src->pargfid); if (src->inode) dst->inode = inode_ref (src->inode); -- cgit