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 <mgerdts@nvidia.com>
Change-Id: I5b574c1c2c4b4802aae3ba23d32ef58fb6fa7586
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11249
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Mike Gerdts 2021-11-18 14:50:41 +00:00 committed by Jim Harris
parent d715c82cc6
commit 643385ea0a

View File

@ -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, "?");
}