From 643385ea0a8a35a0b008b561add7830dfbe5a35d Mon Sep 17 00:00:00 2001 From: Mike Gerdts Date: Thu, 18 Nov 2021 14:50:41 +0000 Subject: [PATCH] blobcli: uuid xattrs should be printed as strings At the time of commit d1d22046df, xattr UUIDs were stored as strings, not as `struct spdk_uuid`. That continues to be true today. As such, bs_dump_xattr should be treating UUID XATTR values as strings rather than as `struct spdk_uuid`. This fix does verify that the UUID string is a well-formed UUID before printing it. If it is not well-formed, "? Invalid UUID" is printed along with the raw bytes. Signed-off-by: Mike Gerdts Change-Id: I5b574c1c2c4b4802aae3ba23d32ef58fb6fa7586 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11249 Tested-by: SPDK CI Jenkins Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Reviewed-by: Aleksey Marchuk Reviewed-by: Ben Walker Reviewed-by: Paul Luse Reviewed-by: Jim Harris --- examples/blob/cli/blobcli.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/examples/blob/cli/blobcli.c b/examples/blob/cli/blobcli.c index 3ce95d0ca..abdfafa47 100644 --- a/examples/blob/cli/blobcli.c +++ b/examples/blob/cli/blobcli.c @@ -994,11 +994,14 @@ bsdump_print_xattr(FILE *fp, const char *bstype, const char *name, const void *v } else if (strncmp(bstype, "LVOLSTORE", SPDK_BLOBSTORE_TYPE_LENGTH) == 0) { if (strcmp(name, "name") == 0) { fprintf(fp, "%s", (char *)value); - } else if (strcmp(name, "uuid") == 0 && value_len == sizeof(struct spdk_uuid)) { - char uuid[SPDK_UUID_STRING_LEN]; + } else if (strcmp(name, "uuid") == 0) { + struct spdk_uuid uuid; - spdk_uuid_fmt_lower(uuid, sizeof(uuid), (struct spdk_uuid *)value); - fprintf(fp, "%s", uuid); + if (spdk_uuid_parse(&uuid, (const char *)value) == 0) { + fprintf(fp, "%s", (const char *)value); + } else { + fprintf(fp, "? Invalid UUID"); + } } else { fprintf(fp, "?"); }