zdb: consistent xattr output
When using zdb to output the value of an xattr only interpret it as printable characters if the entire byte array is printable. Additionally, if the --parseable option is set always output the buffer contents as octal for easy parsing. Reviewed-by: Olaf Faaland <faaland1@llnl.gov> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #14830
This commit is contained in:
parent
245f4a3467
commit
dd19821149
|
@ -3322,13 +3322,22 @@ dump_znode_sa_xattr(sa_handle_t *hdl)
|
|||
(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) {
|
||||
boolean_t can_print = !dump_opt['P'];
|
||||
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]))
|
||||
if (!isprint(value[idx])) {
|
||||
can_print = B_FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (idx = 0; idx < cnt; ++idx) {
|
||||
if (can_print)
|
||||
(void) putchar(value[idx]);
|
||||
else
|
||||
(void) printf("\\%3.3o", value[idx]);
|
||||
|
|
Loading…
Reference in New Issue