daemon: add get_random_uuid

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
This commit is contained in:
Chen Hanxiao
2015-06-30 19:23:12 +08:00
committed by Pino Toscano
parent 5166388914
commit d0c067df87
3 changed files with 22 additions and 0 deletions

View File

@@ -97,6 +97,7 @@ dnl iproute has been renamed to iproute2
vim-tiny
xz-utils
zfs-fuse
uuid-runtime
)
ifelse(ARCHLINUX,1,

View File

@@ -152,6 +152,8 @@ extern void udev_settle (void);
extern int random_name (char *template);
extern char *get_random_uuid (void);
/* This just stops gcc from giving a warning about our custom printf
* formatters %Q and %R. See guestfs(3)/EXTENDING LIBGUESTFS for more
* info about these. In GCC 4.8.0 the warning is even harder to

View File

@@ -57,6 +57,7 @@
#include "daemon.h"
GUESTFSD_EXT_CMD(str_udevadm, udevadm);
GUESTFSD_EXT_CMD(str_uuidgen, uuidgen);
#ifndef MAX
# define MAX(a,b) ((a)>(b)?(a):(b))
@@ -1509,6 +1510,24 @@ udev_settle (void)
fprintf (stderr, "warning: udevadm command failed\n");
}
char *
get_random_uuid (void)
{
int r;
char *out;
CLEANUP_FREE char *err = NULL;
r = command (&out, &err, str_uuidgen, NULL);
if (r == -1) {
reply_with_error ("%s", err);
return NULL;
}
/* caller free */
return out;
}
/* Use by the CLEANUP_* macros. Do not call these directly. */
void
cleanup_free (void *ptr)