summaryrefslogtreecommitdiff
path: root/extras/volume_id/lib/util.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2007-05-04 16:53:19 +0200
committerKay Sievers <kay.sievers@vrfy.org>2007-05-04 16:53:19 +0200
commit444f07fea49bc40207df5e7910907492529b9bce (patch)
treec54872eaf90a67929db5e87c62938198948b32a3 /extras/volume_id/lib/util.c
parentee466b321e5f4bb9f587f65ed05c87a51bc6fef2 (diff)
volume_id: add internal UUID_STRING
Diffstat (limited to 'extras/volume_id/lib/util.c')
-rw-r--r--extras/volume_id/lib/util.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/extras/volume_id/lib/util.c b/extras/volume_id/lib/util.c
index 762e84e170..d65fc2c1d6 100644
--- a/extras/volume_id/lib/util.c
+++ b/extras/volume_id/lib/util.c
@@ -115,11 +115,14 @@ void volume_id_set_label_unicode16(struct volume_id *id, const uint8_t *buf, enu
volume_id_set_unicode16(id->label, sizeof(id->label), buf, endianess, count);
}
-void volume_id_set_uuid(struct volume_id *id, const uint8_t *buf, enum uuid_format format)
+void volume_id_set_uuid(struct volume_id *id, const uint8_t *buf, size_t len, enum uuid_format format)
{
unsigned int i;
unsigned int count = 0;
+ if (len > sizeof(id->uuid_raw))
+ len = sizeof(id->uuid_raw);
+
switch(format) {
case UUID_DOS:
count = 4;
@@ -131,8 +134,11 @@ void volume_id_set_uuid(struct volume_id *id, const uint8_t *buf, enum uuid_form
case UUID_DCE:
count = 16;
break;
- case UUID_DCE_STRING:
- count = 36;
+ case UUID_HEX_STRING:
+ count = len;
+ break;
+ case UUID_STRING:
+ count = len;
break;
case UUID_FOURINT:
count = 35;
@@ -172,7 +178,12 @@ set:
buf[8], buf[9],
buf[10], buf[11], buf[12], buf[13], buf[14],buf[15]);
break;
- case UUID_DCE_STRING:
+ case UUID_HEX_STRING:
+ for (i = 0; i < count; i++)
+ id->uuid[i] = tolower(buf[i]);
+ id->uuid[count] = '\0';
+ break;
+ case UUID_STRING:
memcpy(id->uuid, buf, count);
id->uuid[count] = '\0';
break;