forked from luck/tmp_suning_uos_patched
fs/proc/array.c: convert to use string_escape_str()
Instead of custom approach let's use string_escape_str() to escape a given string (task_name in this case). Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
198d1597cc
commit
edc924e023
|
@ -81,6 +81,7 @@
|
||||||
#include <linux/pid_namespace.h>
|
#include <linux/pid_namespace.h>
|
||||||
#include <linux/ptrace.h>
|
#include <linux/ptrace.h>
|
||||||
#include <linux/tracehook.h>
|
#include <linux/tracehook.h>
|
||||||
|
#include <linux/string_helpers.h>
|
||||||
#include <linux/user_namespace.h>
|
#include <linux/user_namespace.h>
|
||||||
|
|
||||||
#include <asm/pgtable.h>
|
#include <asm/pgtable.h>
|
||||||
|
@ -89,39 +90,18 @@
|
||||||
|
|
||||||
static inline void task_name(struct seq_file *m, struct task_struct *p)
|
static inline void task_name(struct seq_file *m, struct task_struct *p)
|
||||||
{
|
{
|
||||||
int i;
|
char *buf;
|
||||||
char *buf, *end;
|
|
||||||
char *name;
|
|
||||||
char tcomm[sizeof(p->comm)];
|
char tcomm[sizeof(p->comm)];
|
||||||
|
|
||||||
get_task_comm(tcomm, p);
|
get_task_comm(tcomm, p);
|
||||||
|
|
||||||
seq_puts(m, "Name:\t");
|
seq_puts(m, "Name:\t");
|
||||||
end = m->buf + m->size;
|
|
||||||
buf = m->buf + m->count;
|
buf = m->buf + m->count;
|
||||||
name = tcomm;
|
|
||||||
i = sizeof(tcomm);
|
/* Ignore error for now */
|
||||||
while (i && (buf < end)) {
|
string_escape_str(tcomm, &buf, m->size - m->count,
|
||||||
unsigned char c = *name;
|
ESCAPE_SPACE | ESCAPE_SPECIAL, "\n\\");
|
||||||
name++;
|
|
||||||
i--;
|
|
||||||
*buf = c;
|
|
||||||
if (!c)
|
|
||||||
break;
|
|
||||||
if (c == '\\') {
|
|
||||||
buf++;
|
|
||||||
if (buf < end)
|
|
||||||
*buf++ = c;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (c == '\n') {
|
|
||||||
*buf++ = '\\';
|
|
||||||
if (buf < end)
|
|
||||||
*buf++ = 'n';
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
buf++;
|
|
||||||
}
|
|
||||||
m->count = buf - m->buf;
|
m->count = buf - m->buf;
|
||||||
seq_putc(m, '\n');
|
seq_putc(m, '\n');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user