diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2015-09-23 09:04:37 +1000 |
---|---|---|
committer | Stephen Rothwell <sfr@canb.auug.org.au> | 2015-09-23 09:04:37 +1000 |
commit | c31c79ad77c0ef134e3b2822ceec445bc8e1b567 (patch) | |
tree | 2995b8926022bcea71ea67e18db61d1f486f67d8 | |
parent | 7b79c9a69e9e178db31fef9f0cecd94ad2ca95e5 (diff) | |
download | linux-c31c79ad77c0ef134e3b2822ceec445bc8e1b567.tar.gz linux-c31c79ad77c0ef134e3b2822ceec445bc8e1b567.tar.xz |
seq_file: reuse string_escape_str()
strint_escape_str() escapes input string by given criteria. In case of
seq_escape() the criteria is to convert some characters to their octal
representation.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
-rw-r--r-- | fs/seq_file.c | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/fs/seq_file.c b/fs/seq_file.c index 225586e141ca..0f9ab58632bb 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c @@ -13,6 +13,7 @@ #include <linux/cred.h> #include <linux/mm.h> #include <linux/printk.h> +#include <linux/string_helpers.h> #include <asm/uaccess.h> #include <asm/page.h> @@ -377,26 +378,12 @@ EXPORT_SYMBOL(seq_release); */ void seq_escape(struct seq_file *m, const char *s, const char *esc) { - char *end = m->buf + m->size; - char *p; - char c; + char *buf; + size_t size = seq_get_buf(m, &buf); + int ret; - for (p = m->buf + m->count; (c = *s) != '\0' && p < end; s++) { - if (!strchr(esc, c)) { - *p++ = c; - continue; - } - if (p + 3 < end) { - *p++ = '\\'; - *p++ = '0' + ((c & 0300) >> 6); - *p++ = '0' + ((c & 070) >> 3); - *p++ = '0' + (c & 07); - continue; - } - seq_set_overflow(m); - return; - } - m->count = p - m->buf; + ret = string_escape_str(s, buf, size, ESCAPE_OCTAL, esc); + seq_commit(m, ret < size ? ret : -1); } EXPORT_SYMBOL(seq_escape); |