Commit 643385ea authored by Mike Gerdts's avatar Mike Gerdts Committed by Jim Harris
Browse files

blobcli: uuid xattrs should be printed as strings



At the time of commit d1d22046, 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: default avatarMike Gerdts <mgerdts@nvidia.com>
Change-Id: I5b574c1c2c4b4802aae3ba23d32ef58fb6fa7586
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11249


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarPaul Luse <paul.e.luse@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent d715c82c
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -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, "?");
		}