diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2021-06-30 18:55:34 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2021-07-01 11:06:05 -0700 |
commit | 1d31aa172a4e6728918a06ee7f1d6bcb7507172c (patch) | |
tree | 5a9dcf432843110df5ec578940e9aeb1de2dc945 /fs | |
parent | be613b4025fa3894f3985283d5f2929161fae300 (diff) | |
download | linux-stable-1d31aa172a4e6728918a06ee7f1d6bcb7507172c.tar.gz linux-stable-1d31aa172a4e6728918a06ee7f1d6bcb7507172c.tar.bz2 linux-stable-1d31aa172a4e6728918a06ee7f1d6bcb7507172c.zip |
seq_file: introduce seq_escape_mem()
Introduce seq_escape_mem() to allow users to pass additional parameters to
string_escape_mem().
Link: https://lkml.kernel.org/r/20210504180819.73127-12-andriy.shevchenko@linux.intel.com
Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Chuck Lever <chuck.lever@oracle.com>
Cc: "J. Bruce Fields" <bfields@fieldses.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/seq_file.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/fs/seq_file.c b/fs/seq_file.c index 5059248f2d64..532cac2eae0f 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c @@ -356,6 +356,31 @@ int seq_release(struct inode *inode, struct file *file) EXPORT_SYMBOL(seq_release); /** + * seq_escape_mem - print data into buffer, escaping some characters + * @m: target buffer + * @src: source buffer + * @len: size of source buffer + * @flags: flags to pass to string_escape_mem() + * @esc: set of characters that need escaping + * + * Puts data into buffer, replacing each occurrence of character from + * given class (defined by @flags and @esc) with printable escaped sequence. + * + * Use seq_has_overflowed() to check for errors. + */ +void seq_escape_mem(struct seq_file *m, const char *src, size_t len, + unsigned int flags, const char *esc) +{ + char *buf; + size_t size = seq_get_buf(m, &buf); + int ret; + + ret = string_escape_mem(src, len, buf, size, flags, esc); + seq_commit(m, ret < size ? ret : -1); +} +EXPORT_SYMBOL(seq_escape_mem); + +/** * seq_escape - print string into buffer, escaping some characters * @m: target buffer * @s: string |