diff options
| -rw-r--r-- | fs/proc/array.c | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/fs/proc/array.c b/fs/proc/array.c index c6977796fafd..4cb81776a7ff 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c | |||
| @@ -62,6 +62,8 @@ | |||
| 62 | #include <linux/mman.h> | 62 | #include <linux/mman.h> |
| 63 | #include <linux/proc_fs.h> | 63 | #include <linux/proc_fs.h> |
| 64 | #include <linux/ioport.h> | 64 | #include <linux/ioport.h> |
| 65 | #include <linux/uaccess.h> | ||
| 66 | #include <linux/io.h> | ||
| 65 | #include <linux/mm.h> | 67 | #include <linux/mm.h> |
| 66 | #include <linux/hugetlb.h> | 68 | #include <linux/hugetlb.h> |
| 67 | #include <linux/pagemap.h> | 69 | #include <linux/pagemap.h> |
| @@ -76,9 +78,7 @@ | |||
| 76 | #include <linux/rcupdate.h> | 78 | #include <linux/rcupdate.h> |
| 77 | #include <linux/delayacct.h> | 79 | #include <linux/delayacct.h> |
| 78 | 80 | ||
| 79 | #include <asm/uaccess.h> | ||
| 80 | #include <asm/pgtable.h> | 81 | #include <asm/pgtable.h> |
| 81 | #include <asm/io.h> | ||
| 82 | #include <asm/processor.h> | 82 | #include <asm/processor.h> |
| 83 | #include "internal.h" | 83 | #include "internal.h" |
| 84 | 84 | ||
| @@ -87,10 +87,10 @@ | |||
| 87 | do { memcpy(buffer, string, strlen(string)); \ | 87 | do { memcpy(buffer, string, strlen(string)); \ |
| 88 | buffer += strlen(string); } while (0) | 88 | buffer += strlen(string); } while (0) |
| 89 | 89 | ||
| 90 | static inline char * task_name(struct task_struct *p, char * buf) | 90 | static inline char *task_name(struct task_struct *p, char *buf) |
| 91 | { | 91 | { |
| 92 | int i; | 92 | int i; |
| 93 | char * name; | 93 | char *name; |
| 94 | char tcomm[sizeof(p->comm)]; | 94 | char tcomm[sizeof(p->comm)]; |
| 95 | 95 | ||
| 96 | get_task_comm(tcomm, p); | 96 | get_task_comm(tcomm, p); |
| @@ -138,7 +138,7 @@ static const char *task_state_array[] = { | |||
| 138 | "X (dead)" /* 32 */ | 138 | "X (dead)" /* 32 */ |
| 139 | }; | 139 | }; |
| 140 | 140 | ||
| 141 | static inline const char * get_task_state(struct task_struct *tsk) | 141 | static inline const char *get_task_state(struct task_struct *tsk) |
| 142 | { | 142 | { |
| 143 | unsigned int state = (tsk->state & (TASK_RUNNING | | 143 | unsigned int state = (tsk->state & (TASK_RUNNING | |
| 144 | TASK_INTERRUPTIBLE | | 144 | TASK_INTERRUPTIBLE | |
| @@ -156,7 +156,7 @@ static inline const char * get_task_state(struct task_struct *tsk) | |||
| 156 | return *p; | 156 | return *p; |
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | static inline char * task_state(struct task_struct *p, char *buffer) | 159 | static inline char *task_state(struct task_struct *p, char *buffer) |
| 160 | { | 160 | { |
| 161 | struct group_info *group_info; | 161 | struct group_info *group_info; |
| 162 | int g; | 162 | int g; |
| @@ -172,8 +172,8 @@ static inline char * task_state(struct task_struct *p, char *buffer) | |||
| 172 | "Uid:\t%d\t%d\t%d\t%d\n" | 172 | "Uid:\t%d\t%d\t%d\t%d\n" |
| 173 | "Gid:\t%d\t%d\t%d\t%d\n", | 173 | "Gid:\t%d\t%d\t%d\t%d\n", |
| 174 | get_task_state(p), | 174 | get_task_state(p), |
| 175 | p->tgid, p->pid, | 175 | p->tgid, p->pid, |
| 176 | pid_alive(p) ? rcu_dereference(p->real_parent)->tgid : 0, | 176 | pid_alive(p) ? rcu_dereference(p->real_parent)->tgid : 0, |
| 177 | pid_alive(p) && p->ptrace ? rcu_dereference(p->parent)->pid : 0, | 177 | pid_alive(p) && p->ptrace ? rcu_dereference(p->parent)->pid : 0, |
| 178 | p->uid, p->euid, p->suid, p->fsuid, | 178 | p->uid, p->euid, p->suid, p->fsuid, |
| 179 | p->gid, p->egid, p->sgid, p->fsgid); | 179 | p->gid, p->egid, p->sgid, p->fsgid); |
| @@ -191,15 +191,15 @@ static inline char * task_state(struct task_struct *p, char *buffer) | |||
| 191 | get_group_info(group_info); | 191 | get_group_info(group_info); |
| 192 | task_unlock(p); | 192 | task_unlock(p); |
| 193 | 193 | ||
| 194 | for (g = 0; g < min(group_info->ngroups,NGROUPS_SMALL); g++) | 194 | for (g = 0; g < min(group_info->ngroups, NGROUPS_SMALL); g++) |
| 195 | buffer += sprintf(buffer, "%d ", GROUP_AT(group_info,g)); | 195 | buffer += sprintf(buffer, "%d ", GROUP_AT(group_info, g)); |
| 196 | put_group_info(group_info); | 196 | put_group_info(group_info); |
| 197 | 197 | ||
| 198 | buffer += sprintf(buffer, "\n"); | 198 | buffer += sprintf(buffer, "\n"); |
| 199 | return buffer; | 199 | return buffer; |
| 200 | } | 200 | } |
| 201 | 201 | ||
| 202 | static char * render_sigset_t(const char *header, sigset_t *set, char *buffer) | 202 | static char *render_sigset_t(const char *header, sigset_t *set, char *buffer) |
| 203 | { | 203 | { |
| 204 | int i, len; | 204 | int i, len; |
| 205 | 205 | ||
| @@ -239,7 +239,7 @@ static void collect_sigign_sigcatch(struct task_struct *p, sigset_t *ign, | |||
| 239 | } | 239 | } |
| 240 | } | 240 | } |
| 241 | 241 | ||
| 242 | static inline char * task_sig(struct task_struct *p, char *buffer) | 242 | static inline char *task_sig(struct task_struct *p, char *buffer) |
| 243 | { | 243 | { |
| 244 | unsigned long flags; | 244 | unsigned long flags; |
| 245 | sigset_t pending, shpending, blocked, ignored, caught; | 245 | sigset_t pending, shpending, blocked, ignored, caught; |
| @@ -289,14 +289,14 @@ static inline char *task_cap(struct task_struct *p, char *buffer) | |||
| 289 | cap_t(p->cap_effective)); | 289 | cap_t(p->cap_effective)); |
| 290 | } | 290 | } |
| 291 | 291 | ||
| 292 | int proc_pid_status(struct task_struct *task, char * buffer) | 292 | int proc_pid_status(struct task_struct *task, char *buffer) |
| 293 | { | 293 | { |
| 294 | char * orig = buffer; | 294 | char *orig = buffer; |
| 295 | struct mm_struct *mm = get_task_mm(task); | 295 | struct mm_struct *mm = get_task_mm(task); |
| 296 | 296 | ||
| 297 | buffer = task_name(task, buffer); | 297 | buffer = task_name(task, buffer); |
| 298 | buffer = task_state(task, buffer); | 298 | buffer = task_state(task, buffer); |
| 299 | 299 | ||
| 300 | if (mm) { | 300 | if (mm) { |
| 301 | buffer = task_mem(mm, buffer); | 301 | buffer = task_mem(mm, buffer); |
| 302 | mmput(mm); | 302 | mmput(mm); |
| @@ -344,8 +344,7 @@ static clock_t task_stime(struct task_struct *p) | |||
| 344 | return stime; | 344 | return stime; |
| 345 | } | 345 | } |
| 346 | 346 | ||
| 347 | 347 | static int do_task_stat(struct task_struct *task, char *buffer, int whole) | |
| 348 | static int do_task_stat(struct task_struct *task, char * buffer, int whole) | ||
| 349 | { | 348 | { |
| 350 | unsigned long vsize, eip, esp, wchan = ~0UL; | 349 | unsigned long vsize, eip, esp, wchan = ~0UL; |
| 351 | long priority, nice; | 350 | long priority, nice; |
| @@ -353,7 +352,7 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole) | |||
| 353 | sigset_t sigign, sigcatch; | 352 | sigset_t sigign, sigcatch; |
| 354 | char state; | 353 | char state; |
| 355 | int res; | 354 | int res; |
| 356 | pid_t ppid = 0, pgid = -1, sid = -1; | 355 | pid_t ppid = 0, pgid = -1, sid = -1; |
| 357 | int num_threads = 0; | 356 | int num_threads = 0; |
| 358 | struct mm_struct *mm; | 357 | struct mm_struct *mm; |
| 359 | unsigned long long start_time; | 358 | unsigned long long start_time; |
| @@ -424,7 +423,7 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole) | |||
| 424 | } | 423 | } |
| 425 | rcu_read_unlock(); | 424 | rcu_read_unlock(); |
| 426 | 425 | ||
| 427 | if (!whole || num_threads<2) | 426 | if (!whole || num_threads < 2) |
| 428 | wchan = get_wchan(task); | 427 | wchan = get_wchan(task); |
| 429 | if (!whole) { | 428 | if (!whole) { |
| 430 | min_flt = task->min_flt; | 429 | min_flt = task->min_flt; |
| @@ -445,7 +444,7 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole) | |||
| 445 | /* convert nsec -> ticks */ | 444 | /* convert nsec -> ticks */ |
| 446 | start_time = nsec_to_clock_t(start_time); | 445 | start_time = nsec_to_clock_t(start_time); |
| 447 | 446 | ||
| 448 | res = sprintf(buffer,"%d (%s) %c %d %d %d %d %d %u %lu \ | 447 | res = sprintf(buffer, "%d (%s) %c %d %d %d %d %d %u %lu \ |
| 449 | %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \ | 448 | %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \ |
| 450 | %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu\n", | 449 | %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu\n", |
| 451 | task->pid, | 450 | task->pid, |
| @@ -471,7 +470,7 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole) | |||
| 471 | start_time, | 470 | start_time, |
| 472 | vsize, | 471 | vsize, |
| 473 | mm ? get_mm_rss(mm) : 0, | 472 | mm ? get_mm_rss(mm) : 0, |
| 474 | rsslim, | 473 | rsslim, |
| 475 | mm ? mm->start_code : 0, | 474 | mm ? mm->start_code : 0, |
| 476 | mm ? mm->end_code : 0, | 475 | mm ? mm->end_code : 0, |
| 477 | mm ? mm->start_stack : 0, | 476 | mm ? mm->start_stack : 0, |
| @@ -493,17 +492,17 @@ static int do_task_stat(struct task_struct *task, char * buffer, int whole) | |||
| 493 | task->rt_priority, | 492 | task->rt_priority, |
| 494 | task->policy, | 493 | task->policy, |
| 495 | (unsigned long long)delayacct_blkio_ticks(task)); | 494 | (unsigned long long)delayacct_blkio_ticks(task)); |
| 496 | if(mm) | 495 | if (mm) |
| 497 | mmput(mm); | 496 | mmput(mm); |
| 498 | return res; | 497 | return res; |
| 499 | } | 498 | } |
| 500 | 499 | ||
| 501 | int proc_tid_stat(struct task_struct *task, char * buffer) | 500 | int proc_tid_stat(struct task_struct *task, char *buffer) |
| 502 | { | 501 | { |
| 503 | return do_task_stat(task, buffer, 0); | 502 | return do_task_stat(task, buffer, 0); |
| 504 | } | 503 | } |
| 505 | 504 | ||
| 506 | int proc_tgid_stat(struct task_struct *task, char * buffer) | 505 | int proc_tgid_stat(struct task_struct *task, char *buffer) |
| 507 | { | 506 | { |
| 508 | return do_task_stat(task, buffer, 1); | 507 | return do_task_stat(task, buffer, 1); |
| 509 | } | 508 | } |
| @@ -512,12 +511,12 @@ int proc_pid_statm(struct task_struct *task, char *buffer) | |||
| 512 | { | 511 | { |
| 513 | int size = 0, resident = 0, shared = 0, text = 0, lib = 0, data = 0; | 512 | int size = 0, resident = 0, shared = 0, text = 0, lib = 0, data = 0; |
| 514 | struct mm_struct *mm = get_task_mm(task); | 513 | struct mm_struct *mm = get_task_mm(task); |
| 515 | 514 | ||
| 516 | if (mm) { | 515 | if (mm) { |
| 517 | size = task_statm(mm, &shared, &text, &data, &resident); | 516 | size = task_statm(mm, &shared, &text, &data, &resident); |
| 518 | mmput(mm); | 517 | mmput(mm); |
| 519 | } | 518 | } |
| 520 | 519 | ||
| 521 | return sprintf(buffer,"%d %d %d %d %d %d %d\n", | 520 | return sprintf(buffer, "%d %d %d %d %d %d %d\n", |
| 522 | size, resident, shared, text, lib, data, 0); | 521 | size, resident, shared, text, lib, data, 0); |
| 523 | } | 522 | } |
