btrfs-progs
btrfs-progs copied to clipboard
inspect dump-tree: encode non-printable filenames and xattrs
As reported eg. in #350, xattrs can contain characters that are either not printable or cause formatting changes when printed (like newlines). The same holds for filenames.
- Non-printable characters (and maybe some printable ones as exceptions) could be encoded, eg. like in C with
\x00so that they can be easily converted by common tools. - Alternatively we can use iconv to do conversion from raw bytes to any output encoding so eg. filenames in CJK are readable. ~~To avoid hard dependency on libiconv, this can be done by dlopen (iconv_open, iconv, iconv_close) and do nothing as fallback.~~ iconv is part of glibc.
- The conversion should be done when requested by an option as we don't have a good default
Iconv is also available in musl so there's no problem with compatibility.