diff options
author | Emmanuel Dreyfus <manu@netbsd.org> | 2015-04-02 15:51:30 +0200 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2015-04-04 10:48:35 -0700 |
commit | 28397cae4102ac3f08576ebaf071ad92683097e8 (patch) | |
tree | 4c8be92299a951c8a28e1dc85bf2671f60da6e08 /contrib/uuid/tst_uuid.c | |
parent | 0aebfaa349c7c68c2d59531eabae5a03a748e16a (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/tst_uuid.c')
-rw-r--r-- | contrib/uuid/tst_uuid.c | 36 |
1 files changed, 18 insertions, 18 deletions
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"); |