Added dynamic support for uuid_generate when creating VHDs on *nix platforms.
This commit is contained in:
parent
db7e04e0df
commit
a808ca561c
1 changed files with 17 additions and 4 deletions
21
sim_disk.c
21
sim_disk.c
|
@ -2609,7 +2609,7 @@ RPC_STATUS
|
||||||
|
|
||||||
if (!UuidCreate_c) {
|
if (!UuidCreate_c) {
|
||||||
HINSTANCE hDll;
|
HINSTANCE hDll;
|
||||||
hDll = LoadLibrary("rpcrt4.dll");
|
hDll = LoadLibraryA("rpcrt4.dll");
|
||||||
UuidCreate_c = (void *)GetProcAddress(hDll, "UuidCreate");
|
UuidCreate_c = (void *)GetProcAddress(hDll, "UuidCreate");
|
||||||
}
|
}
|
||||||
if (UuidCreate_c)
|
if (UuidCreate_c)
|
||||||
|
@ -2617,13 +2617,26 @@ if (UuidCreate_c)
|
||||||
else
|
else
|
||||||
_rand_uuid_gen (uuidaddr);
|
_rand_uuid_gen (uuidaddr);
|
||||||
}
|
}
|
||||||
#elif defined (USE_LIBUUID)
|
#elif defined (HAVE_DLOPEN)
|
||||||
#include <uuid/uuid.h>
|
#include <dlfcn.h>
|
||||||
|
|
||||||
static void
|
static void
|
||||||
uuid_gen (void *uuidaddr)
|
uuid_gen (void *uuidaddr)
|
||||||
{
|
{
|
||||||
uuid_generate((uuid_t)uuidaddr);
|
void (*uuid_generate_c) (void *) = NULL;
|
||||||
|
void *handle;
|
||||||
|
|
||||||
|
#define __STR_QUOTE(tok) #tok
|
||||||
|
#define __STR(tok) __STR_QUOTE(tok)
|
||||||
|
handle = dlopen("libuuid." __STR(HAVE_DLOPEN), RTLD_NOW|RTLD_GLOBAL);
|
||||||
|
if (handle)
|
||||||
|
uuid_generate_c = dlsym(handle, "uuid_generate");
|
||||||
|
if (uuid_generate_c)
|
||||||
|
uuid_generate_c(uuidaddr);
|
||||||
|
else
|
||||||
|
_rand_uuid_gen (uuidaddr);
|
||||||
|
if (handle)
|
||||||
|
dlclose(handle);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Add table
Reference in a new issue