blob: blobcli should dump XATTR_INTERNAL
Refactor the code that dumps XATTR into a function. Call this function for XATTR and XATTR_INTERNAL. Signed-off-by: Mike Gerdts <mgerdts@nvidia.com> Change-Id: Ic0cb32b14f7a34e030a48e1ea468ec63172e2bf1 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11256 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: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Paul Luse <paul.e.luse@intel.com>
This commit is contained in:
parent
ab2aad8553
commit
7caa514f3c
@ -4548,6 +4548,50 @@ bs_dump_finish(spdk_bs_sequence_t *seq, struct spdk_bs_load_ctx *ctx, int bserrn
|
||||
free(ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
bs_dump_print_xattr(struct spdk_bs_load_ctx *ctx, struct spdk_blob_md_descriptor *desc)
|
||||
{
|
||||
struct spdk_blob_md_descriptor_xattr *desc_xattr;
|
||||
uint32_t i;
|
||||
const char *type;
|
||||
|
||||
desc_xattr = (struct spdk_blob_md_descriptor_xattr *)desc;
|
||||
|
||||
if (desc_xattr->length !=
|
||||
sizeof(desc_xattr->name_length) + sizeof(desc_xattr->value_length) +
|
||||
desc_xattr->name_length + desc_xattr->value_length) {
|
||||
}
|
||||
|
||||
memcpy(ctx->xattr_name, desc_xattr->name, desc_xattr->name_length);
|
||||
ctx->xattr_name[desc_xattr->name_length] = '\0';
|
||||
if (desc->type == SPDK_MD_DESCRIPTOR_TYPE_XATTR) {
|
||||
type = "XATTR";
|
||||
} else if (desc->type == SPDK_MD_DESCRIPTOR_TYPE_XATTR_INTERNAL) {
|
||||
type = "XATTR_INTERNAL";
|
||||
} else {
|
||||
assert(false);
|
||||
type = "XATTR_?";
|
||||
}
|
||||
fprintf(ctx->fp, "%s: name = \"%s\"\n", type, ctx->xattr_name);
|
||||
fprintf(ctx->fp, " value = \"");
|
||||
ctx->print_xattr_fn(ctx->fp, ctx->super->bstype.bstype, ctx->xattr_name,
|
||||
(void *)((uintptr_t)desc_xattr->name + desc_xattr->name_length),
|
||||
desc_xattr->value_length);
|
||||
fprintf(ctx->fp, "\"\n");
|
||||
for (i = 0; i < desc_xattr->value_length; i++) {
|
||||
if (i % 16 == 0) {
|
||||
fprintf(ctx->fp, " ");
|
||||
}
|
||||
fprintf(ctx->fp, "%02" PRIx8 " ", *((uint8_t *)desc_xattr->name + desc_xattr->name_length + i));
|
||||
if ((i + 1) % 16 == 0) {
|
||||
fprintf(ctx->fp, "\n");
|
||||
}
|
||||
}
|
||||
if (i % 16 != 0) {
|
||||
fprintf(ctx->fp, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
bs_dump_print_md_page(struct spdk_bs_load_ctx *ctx)
|
||||
{
|
||||
@ -4617,38 +4661,9 @@ bs_dump_print_md_page(struct spdk_bs_load_ctx *ctx)
|
||||
fprintf(ctx->fp, "\n");
|
||||
}
|
||||
} else if (desc->type == SPDK_MD_DESCRIPTOR_TYPE_XATTR) {
|
||||
struct spdk_blob_md_descriptor_xattr *desc_xattr;
|
||||
uint32_t i;
|
||||
|
||||
desc_xattr = (struct spdk_blob_md_descriptor_xattr *)desc;
|
||||
|
||||
if (desc_xattr->length !=
|
||||
sizeof(desc_xattr->name_length) + sizeof(desc_xattr->value_length) +
|
||||
desc_xattr->name_length + desc_xattr->value_length) {
|
||||
}
|
||||
|
||||
memcpy(ctx->xattr_name, desc_xattr->name, desc_xattr->name_length);
|
||||
ctx->xattr_name[desc_xattr->name_length] = '\0';
|
||||
fprintf(ctx->fp, "XATTR: name = \"%s\"\n", ctx->xattr_name);
|
||||
fprintf(ctx->fp, " value = \"");
|
||||
ctx->print_xattr_fn(ctx->fp, ctx->super->bstype.bstype, ctx->xattr_name,
|
||||
(void *)((uintptr_t)desc_xattr->name + desc_xattr->name_length),
|
||||
desc_xattr->value_length);
|
||||
fprintf(ctx->fp, "\"\n");
|
||||
for (i = 0; i < desc_xattr->value_length; i++) {
|
||||
if (i % 16 == 0) {
|
||||
fprintf(ctx->fp, " ");
|
||||
}
|
||||
fprintf(ctx->fp, "%02" PRIx8 " ", *((uint8_t *)desc_xattr->name + desc_xattr->name_length + i));
|
||||
if ((i + 1) % 16 == 0) {
|
||||
fprintf(ctx->fp, "\n");
|
||||
}
|
||||
}
|
||||
if (i % 16 != 0) {
|
||||
fprintf(ctx->fp, "\n");
|
||||
}
|
||||
bs_dump_print_xattr(ctx, desc);
|
||||
} else if (desc->type == SPDK_MD_DESCRIPTOR_TYPE_XATTR_INTERNAL) {
|
||||
/* TODO */
|
||||
bs_dump_print_xattr(ctx, desc);
|
||||
} else if (desc->type == SPDK_MD_DESCRIPTOR_TYPE_FLAGS) {
|
||||
/* TODO */
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user