diff options
author | David S. Miller <davem@davemloft.net> | 2008-03-18 02:44:31 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-03-18 02:44:31 -0400 |
commit | 2f633928cbba8a5858bb39b11e7219a41b0fbef5 (patch) | |
tree | 9a82f4b7f2c3afe4b0208d8e44ea61bae90a7d22 /fs/proc | |
parent | 5e226e4d9016daee170699f8a4188a5505021756 (diff) | |
parent | bde4f8fa8db2abd5ac9c542d76012d0fedab050f (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'fs/proc')
-rw-r--r-- | fs/proc/base.c | 27 | ||||
-rw-r--r-- | fs/proc/proc_misc.c | 3 | ||||
-rw-r--r-- | fs/proc/task_mmu.c | 18 |
3 files changed, 25 insertions, 23 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c index 3217774d269f..9a4da0aae02e 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -314,9 +314,12 @@ static int proc_pid_schedstat(struct task_struct *task, char *buffer) | |||
314 | static int lstats_show_proc(struct seq_file *m, void *v) | 314 | static int lstats_show_proc(struct seq_file *m, void *v) |
315 | { | 315 | { |
316 | int i; | 316 | int i; |
317 | struct task_struct *task = m->private; | 317 | struct inode *inode = m->private; |
318 | seq_puts(m, "Latency Top version : v0.1\n"); | 318 | struct task_struct *task = get_proc_task(inode); |
319 | 319 | ||
320 | if (!task) | ||
321 | return -ESRCH; | ||
322 | seq_puts(m, "Latency Top version : v0.1\n"); | ||
320 | for (i = 0; i < 32; i++) { | 323 | for (i = 0; i < 32; i++) { |
321 | if (task->latency_record[i].backtrace[0]) { | 324 | if (task->latency_record[i].backtrace[0]) { |
322 | int q; | 325 | int q; |
@@ -341,32 +344,24 @@ static int lstats_show_proc(struct seq_file *m, void *v) | |||
341 | } | 344 | } |
342 | 345 | ||
343 | } | 346 | } |
347 | put_task_struct(task); | ||
344 | return 0; | 348 | return 0; |
345 | } | 349 | } |
346 | 350 | ||
347 | static int lstats_open(struct inode *inode, struct file *file) | 351 | static int lstats_open(struct inode *inode, struct file *file) |
348 | { | 352 | { |
349 | int ret; | 353 | return single_open(file, lstats_show_proc, inode); |
350 | struct seq_file *m; | ||
351 | struct task_struct *task = get_proc_task(inode); | ||
352 | |||
353 | ret = single_open(file, lstats_show_proc, NULL); | ||
354 | if (!ret) { | ||
355 | m = file->private_data; | ||
356 | m->private = task; | ||
357 | } | ||
358 | return ret; | ||
359 | } | 354 | } |
360 | 355 | ||
361 | static ssize_t lstats_write(struct file *file, const char __user *buf, | 356 | static ssize_t lstats_write(struct file *file, const char __user *buf, |
362 | size_t count, loff_t *offs) | 357 | size_t count, loff_t *offs) |
363 | { | 358 | { |
364 | struct seq_file *m; | 359 | struct task_struct *task = get_proc_task(file->f_dentry->d_inode); |
365 | struct task_struct *task; | ||
366 | 360 | ||
367 | m = file->private_data; | 361 | if (!task) |
368 | task = m->private; | 362 | return -ESRCH; |
369 | clear_all_latency_tracing(task); | 363 | clear_all_latency_tracing(task); |
364 | put_task_struct(task); | ||
370 | 365 | ||
371 | return count; | 366 | return count; |
372 | } | 367 | } |
diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c index 468805d40e2b..2d563979cb02 100644 --- a/fs/proc/proc_misc.c +++ b/fs/proc/proc_misc.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/interrupt.h> | 32 | #include <linux/interrupt.h> |
33 | #include <linux/swap.h> | 33 | #include <linux/swap.h> |
34 | #include <linux/slab.h> | 34 | #include <linux/slab.h> |
35 | #include <linux/genhd.h> | ||
35 | #include <linux/smp.h> | 36 | #include <linux/smp.h> |
36 | #include <linux/signal.h> | 37 | #include <linux/signal.h> |
37 | #include <linux/module.h> | 38 | #include <linux/module.h> |
@@ -377,7 +378,6 @@ static int stram_read_proc(char *page, char **start, off_t off, | |||
377 | #endif | 378 | #endif |
378 | 379 | ||
379 | #ifdef CONFIG_BLOCK | 380 | #ifdef CONFIG_BLOCK |
380 | extern const struct seq_operations partitions_op; | ||
381 | static int partitions_open(struct inode *inode, struct file *file) | 381 | static int partitions_open(struct inode *inode, struct file *file) |
382 | { | 382 | { |
383 | return seq_open(file, &partitions_op); | 383 | return seq_open(file, &partitions_op); |
@@ -389,7 +389,6 @@ static const struct file_operations proc_partitions_operations = { | |||
389 | .release = seq_release, | 389 | .release = seq_release, |
390 | }; | 390 | }; |
391 | 391 | ||
392 | extern const struct seq_operations diskstats_op; | ||
393 | static int diskstats_open(struct inode *inode, struct file *file) | 392 | static int diskstats_open(struct inode *inode, struct file *file) |
394 | { | 393 | { |
395 | return seq_open(file, &diskstats_op); | 394 | return seq_open(file, &diskstats_op); |
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 6dc0334815f7..4206454734e0 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c | |||
@@ -640,17 +640,17 @@ static ssize_t pagemap_read(struct file *file, char __user *buf, | |||
640 | 640 | ||
641 | ret = -EACCES; | 641 | ret = -EACCES; |
642 | if (!ptrace_may_attach(task)) | 642 | if (!ptrace_may_attach(task)) |
643 | goto out; | 643 | goto out_task; |
644 | 644 | ||
645 | ret = -EINVAL; | 645 | ret = -EINVAL; |
646 | /* file position must be aligned */ | 646 | /* file position must be aligned */ |
647 | if (*ppos % PM_ENTRY_BYTES) | 647 | if (*ppos % PM_ENTRY_BYTES) |
648 | goto out; | 648 | goto out_task; |
649 | 649 | ||
650 | ret = 0; | 650 | ret = 0; |
651 | mm = get_task_mm(task); | 651 | mm = get_task_mm(task); |
652 | if (!mm) | 652 | if (!mm) |
653 | goto out; | 653 | goto out_task; |
654 | 654 | ||
655 | ret = -ENOMEM; | 655 | ret = -ENOMEM; |
656 | uaddr = (unsigned long)buf & PAGE_MASK; | 656 | uaddr = (unsigned long)buf & PAGE_MASK; |
@@ -658,7 +658,7 @@ static ssize_t pagemap_read(struct file *file, char __user *buf, | |||
658 | pagecount = (PAGE_ALIGN(uend) - uaddr) / PAGE_SIZE; | 658 | pagecount = (PAGE_ALIGN(uend) - uaddr) / PAGE_SIZE; |
659 | pages = kmalloc(pagecount * sizeof(struct page *), GFP_KERNEL); | 659 | pages = kmalloc(pagecount * sizeof(struct page *), GFP_KERNEL); |
660 | if (!pages) | 660 | if (!pages) |
661 | goto out_task; | 661 | goto out_mm; |
662 | 662 | ||
663 | down_read(¤t->mm->mmap_sem); | 663 | down_read(¤t->mm->mmap_sem); |
664 | ret = get_user_pages(current, current->mm, uaddr, pagecount, | 664 | ret = get_user_pages(current, current->mm, uaddr, pagecount, |
@@ -668,6 +668,12 @@ static ssize_t pagemap_read(struct file *file, char __user *buf, | |||
668 | if (ret < 0) | 668 | if (ret < 0) |
669 | goto out_free; | 669 | goto out_free; |
670 | 670 | ||
671 | if (ret != pagecount) { | ||
672 | pagecount = ret; | ||
673 | ret = -EFAULT; | ||
674 | goto out_pages; | ||
675 | } | ||
676 | |||
671 | pm.out = buf; | 677 | pm.out = buf; |
672 | pm.end = buf + count; | 678 | pm.end = buf + count; |
673 | 679 | ||
@@ -699,15 +705,17 @@ static ssize_t pagemap_read(struct file *file, char __user *buf, | |||
699 | ret = pm.out - buf; | 705 | ret = pm.out - buf; |
700 | } | 706 | } |
701 | 707 | ||
708 | out_pages: | ||
702 | for (; pagecount; pagecount--) { | 709 | for (; pagecount; pagecount--) { |
703 | page = pages[pagecount-1]; | 710 | page = pages[pagecount-1]; |
704 | if (!PageReserved(page)) | 711 | if (!PageReserved(page)) |
705 | SetPageDirty(page); | 712 | SetPageDirty(page); |
706 | page_cache_release(page); | 713 | page_cache_release(page); |
707 | } | 714 | } |
708 | mmput(mm); | ||
709 | out_free: | 715 | out_free: |
710 | kfree(pages); | 716 | kfree(pages); |
717 | out_mm: | ||
718 | mmput(mm); | ||
711 | out_task: | 719 | out_task: |
712 | put_task_struct(task); | 720 | put_task_struct(task); |
713 | out: | 721 | out: |