summaryrefslogtreecommitdiffstats
path: root/contrib/uuid
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
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')
-rw-r--r--contrib/uuid/clear.c2
-rw-r--r--contrib/uuid/compare.c2
-rw-r--r--contrib/uuid/copy.c2
-rw-r--r--contrib/uuid/gen_uuid.c14
-rw-r--r--contrib/uuid/gen_uuid_nt.c2
-rw-r--r--contrib/uuid/isnull.c2
-rw-r--r--contrib/uuid/parse.c2
-rw-r--r--contrib/uuid/tst_uuid.c36
-rw-r--r--contrib/uuid/unparse.c14
-rw-r--r--contrib/uuid/uuid.h28
-rw-r--r--contrib/uuid/uuid_time.c14
11 files changed, 59 insertions, 59 deletions
diff --git a/contrib/uuid/clear.c b/contrib/uuid/clear.c
index 2d91fee9399..0362d073e3d 100644
--- a/contrib/uuid/clear.c
+++ b/contrib/uuid/clear.c
@@ -36,7 +36,7 @@
#include "uuidP.h"
-void uuid_clear(uuid_t uu)
+void gf_uuid_clear(uuid_t uu)
{
memset(uu, 0, 16);
}
diff --git a/contrib/uuid/compare.c b/contrib/uuid/compare.c
index f28a72678cf..dba4c5bf8cf 100644
--- a/contrib/uuid/compare.c
+++ b/contrib/uuid/compare.c
@@ -39,7 +39,7 @@
#define UUCMP(u1,u2) if (u1 != u2) return((u1 < u2) ? -1 : 1);
-int uuid_compare(const uuid_t uu1, const uuid_t uu2)
+int gf_uuid_compare(const uuid_t uu1, const uuid_t uu2)
{
struct uuid uuid1, uuid2;
diff --git a/contrib/uuid/copy.c b/contrib/uuid/copy.c
index ead33aa26e8..45983bfd48b 100644
--- a/contrib/uuid/copy.c
+++ b/contrib/uuid/copy.c
@@ -34,7 +34,7 @@
#include "uuidP.h"
-void uuid_copy(uuid_t dst, const uuid_t src)
+void gf_uuid_copy(uuid_t dst, const uuid_t src)
{
unsigned char *cp1;
const unsigned char *cp2;
diff --git a/contrib/uuid/gen_uuid.c b/contrib/uuid/gen_uuid.c
index 4da0dc69b84..1ec156f76ff 100644
--- a/contrib/uuid/gen_uuid.c
+++ b/contrib/uuid/gen_uuid.c
@@ -595,7 +595,7 @@ void uuid__generate_time(uuid_t out, int *num)
uuid_pack(&uu, out);
}
-void uuid_generate_time(uuid_t out)
+void gf_uuid_generate_time(uuid_t out)
{
#ifdef TLS
THREAD_LOCAL int num = 0;
@@ -662,7 +662,7 @@ void uuid__generate_random(uuid_t out, int *num)
}
}
-void uuid_generate_random(uuid_t out)
+void gf_uuid_generate_random(uuid_t out)
{
int num = 1;
/* No real reason to use the daemon for random uuid's -- yet */
@@ -672,15 +672,15 @@ void uuid_generate_random(uuid_t out)
/*
- * This is the generic front-end to uuid_generate_random and
- * uuid_generate_time. It uses uuid_generate_random only if
+ * This is the generic front-end to gf_uuid_generate_random and
+ * gf_uuid_generate_time. It uses gf_uuid_generate_random only if
* /dev/urandom is available, since otherwise we won't have
* high-quality randomness.
*/
-void uuid_generate(uuid_t out)
+void gf_uuid_generate(uuid_t out)
{
if (get_random_fd() >= 0)
- uuid_generate_random(out);
+ gf_uuid_generate_random(out);
else
- uuid_generate_time(out);
+ gf_uuid_generate_time(out);
}
diff --git a/contrib/uuid/gen_uuid_nt.c b/contrib/uuid/gen_uuid_nt.c
index aa44bfd3d7d..91828b7a13b 100644
--- a/contrib/uuid/gen_uuid_nt.c
+++ b/contrib/uuid/gen_uuid_nt.c
@@ -78,7 +78,7 @@ Nt5(void)
-void uuid_generate(uuid_t out)
+void gf_uuid_generate(uuid_t out)
{
if(Nt5())
{
diff --git a/contrib/uuid/isnull.c b/contrib/uuid/isnull.c
index 931e7e7dba2..20d8fcef6da 100644
--- a/contrib/uuid/isnull.c
+++ b/contrib/uuid/isnull.c
@@ -35,7 +35,7 @@
#include "uuidP.h"
/* Returns 1 if the uuid is the NULL uuid */
-int uuid_is_null(const uuid_t uu)
+int gf_uuid_is_null(const uuid_t uu)
{
const unsigned char *cp;
int i;
diff --git a/contrib/uuid/parse.c b/contrib/uuid/parse.c
index 074383efae7..059ae437805 100644
--- a/contrib/uuid/parse.c
+++ b/contrib/uuid/parse.c
@@ -39,7 +39,7 @@
#include "uuidP.h"
-int uuid_parse(const char *in, uuid_t uu)
+int gf_uuid_parse(const char *in, uuid_t uu)
{
struct uuid uuid;
int i;
diff --git a/contrib/uuid/tst_uuid.c b/contrib/uuid/tst_uuid.c
index e03138f7d18..865564b0c34 100644
--- a/contrib/uuid/tst_uuid.c
+++ b/contrib/uuid/tst_uuid.c
@@ -49,11 +49,11 @@ static int test_uuid(const char * uuid, int isValid)
uuid_t uuidBits;
int parsedOk;
- parsedOk = uuid_parse(uuid, uuidBits) == 0;
+ parsedOk = gf_uuid_parse(uuid, uuidBits) == 0;
printf("%s is %s", uuid, validStr[isValid]);
if (parsedOk != isValid) {
- printf(" but uuid_parse says %s\n", validStr[parsedOk]);
+ printf(" but gf_uuid_parse says %s\n", validStr[parsedOk]);
return 1;
}
printf(", OK\n");
@@ -78,15 +78,15 @@ main(int argc ATTR((unused)) , char **argv ATTR((unused)))
int failed = 0;
int type, variant;
- uuid_generate(buf);
- uuid_unparse(buf, str);
+ gf_uuid_generate(buf);
+ gf_uuid_unparse(buf, str);
printf("UUID generate = %s\n", str);
printf("UUID: ");
for (i=0, cp = (unsigned char *) &buf; i < 16; i++) {
printf("%02x", *cp++);
}
printf("\n");
- type = uuid_type(buf); variant = uuid_variant(buf);
+ type = gf_uuid_type(buf); variant = gf_uuid_variant(buf);
printf("UUID type = %d, UUID variant = %d\n", type, variant);
if (variant != UUID_VARIANT_DCE) {
printf("Incorrect UUID Variant; was expecting DCE!\n");
@@ -94,15 +94,15 @@ main(int argc ATTR((unused)) , char **argv ATTR((unused)))
}
printf("\n");
- uuid_generate_random(buf);
- uuid_unparse(buf, str);
+ gf_uuid_generate_random(buf);
+ gf_uuid_unparse(buf, str);
printf("UUID random string = %s\n", str);
printf("UUID: ");
for (i=0, cp = (unsigned char *) &buf; i < 16; i++) {
printf("%02x", *cp++);
}
printf("\n");
- type = uuid_type(buf); variant = uuid_variant(buf);
+ type = gf_uuid_type(buf); variant = gf_uuid_variant(buf);
printf("UUID type = %d, UUID variant = %d\n", type, variant);
if (variant != UUID_VARIANT_DCE) {
printf("Incorrect UUID Variant; was expecting DCE!\n");
@@ -115,15 +115,15 @@ main(int argc ATTR((unused)) , char **argv ATTR((unused)))
}
printf("\n");
- uuid_generate_time(buf);
- uuid_unparse(buf, str);
+ gf_uuid_generate_time(buf);
+ gf_uuid_unparse(buf, str);
printf("UUID string = %s\n", str);
printf("UUID time: ");
for (i=0, cp = (unsigned char *) &buf; i < 16; i++) {
printf("%02x", *cp++);
}
printf("\n");
- type = uuid_type(buf); variant = uuid_variant(buf);
+ type = gf_uuid_type(buf); variant = gf_uuid_variant(buf);
printf("UUID type = %d, UUID variant = %d\n", type, variant);
if (variant != UUID_VARIANT_DCE) {
printf("Incorrect UUID Variant; was expecting DCE!\n");
@@ -136,25 +136,25 @@ main(int argc ATTR((unused)) , char **argv ATTR((unused)))
}
tv.tv_sec = 0;
tv.tv_usec = 0;
- time_reg = uuid_time(buf, &tv);
+ time_reg = gf_uuid_time(buf, &tv);
printf("UUID time is: (%ld, %ld): %s\n", tv.tv_sec, tv.tv_usec,
ctime(&time_reg));
- uuid_parse(str, tst);
- if (!uuid_compare(buf, tst))
+ gf_uuid_parse(str, tst);
+ if (!gf_uuid_compare(buf, tst))
printf("UUID parse and compare succeeded.\n");
else {
printf("UUID parse and compare failed!\n");
failed++;
}
- uuid_clear(tst);
- if (uuid_is_null(tst))
+ gf_uuid_clear(tst);
+ if (gf_uuid_is_null(tst))
printf("UUID clear and is null succeeded.\n");
else {
printf("UUID clear and is null failed!\n");
failed++;
}
- uuid_copy(buf, tst);
- if (!uuid_compare(buf, tst))
+ gf_uuid_copy(buf, tst);
+ if (!gf_uuid_compare(buf, tst))
printf("UUID copy and compare succeeded.\n");
else {
printf("UUID copy and compare failed!\n");
diff --git a/contrib/uuid/unparse.c b/contrib/uuid/unparse.c
index a95bbb04258..f6e29534140 100644
--- a/contrib/uuid/unparse.c
+++ b/contrib/uuid/unparse.c
@@ -48,7 +48,7 @@ static const char *fmt_upper =
#define FMT_DEFAULT fmt_lower
#endif
-static void uuid_unparse_x(const uuid_t uu, char *out, const char *fmt)
+static void gf_uuid_unparse_x(const uuid_t uu, char *out, const char *fmt)
{
struct uuid uuid;
@@ -60,17 +60,17 @@ static void uuid_unparse_x(const uuid_t uu, char *out, const char *fmt)
uuid.node[3], uuid.node[4], uuid.node[5]);
}
-void uuid_unparse_lower(const uuid_t uu, char *out)
+void gf_uuid_unparse_lower(const uuid_t uu, char *out)
{
- uuid_unparse_x(uu, out, fmt_lower);
+ gf_uuid_unparse_x(uu, out, fmt_lower);
}
-void uuid_unparse_upper(const uuid_t uu, char *out)
+void gf_uuid_unparse_upper(const uuid_t uu, char *out)
{
- uuid_unparse_x(uu, out, fmt_upper);
+ gf_uuid_unparse_x(uu, out, fmt_upper);
}
-void uuid_unparse(const uuid_t uu, char *out)
+void gf_uuid_unparse(const uuid_t uu, char *out)
{
- uuid_unparse_x(uu, out, FMT_DEFAULT);
+ gf_uuid_unparse_x(uu, out, FMT_DEFAULT);
}
diff --git a/contrib/uuid/uuid.h b/contrib/uuid/uuid.h
index ab006652fc0..97de360ad52 100644
--- a/contrib/uuid/uuid.h
+++ b/contrib/uuid/uuid.h
@@ -68,34 +68,34 @@ extern "C" {
#endif
/* clear.c */
-void uuid_clear(uuid_t uu);
+void gf_uuid_clear(uuid_t uu);
/* compare.c */
-int uuid_compare(const uuid_t uu1, const uuid_t uu2);
+int gf_uuid_compare(const uuid_t uu1, const uuid_t uu2);
/* copy.c */
-void uuid_copy(uuid_t dst, const uuid_t src);
+void gf_uuid_copy(uuid_t dst, const uuid_t src);
/* gen_uuid.c */
-void uuid_generate(uuid_t out);
-void uuid_generate_random(uuid_t out);
-void uuid_generate_time(uuid_t out);
+void gf_uuid_generate(uuid_t out);
+void gf_uuid_generate_random(uuid_t out);
+void gf_uuid_generate_time(uuid_t out);
/* isnull.c */
-int uuid_is_null(const uuid_t uu);
+int gf_uuid_is_null(const uuid_t uu);
/* parse.c */
-int uuid_parse(const char *in, uuid_t uu);
+int gf_uuid_parse(const char *in, uuid_t uu);
/* unparse.c */
-void uuid_unparse(const uuid_t uu, char *out);
-void uuid_unparse_lower(const uuid_t uu, char *out);
-void uuid_unparse_upper(const uuid_t uu, char *out);
+void gf_uuid_unparse(const uuid_t uu, char *out);
+void gf_uuid_unparse_lower(const uuid_t uu, char *out);
+void gf_uuid_unparse_upper(const uuid_t uu, char *out);
/* uuid_time.c */
-time_t uuid_time(const uuid_t uu, struct timeval *ret_tv);
-int uuid_type(const uuid_t uu);
-int uuid_variant(const uuid_t uu);
+time_t gf_uuid_time(const uuid_t uu, struct timeval *ret_tv);
+int gf_uuid_type(const uuid_t uu);
+int gf_uuid_variant(const uuid_t uu);
#ifdef __cplusplus
}
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) {