aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2015-02-12 18:01:11 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-02-12 21:54:12 -0500
commitedc924e023ae2022fc29f1246e115c610c9abf38 (patch)
tree09417a3d57aa78bc11ae8a35d2aca4b0c627db1c
parent198d1597cc5a12d04af18b69338a5b1d66ee7020 (diff)
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>
-rw-r--r--fs/proc/array.c34
1 files changed, 7 insertions, 27 deletions
diff --git a/fs/proc/array.c b/fs/proc/array.c
index bd117d065b82..a3ccf4c4ce70 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -81,6 +81,7 @@
81#include <linux/pid_namespace.h> 81#include <linux/pid_namespace.h>
82#include <linux/ptrace.h> 82#include <linux/ptrace.h>
83#include <linux/tracehook.h> 83#include <linux/tracehook.h>
84#include <linux/string_helpers.h>
84#include <linux/user_namespace.h> 85#include <linux/user_namespace.h>
85 86
86#include <asm/pgtable.h> 87#include <asm/pgtable.h>
@@ -89,39 +90,18 @@
89 90
90static inline void task_name(struct seq_file *m, struct task_struct *p) 91static inline void task_name(struct seq_file *m, struct task_struct *p)
91{ 92{
92 int i; 93 char *buf;
93 char *buf, *end;
94 char *name;
95 char tcomm[sizeof(p->comm)]; 94 char tcomm[sizeof(p->comm)];
96 95
97 get_task_comm(tcomm, p); 96 get_task_comm(tcomm, p);
98 97
99 seq_puts(m, "Name:\t"); 98 seq_puts(m, "Name:\t");
100 end = m->buf + m->size;
101 buf = m->buf + m->count; 99 buf = m->buf + m->count;
102 name = tcomm; 100
103 i = sizeof(tcomm); 101 /* Ignore error for now */
104 while (i && (buf < end)) { 102 string_escape_str(tcomm, &buf, m->size - m->count,
105 unsigned char c = *name; 103 ESCAPE_SPACE | ESCAPE_SPECIAL, "\n\\");
106 name++; 104
107 i--;
108 *buf = c;
109 if (!c)
110 break;
111 if (c == '\\') {
112 buf++;
113 if (buf < end)
114 *buf++ = c;
115 continue;
116 }
117 if (c == '\n') {
118 *buf++ = '\\';
119 if (buf < end)
120 *buf++ = 'n';
121 continue;
122 }
123 buf++;
124 }
125 m->count = buf - m->buf; 105 m->count = buf - m->buf;
126 seq_putc(m, '\n'); 106 seq_putc(m, '\n');
127} 107}