[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] minios: add xenbus_read_uuid


  • To: xen-changelog@xxxxxxxxxxxxxxxxxxx
  • From: Xen patchbot-unstable <patchbot@xxxxxxx>
  • Date: Tue, 13 Nov 2012 16:22:09 +0000
  • Delivery-date: Tue, 13 Nov 2012 16:22:17 +0000
  • List-id: "Change log for Mercurial \(receive only\)" <xen-changelog.lists.xen.org>

# HG changeset patch
# User Matthew Fioravante <matthew.fioravante@xxxxxxxxxx>
# Date 1352803617 0
# Node ID 3015f8c6174b579ee62ff01cfa177ca33d6dd531
# Parent  14669ca1e53de199cf821ad5ccb47dafec2fc9e6
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@xxxxxxxxxx>
Acked-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxx>
Committed-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---


diff -r 14669ca1e53d -r 3015f8c6174b extras/mini-os/include/xenbus.h
--- a/extras/mini-os/include/xenbus.h   Tue Nov 13 10:46:56 2012 +0000
+++ b/extras/mini-os/include/xenbus.h   Tue Nov 13 10:46:57 2012 +0000
@@ -95,6 +95,10 @@ char *xenbus_transaction_end(xenbus_tran
 /* Read path and parse it as an integer.  Returns -1 on error. */
 int xenbus_read_integer(const char *path);
 
+/* Read path and parse it as 16 byte uuid. Returns 1 if
+ * read and parsing were successful, 0 if not */
+int xenbus_read_uuid(const char* path, unsigned char uuid[16]);
+
 /* Contraction of snprintf and xenbus_write(path/node). */
 char* xenbus_printf(xenbus_transaction_t xbt,
                                   const char* node, const char* path,
diff -r 14669ca1e53d -r 3015f8c6174b extras/mini-os/xenbus/xenbus.c
--- a/extras/mini-os/xenbus/xenbus.c    Tue Nov 13 10:46:56 2012 +0000
+++ b/extras/mini-os/xenbus/xenbus.c    Tue Nov 13 10:46:57 2012 +0000
@@ -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, ...)

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.