btrfs-progs: dump-tree: escape special characters in paths or xattrs
Filenames can contain a newline (or other funny characters), this makes the dump-tree output confusing, same for xattr names or values that can binary data. Encode the special characters in the C-style ('\e' -> "\e", or \NNN if there's no single letter representation). This is based on the isprint() as it's espected either on a terminal or in a dump file. Issue: #350 Issue: #407 Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
3d2e879463
commit
ef73193623
|
@ -66,8 +66,12 @@ dump-tree [options] <device> [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``
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue