diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2014-10-13 18:55:18 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-10-13 20:18:26 -0400 |
commit | 71dca95d5cf5ece6c1bee8e625e23c16025952c7 (patch) | |
tree | 098b1a20867ef6d1b38f549f162c160610b3cbff /Documentation/printk-formats.txt | |
parent | c8250381c8272a9828fdd353171727b154fbd296 (diff) |
lib/vsprintf: add %*pE[achnops] format specifier
This allows user to print a given buffer as an escaped string. The
rules are applied according to an optional mix of flags provided by
additional format letters.
For example, if the given buffer is:
1b 62 20 5c 43 07 22 90 0d 5d
The result strings would be:
%*pE "\eb \C\a"\220\r]"
%*pEhp "\x1bb \C\x07"\x90\x0d]"
%*pEa "\e\142\040\\\103\a\042\220\r\135"
Please, read Documentation/printk-formats.txt and lib/string_helpers.c
kernel documentation to get further information.
[akpm@linux-foundation.org: tidy up comment layout, per Joe]
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Suggested-by: Joe Perches <joe@perches.com>
Cc: "John W . Linville" <linville@tuxdriver.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'Documentation/printk-formats.txt')
-rw-r--r-- | Documentation/printk-formats.txt | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt index b4498218c474..5a615c14f75d 100644 --- a/Documentation/printk-formats.txt +++ b/Documentation/printk-formats.txt | |||
@@ -70,6 +70,38 @@ DMA addresses types dma_addr_t: | |||
70 | For printing a dma_addr_t type which can vary based on build options, | 70 | For printing a dma_addr_t type which can vary based on build options, |
71 | regardless of the width of the CPU data path. Passed by reference. | 71 | regardless of the width of the CPU data path. Passed by reference. |
72 | 72 | ||
73 | Raw buffer as an escaped string: | ||
74 | |||
75 | %*pE[achnops] | ||
76 | |||
77 | For printing raw buffer as an escaped string. For the following buffer | ||
78 | |||
79 | 1b 62 20 5c 43 07 22 90 0d 5d | ||
80 | |||
81 | few examples show how the conversion would be done (the result string | ||
82 | without surrounding quotes): | ||
83 | |||
84 | %*pE "\eb \C\a"\220\r]" | ||
85 | %*pEhp "\x1bb \C\x07"\x90\x0d]" | ||
86 | %*pEa "\e\142\040\\\103\a\042\220\r\135" | ||
87 | |||
88 | The conversion rules are applied according to an optional combination | ||
89 | of flags (see string_escape_mem() kernel documentation for the | ||
90 | details): | ||
91 | a - ESCAPE_ANY | ||
92 | c - ESCAPE_SPECIAL | ||
93 | h - ESCAPE_HEX | ||
94 | n - ESCAPE_NULL | ||
95 | o - ESCAPE_OCTAL | ||
96 | p - ESCAPE_NP | ||
97 | s - ESCAPE_SPACE | ||
98 | By default ESCAPE_ANY_NP is used. | ||
99 | |||
100 | ESCAPE_ANY_NP is the sane choice for many cases, in particularly for | ||
101 | printing SSIDs. | ||
102 | |||
103 | If field width is omitted the 1 byte only will be escaped. | ||
104 | |||
73 | Raw buffer as a hex string: | 105 | Raw buffer as a hex string: |
74 | %*ph 00 01 02 ... 3f | 106 | %*ph 00 01 02 ... 3f |
75 | %*phC 00:01:02: ... :3f | 107 | %*phC 00:01:02: ... :3f |