aboutsummaryrefslogtreecommitdiffstats
path: root/lib/string_helpers.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-07-17 11:58:04 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-07-17 11:58:04 -0400
commit57a8ec387e1441ea5e1232bc0749fb99a8cba7e7 (patch)
treeb5fb03fc6bc5754de8b5b1f8b0e4f36d67c8315c /lib/string_helpers.c
parent0a8ad0ffa4d80a544f6cbff703bf6394339afcdf (diff)
parent43e11fa2d1d3b6e35629fa556eb7d571edba2010 (diff)
Merge branch 'akpm' (patches from Andrew)
Merge more updates from Andrew Morton: "VM: - z3fold fixes and enhancements by Henry Burns and Vitaly Wool - more accurate reclaimed slab caches calculations by Yafang Shao - fix MAP_UNINITIALIZED UAPI symbol to not depend on config, by Christoph Hellwig - !CONFIG_MMU fixes by Christoph Hellwig - new novmcoredd parameter to omit device dumps from vmcore, by Kairui Song - new test_meminit module for testing heap and pagealloc initialization, by Alexander Potapenko - ioremap improvements for huge mappings, by Anshuman Khandual - generalize kprobe page fault handling, by Anshuman Khandual - device-dax hotplug fixes and improvements, by Pavel Tatashin - enable synchronous DAX fault on powerpc, by Aneesh Kumar K.V - add pte_devmap() support for arm64, by Robin Murphy - unify locked_vm accounting with a helper, by Daniel Jordan - several misc fixes core/lib: - new typeof_member() macro including some users, by Alexey Dobriyan - make BIT() and GENMASK() available in asm, by Masahiro Yamada - changed LIST_POISON2 on x86_64 to 0xdead000000000122 for better code generation, by Alexey Dobriyan - rbtree code size optimizations, by Michel Lespinasse - convert struct pid count to refcount_t, by Joel Fernandes get_maintainer.pl: - add --no-moderated switch to skip moderated ML's, by Joe Perches misc: - ptrace PTRACE_GET_SYSCALL_INFO interface - coda updates - gdb scripts, various" [ Using merge message suggestion from Vlastimil Babka, with some editing - Linus ] * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (100 commits) fs/select.c: use struct_size() in kmalloc() mm: add account_locked_vm utility function arm64: mm: implement pte_devmap support mm: introduce ARCH_HAS_PTE_DEVMAP mm: clean up is_device_*_page() definitions mm/mmap: move common defines to mman-common.h mm: move MAP_SYNC to asm-generic/mman-common.h device-dax: "Hotremove" persistent memory that is used like normal RAM mm/hotplug: make remove_memory() interface usable device-dax: fix memory and resource leak if hotplug fails include/linux/lz4.h: fix spelling and copy-paste errors in documentation ipc/mqueue.c: only perform resource calculation if user valid include/asm-generic/bug.h: fix "cut here" for WARN_ON for __WARN_TAINT architectures scripts/gdb: add helpers to find and list devices scripts/gdb: add lx-genpd-summary command drivers/pps/pps.c: clear offset flags in PPS_SETPARAMS ioctl kernel/pid.c: convert struct pid count to refcount_t drivers/rapidio/devices/rio_mport_cdev.c: NUL terminate some strings select: shift restore_saved_sigmask_unless() into poll_select_copy_remaining() select: change do_poll() to return -ERESTARTNOHAND rather than -EINTR ...
Diffstat (limited to 'lib/string_helpers.c')
-rw-r--r--lib/string_helpers.c77
1 files changed, 40 insertions, 37 deletions
diff --git a/lib/string_helpers.c b/lib/string_helpers.c
index 3a90a9e2b94a..963050c0283e 100644
--- a/lib/string_helpers.c
+++ b/lib/string_helpers.c
@@ -231,35 +231,36 @@ static bool unescape_special(char **src, char **dst)
231 * @src: source buffer (escaped) 231 * @src: source buffer (escaped)
232 * @dst: destination buffer (unescaped) 232 * @dst: destination buffer (unescaped)
233 * @size: size of the destination buffer (0 to unlimit) 233 * @size: size of the destination buffer (0 to unlimit)
234 * @flags: combination of the flags (bitwise OR): 234 * @flags: combination of the flags.
235 * %UNESCAPE_SPACE: 235 *
236 * Description:
237 * The function unquotes characters in the given string.
238 *
239 * Because the size of the output will be the same as or less than the size of
240 * the input, the transformation may be performed in place.
241 *
242 * Caller must provide valid source and destination pointers. Be aware that
243 * destination buffer will always be NULL-terminated. Source string must be
244 * NULL-terminated as well. The supported flags are::
245 *
246 * UNESCAPE_SPACE:
236 * '\f' - form feed 247 * '\f' - form feed
237 * '\n' - new line 248 * '\n' - new line
238 * '\r' - carriage return 249 * '\r' - carriage return
239 * '\t' - horizontal tab 250 * '\t' - horizontal tab
240 * '\v' - vertical tab 251 * '\v' - vertical tab
241 * %UNESCAPE_OCTAL: 252 * UNESCAPE_OCTAL:
242 * '\NNN' - byte with octal value NNN (1 to 3 digits) 253 * '\NNN' - byte with octal value NNN (1 to 3 digits)
243 * %UNESCAPE_HEX: 254 * UNESCAPE_HEX:
244 * '\xHH' - byte with hexadecimal value HH (1 to 2 digits) 255 * '\xHH' - byte with hexadecimal value HH (1 to 2 digits)
245 * %UNESCAPE_SPECIAL: 256 * UNESCAPE_SPECIAL:
246 * '\"' - double quote 257 * '\"' - double quote
247 * '\\' - backslash 258 * '\\' - backslash
248 * '\a' - alert (BEL) 259 * '\a' - alert (BEL)
249 * '\e' - escape 260 * '\e' - escape
250 * %UNESCAPE_ANY: 261 * UNESCAPE_ANY:
251 * all previous together 262 * all previous together
252 * 263 *
253 * Description:
254 * The function unquotes characters in the given string.
255 *
256 * Because the size of the output will be the same as or less than the size of
257 * the input, the transformation may be performed in place.
258 *
259 * Caller must provide valid source and destination pointers. Be aware that
260 * destination buffer will always be NULL-terminated. Source string must be
261 * NULL-terminated as well.
262 *
263 * Return: 264 * Return:
264 * The amount of the characters processed to the destination buffer excluding 265 * The amount of the characters processed to the destination buffer excluding
265 * trailing '\0' is returned. 266 * trailing '\0' is returned.
@@ -441,7 +442,29 @@ static bool escape_hex(unsigned char c, char **dst, char *end)
441 * @isz: source buffer size 442 * @isz: source buffer size
442 * @dst: destination buffer (escaped) 443 * @dst: destination buffer (escaped)
443 * @osz: destination buffer size 444 * @osz: destination buffer size
444 * @flags: combination of the flags (bitwise OR): 445 * @flags: combination of the flags
446 * @only: NULL-terminated string containing characters used to limit
447 * the selected escape class. If characters are included in @only
448 * that would not normally be escaped by the classes selected
449 * in @flags, they will be copied to @dst unescaped.
450 *
451 * Description:
452 * The process of escaping byte buffer includes several parts. They are applied
453 * in the following sequence.
454 *
455 * 1. The character is matched to the printable class, if asked, and in
456 * case of match it passes through to the output.
457 * 2. The character is not matched to the one from @only string and thus
458 * must go as-is to the output.
459 * 3. The character is checked if it falls into the class given by @flags.
460 * %ESCAPE_OCTAL and %ESCAPE_HEX are going last since they cover any
461 * character. Note that they actually can't go together, otherwise
462 * %ESCAPE_HEX will be ignored.
463 *
464 * Caller must provide valid source and destination pointers. Be aware that
465 * destination buffer will not be NULL-terminated, thus caller have to append
466 * it if needs. The supported flags are::
467 *
445 * %ESCAPE_SPACE: (special white space, not space itself) 468 * %ESCAPE_SPACE: (special white space, not space itself)
446 * '\f' - form feed 469 * '\f' - form feed
447 * '\n' - new line 470 * '\n' - new line
@@ -464,26 +487,6 @@ static bool escape_hex(unsigned char c, char **dst, char *end)
464 * all previous together 487 * all previous together
465 * %ESCAPE_HEX: 488 * %ESCAPE_HEX:
466 * '\xHH' - byte with hexadecimal value HH (2 digits) 489 * '\xHH' - byte with hexadecimal value HH (2 digits)
467 * @only: NULL-terminated string containing characters used to limit
468 * the selected escape class. If characters are included in @only
469 * that would not normally be escaped by the classes selected
470 * in @flags, they will be copied to @dst unescaped.
471 *
472 * Description:
473 * The process of escaping byte buffer includes several parts. They are applied
474 * in the following sequence.
475 * 1. The character is matched to the printable class, if asked, and in
476 * case of match it passes through to the output.
477 * 2. The character is not matched to the one from @only string and thus
478 * must go as-is to the output.
479 * 3. The character is checked if it falls into the class given by @flags.
480 * %ESCAPE_OCTAL and %ESCAPE_HEX are going last since they cover any
481 * character. Note that they actually can't go together, otherwise
482 * %ESCAPE_HEX will be ignored.
483 *
484 * Caller must provide valid source and destination pointers. Be aware that
485 * destination buffer will not be NULL-terminated, thus caller have to append
486 * it if needs.
487 * 490 *
488 * Return: 491 * Return:
489 * The total size of the escaped output that would be generated for 492 * The total size of the escaped output that would be generated for