summaryrefslogtreecommitdiffstats
path: root/contrib/uuid/uuid_time.c
diff options
context:
space:
mode:
authorEmmanuel Dreyfus <manu@netbsd.org>2015-04-02 15:51:30 +0200
committerVijay Bellur <vbellur@redhat.com>2015-04-04 10:48:35 -0700
commit28397cae4102ac3f08576ebaf071ad92683097e8 (patch)
tree4c8be92299a951c8a28e1dc85bf2671f60da6e08 /contrib/uuid/uuid_time.c
parent0aebfaa349c7c68c2d59531eabae5a03a748e16a (diff)
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 <manu@netbsd.org> Reviewed-on: http://review.gluster.org/10017 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Niels de Vos <ndevos@redhat.com>
Diffstat (limited to 'contrib/uuid/uuid_time.c')
-rw-r--r--contrib/uuid/uuid_time.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/contrib/uuid/uuid_time.c b/contrib/uuid/uuid_time.c
index ccaa542fed0..35f727018b1 100644
--- a/contrib/uuid/uuid_time.c
+++ b/contrib/uuid/uuid_time.c
@@ -54,7 +54,7 @@
#include "uuidP.h"
#include "logging.h"
-time_t uuid_time(const uuid_t uu, struct timeval *ret_tv)
+time_t gf_uuid_time(const uuid_t uu, struct timeval *ret_tv)
{
struct timeval tv;
struct uuid uuid;
@@ -76,7 +76,7 @@ time_t uuid_time(const uuid_t uu, struct timeval *ret_tv)
return tv.tv_sec;
}
-int uuid_type(const uuid_t uu)
+int gf_uuid_type(const uuid_t uu)
{
struct uuid uuid;
@@ -84,7 +84,7 @@ int uuid_type(const uuid_t uu)
return ((uuid.time_hi_and_version >> 12) & 0xF);
}
-int uuid_variant(const uuid_t uu)
+int gf_uuid_variant(const uuid_t uu)
{
struct uuid uuid;
int var;
@@ -129,13 +129,13 @@ main(int argc, char **argv)
fprintf(stderr, "Usage: %s uuid\n", argv[0]);
exit(1);
}
- if (uuid_parse(argv[1], buf)) {
+ if (gf_uuid_parse(argv[1], buf)) {
fprintf(stderr, "Invalid UUID: %s\n", argv[1]);
exit(1);
}
- variant = uuid_variant(buf);
- type = uuid_type(buf);
- time_reg = uuid_time(buf, &tv);
+ variant = gf_uuid_variant(buf);
+ type = gf_uuid_type(buf);
+ time_reg = gf_uuid_time(buf, &tv);
printf("UUID variant is %d (%s)\n", variant, variant_string(variant));
if (variant != UUID_VARIANT_DCE) {