aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc/array.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/proc/array.c')
-rw-r--r--fs/proc/array.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/fs/proc/array.c b/fs/proc/array.c
index ae2c807fd719..f29221e95792 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -95,7 +95,7 @@
95#include <asm/processor.h> 95#include <asm/processor.h>
96#include "internal.h" 96#include "internal.h"
97 97
98static inline void task_name(struct seq_file *m, struct task_struct *p) 98void proc_task_name(struct seq_file *m, struct task_struct *p, bool escape)
99{ 99{
100 char *buf; 100 char *buf;
101 size_t size; 101 size_t size;
@@ -104,13 +104,17 @@ static inline void task_name(struct seq_file *m, struct task_struct *p)
104 104
105 get_task_comm(tcomm, p); 105 get_task_comm(tcomm, p);
106 106
107 seq_puts(m, "Name:\t");
108
109 size = seq_get_buf(m, &buf); 107 size = seq_get_buf(m, &buf);
110 ret = string_escape_str(tcomm, buf, size, ESCAPE_SPACE | ESCAPE_SPECIAL, "\n\\"); 108 if (escape) {
111 seq_commit(m, ret < size ? ret : -1); 109 ret = string_escape_str(tcomm, buf, size,
110 ESCAPE_SPACE | ESCAPE_SPECIAL, "\n\\");
111 if (ret >= size)
112 ret = -1;
113 } else {
114 ret = strscpy(buf, tcomm, size);
115 }
112 116
113 seq_putc(m, '\n'); 117 seq_commit(m, ret);
114} 118}
115 119
116/* 120/*
@@ -365,7 +369,10 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
365{ 369{
366 struct mm_struct *mm = get_task_mm(task); 370 struct mm_struct *mm = get_task_mm(task);
367 371
368 task_name(m, task); 372 seq_puts(m, "Name:\t");
373 proc_task_name(m, task, true);
374 seq_putc(m, '\n');
375
369 task_state(m, ns, pid, task); 376 task_state(m, ns, pid, task);
370 377
371 if (mm) { 378 if (mm) {
@@ -400,7 +407,6 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
400 u64 cutime, cstime, utime, stime; 407 u64 cutime, cstime, utime, stime;
401 u64 cgtime, gtime; 408 u64 cgtime, gtime;
402 unsigned long rsslim = 0; 409 unsigned long rsslim = 0;
403 char tcomm[sizeof(task->comm)];
404 unsigned long flags; 410 unsigned long flags;
405 411
406 state = *get_task_state(task); 412 state = *get_task_state(task);
@@ -427,8 +433,6 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
427 } 433 }
428 } 434 }
429 435
430 get_task_comm(tcomm, task);
431
432 sigemptyset(&sigign); 436 sigemptyset(&sigign);
433 sigemptyset(&sigcatch); 437 sigemptyset(&sigcatch);
434 cutime = cstime = utime = stime = 0; 438 cutime = cstime = utime = stime = 0;
@@ -495,7 +499,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
495 499
496 seq_put_decimal_ull(m, "", pid_nr_ns(pid, ns)); 500 seq_put_decimal_ull(m, "", pid_nr_ns(pid, ns));
497 seq_puts(m, " ("); 501 seq_puts(m, " (");
498 seq_puts(m, tcomm); 502 proc_task_name(m, task, false);
499 seq_puts(m, ") "); 503 seq_puts(m, ") ");
500 seq_putc(m, state); 504 seq_putc(m, state);
501 seq_put_decimal_ll(m, " ", ppid); 505 seq_put_decimal_ll(m, " ", ppid);