diff options
author | Matthew Fioravante <matthew.fioravante@jhuapl.edu> | 2012-11-13 10:46:57 +0000 |
---|---|---|
committer | Matthew Fioravante <matthew.fioravante@jhuapl.edu> | 2012-11-13 10:46:57 +0000 |
commit | a8e67280ca51dea574c05779df349294338a9fd4 (patch) | |
tree | 3fd90a123560ff2cd06c6e7ad053be8041967560 /extras/mini-os/xenbus | |
parent | d9740f716d02ef6513b77cf8ebef3146b6fd6173 (diff) | |
download | xen-a8e67280ca51dea574c05779df349294338a9fd4.tar.gz xen-a8e67280ca51dea574c05779df349294338a9fd4.tar.bz2 xen-a8e67280ca51dea574c05779df349294338a9fd4.zip |
minios: add xenbus_read_uuid
Similar to xenbus_read_integer, this function reads a xenstore path
and parses it as a uuid. See include/xenbus.h for details.
Signed-off-by: Matthew Fioravante <matthew.fioravante@jhuapl.edu>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
Diffstat (limited to 'extras/mini-os/xenbus')
-rw-r--r-- | extras/mini-os/xenbus/xenbus.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/extras/mini-os/xenbus/xenbus.c b/extras/mini-os/xenbus/xenbus.c index 8c899f3a40..ee1691b858 100644 --- a/extras/mini-os/xenbus/xenbus.c +++ b/extras/mini-os/xenbus/xenbus.c @@ -719,6 +719,33 @@ int xenbus_read_integer(const char *path) return t; } +int xenbus_read_uuid(const char* path, unsigned char uuid[16]) { + char * res, *buf; + res = xenbus_read(XBT_NIL, path, &buf); + if(res) { + printk("Failed to read %s.\n", path); + free(res); + return 0; + } + if(strlen(buf) != ((2*16)+4) /* 16 hex bytes and 4 hyphens */ + || sscanf(buf, + "%2hhx%2hhx%2hhx%2hhx-" + "%2hhx%2hhx-" + "%2hhx%2hhx-" + "%2hhx%2hhx-" + "%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx", + uuid, uuid + 1, uuid + 2, uuid + 3, + uuid + 4, uuid + 5, uuid + 6, uuid + 7, + uuid + 8, uuid + 9, uuid + 10, uuid + 11, + uuid + 12, uuid + 13, uuid + 14, uuid + 15) != 16) { + printk("Xenbus path %s value %s is not a uuid!\n", path, buf); + free(buf); + return 0; + } + free(buf); + return 1; +} + char* xenbus_printf(xenbus_transaction_t xbt, const char* node, const char* path, const char* fmt, ...) |