Skip to content

Commit

Permalink
Add SA xattr debugging.
Browse files Browse the repository at this point in the history
  • Loading branch information
dweeezil committed Dec 17, 2013
1 parent c2d439d commit 803578e
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion cmd/zdb/zdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1394,17 +1394,26 @@ dump_uidgid(objset_t *os, uint64_t uid, uint64_t gid)
print_idstr(gid, "gid");
}

void
octdump(void *ptr, int cnt) {
unsigned char *s = ptr;
while (cnt-- > 0)
printf("\\%3.3o", *s++);
}

static void
dump_znode_sa_xattr(sa_handle_t *hdl)
{
nvlist_t *sa_xattr;
nvlist_t *sa_xattr = NULL;
nvpair_t *elem = NULL;
int sa_xattr_size = 0;
int sa_xattr_entries = 0;
int error;
char *sa_xattr_packed;

error = sa_size(hdl, sa_attr_table[ZPL_DXATTR], &sa_xattr_size);
if (dump_opt['d'] > 4)
printf("\t%s: sa_xattr_size=%d sa_size error=%d\n", __FUNCTION__, sa_xattr_size, error);
if (error || sa_xattr_size == 0)
return;

Expand All @@ -1419,8 +1428,20 @@ dump_znode_sa_xattr(sa_handle_t *hdl)
return;
}

if (dump_opt['d'] > 5) {
printf("\tSA packed dump sa_xattr_size=%d: ", sa_xattr_size);
octdump(sa_xattr_packed, sa_xattr_size);
printf("\n");
}

error = nvlist_unpack(sa_xattr_packed, sa_xattr_size, &sa_xattr, 0);
if (dump_opt['d'] > 4) {
printf("\tSA xattr dump:\n");
dump_nvlist(sa_xattr, 16);
}

if (error) {
printf("\t%s: nvlist_unpack error=%d\n", __FUNCTION__, error);
free(sa_xattr_packed);
return;
}
Expand Down

0 comments on commit 803578e

Please sign in to comment.