summaryrefslogtreecommitdiffstats
path: root/shlibs/blkid/src/probe.c
diff options
context:
space:
mode:
authorKarel Zak2009-09-15 20:36:46 +0200
committerKarel Zak2009-09-15 20:36:46 +0200
commit201529bd71b0a20f2303be4f0b839af59ecf43c2 (patch)
treedb95436db89c4b89c49b3217e5b93a553f6a7b08 /shlibs/blkid/src/probe.c
parentlibblkid: use superblocks.h (diff)
downloadkernel-qcow2-util-linux-201529bd71b0a20f2303be4f0b839af59ecf43c2.tar.gz
kernel-qcow2-util-linux-201529bd71b0a20f2303be4f0b839af59ecf43c2.tar.xz
kernel-qcow2-util-linux-201529bd71b0a20f2303be4f0b839af59ecf43c2.zip
libblkid: create a generic blkid_unparse_uuid()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs/blkid/src/probe.c')
-rw-r--r--shlibs/blkid/src/probe.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/shlibs/blkid/src/probe.c b/shlibs/blkid/src/probe.c
index 4677389ec..1b7d4b8b3 100644
--- a/shlibs/blkid/src/probe.c
+++ b/shlibs/blkid/src/probe.c
@@ -862,21 +862,9 @@ int blkid_probe_set_uuid_as(blkid_probe pr, unsigned char *uuid, const char *nam
} else
v = blkid_probe_assign_value(pr, name);
-#ifdef HAVE_LIBUUID
- {
- uuid_unparse(uuid, (char *) v->data);
- v->len = 37;
- }
-#else
- v->len = snprintf(v->data, sizeof(v->data),
- "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
- uuid[0], 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]);
- v->len++;
-#endif
+ blkid_unparse_uuid(uuid, (char *) v->data, sizeof(v->data));
+ v->len = 37;
+
return 0;
}
@@ -935,3 +923,21 @@ int blkid_probe_has_value(blkid_probe pr, const char *name)
return 0;
}
+
+/* converts DCE UUID (uuid[16]) to human readable string
+ * - the @len should be always 37 */
+void blkid_unparse_uuid(const unsigned char *uuid, char *str, size_t len)
+{
+#ifdef HAVE_LIBUUID
+ uuid_unparse(uuid, str);
+#else
+ snprintf(str, len,
+ "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+ uuid[0], 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]);
+#endif
+}
+