summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Chase <[email protected]>2013-07-09 07:15:26 -0500
committerBrian Behlendorf <[email protected]>2013-07-09 13:52:28 -0700
commit50210587563bb37c48d2624d11e158ab3ad30715 (patch)
tree180be0733c6071af8d871e868f0d130f804f3423
parent5d3dc3fb72518a4c191e3a014622b74365eb3a74 (diff)
zdb: enhancement - Display SA xattrs.
If the znode has SA xattrs, display them following the other standard attributes. The format used is similar to that used when listing the contents of a ZAP. It is as follows: $ zdb -vvv <pool>/<dataset> <object> ... SA xattrs: <size> bytes, <number> entries <name1> = <value1> <name2> = <value2> ... Signed-off-by: Brian Behlendorf <[email protected]> Closes #1581
-rw-r--r--cmd/zdb/zdb.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c
index a2b6bfe97..82491ad5f 100644
--- a/cmd/zdb/zdb.c
+++ b/cmd/zdb/zdb.c
@@ -1327,6 +1327,61 @@ dump_uidgid(objset_t *os, uint64_t uid, uint64_t gid)
print_idstr(gid, "gid");
}
+static void
+dump_znode_sa_xattr(sa_handle_t *hdl)
+{
+ nvlist_t *sa_xattr;
+ 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 (error || sa_xattr_size == 0)
+ return;
+
+ sa_xattr_packed = malloc(sa_xattr_size);
+ if (sa_xattr_packed == NULL)
+ return;
+
+ error = sa_lookup(hdl, sa_attr_table[ZPL_DXATTR],
+ sa_xattr_packed, sa_xattr_size);
+ if (error) {
+ free(sa_xattr_packed);
+ return;
+ }
+
+ error = nvlist_unpack(sa_xattr_packed, sa_xattr_size, &sa_xattr, 0);
+ if (error) {
+ free(sa_xattr_packed);
+ return;
+ }
+
+ while ((elem = nvlist_next_nvpair(sa_xattr, elem)) != NULL)
+ sa_xattr_entries++;
+
+ (void) printf("\tSA xattrs: %d bytes, %d entries\n\n",
+ sa_xattr_size, sa_xattr_entries);
+ while ((elem = nvlist_next_nvpair(sa_xattr, elem)) != NULL) {
+ uchar_t *value;
+ uint_t cnt, idx;
+
+ (void) printf("\t\t%s = ", nvpair_name(elem));
+ nvpair_value_byte_array(elem, &value, &cnt);
+ for (idx = 0 ; idx < cnt ; ++idx) {
+ if (isprint(value[idx]))
+ (void) putchar(value[idx]);
+ else
+ (void) printf("\\%3.3o", value[idx]);
+ }
+ (void) putchar('\n');
+ }
+
+ nvlist_free(sa_xattr);
+ free(sa_xattr_packed);
+}
+
/*ARGSUSED*/
static void
dump_znode(objset_t *os, uint64_t object, void *data, size_t size)
@@ -1427,6 +1482,7 @@ dump_znode(objset_t *os, uint64_t object, void *data, size_t size)
if (sa_lookup(hdl, sa_attr_table[ZPL_RDEV], &rdev,
sizeof (uint64_t)) == 0)
(void) printf("\trdev 0x%016llx\n", (u_longlong_t)rdev);
+ dump_znode_sa_xattr(hdl);
sa_handle_destroy(hdl);
}