diff --git a/Documentation/btrfs-inspect-internal.rst b/Documentation/btrfs-inspect-internal.rst index b72651ed..79713c30 100644 --- a/Documentation/btrfs-inspect-internal.rst +++ b/Documentation/btrfs-inspect-internal.rst @@ -66,8 +66,12 @@ dump-tree [options] [device...] a positive educational effect on understanding the internal filesystem structure. .. note:: - Contains file names, consider that if you're asked to send the dump for - analysis. Does not contain file data. + By default contains file names, consider that if you're asked + to send the dump for analysis and use *--hide-names* eventually. + Does not contain file data. + + Special characters in file names, xattr names and values are escaped, + in the C style like ``\n`` and octal encoding ``\NNN``. ``Options`` diff --git a/kernel-shared/print-tree.c b/kernel-shared/print-tree.c index 1692e647..ab85432e 100644 --- a/kernel-shared/print-tree.c +++ b/kernel-shared/print-tree.c @@ -93,7 +93,9 @@ static void print_dir_item(struct extent_buffer *eb, u32 size, } else { read_extent_buffer(eb, namebuf, (unsigned long)(di + 1), len); - printf("\t\tname: %.*s\n", len, namebuf); + printf("\t\tname: "); + string_print_escape_special_len(namebuf, len); + printf("\n"); } if (data_len) { @@ -104,7 +106,9 @@ static void print_dir_item(struct extent_buffer *eb, u32 size, } else { read_extent_buffer(eb, namebuf, (unsigned long)(di + 1) + name_len, len); - printf("\t\tdata %.*s\n", len, namebuf); + printf("\t\tdata "); + string_print_escape_special_len(namebuf, len); + printf("\n"); } } len = sizeof(*di) + name_len + data_len; @@ -137,7 +141,9 @@ static void print_inode_extref_item(struct extent_buffer *eb, u32 size, } else { read_extent_buffer(eb, namebuf, (unsigned long)extref->name, len); - printf("name: %.*s\n", len, namebuf); + printf("name: "); + string_print_escape_special_len(namebuf, len); + printf("\n"); } len = sizeof(*extref) + name_len; @@ -167,7 +173,9 @@ static void print_inode_ref_item(struct extent_buffer *eb, u32 size, } else { read_extent_buffer(eb, namebuf, (unsigned long)(ref + 1), len); - printf("name: %.*s\n", len, namebuf); + printf("name: "); + string_print_escape_special_len(namebuf, len); + printf("\n"); } len = sizeof(*ref) + name_len; ref = (struct btrfs_inode_ref *)((char *)ref + len);