mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-28 01:21:58 +00:00
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> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
8b91a318e4
commit
25c6bb76ea
1 changed files with 6 additions and 19 deletions
|
@ -13,6 +13,7 @@
|
||||||
#include <linux/cred.h>
|
#include <linux/cred.h>
|
||||||
#include <linux/mm.h>
|
#include <linux/mm.h>
|
||||||
#include <linux/printk.h>
|
#include <linux/printk.h>
|
||||||
|
#include <linux/string_helpers.h>
|
||||||
|
|
||||||
#include <asm/uaccess.h>
|
#include <asm/uaccess.h>
|
||||||
#include <asm/page.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)
|
void seq_escape(struct seq_file *m, const char *s, const char *esc)
|
||||||
{
|
{
|
||||||
char *end = m->buf + m->size;
|
char *buf;
|
||||||
char *p;
|
size_t size = seq_get_buf(m, &buf);
|
||||||
char c;
|
int ret;
|
||||||
|
|
||||||
for (p = m->buf + m->count; (c = *s) != '\0' && p < end; s++) {
|
ret = string_escape_str(s, buf, size, ESCAPE_OCTAL, esc);
|
||||||
if (!strchr(esc, c)) {
|
seq_commit(m, ret < size ? ret : -1);
|
||||||
*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;
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(seq_escape);
|
EXPORT_SYMBOL(seq_escape);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue