diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-05-01 20:51:54 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-05-01 20:51:54 -0400 |
commit | 20b4fb485227404329e41ad15588afad3df23050 (patch) | |
tree | f3e099f0ab3da8a93b447203e294d2bb22f6dc05 /fs/proc/base.c | |
parent | b9394d8a657cd3c064fa432aa0905c1b58b38fe9 (diff) | |
parent | ac3e3c5b1164397656df81b9e9ab4991184d3236 (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull VFS updates from Al Viro,
Misc cleanups all over the place, mainly wrt /proc interfaces (switch
create_proc_entry to proc_create(), get rid of the deprecated
create_proc_read_entry() in favor of using proc_create_data() and
seq_file etc).
7kloc removed.
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (204 commits)
don't bother with deferred freeing of fdtables
proc: Move non-public stuff from linux/proc_fs.h to fs/proc/internal.h
proc: Make the PROC_I() and PDE() macros internal to procfs
proc: Supply a function to remove a proc entry by PDE
take cgroup_open() and cpuset_open() to fs/proc/base.c
ppc: Clean up scanlog
ppc: Clean up rtas_flash driver somewhat
hostap: proc: Use remove_proc_subtree()
drm: proc: Use remove_proc_subtree()
drm: proc: Use minor->index to label things, not PDE->name
drm: Constify drm_proc_list[]
zoran: Don't print proc_dir_entry data in debug
reiserfs: Don't access the proc_dir_entry in r_open(), r_start() r_show()
proc: Supply an accessor for getting the data from a PDE's parent
airo: Use remove_proc_subtree()
rtl8192u: Don't need to save device proc dir PDE
rtl8187se: Use a dir under /proc/net/r8180/
proc: Add proc_mkdir_data()
proc: Move some bits from linux/proc_fs.h to linux/{of.h,signal.h,tty.h}
proc: Move PDE_NET() to fs/proc/proc_net.c
...
Diffstat (limited to 'fs/proc/base.c')
-rw-r--r-- | fs/proc/base.c | 56 |
1 files changed, 52 insertions, 4 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c index 3861bcec41ff..dd51e50001fe 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -405,6 +405,37 @@ static const struct file_operations proc_lstats_operations = { | |||
405 | 405 | ||
406 | #endif | 406 | #endif |
407 | 407 | ||
408 | #ifdef CONFIG_CGROUPS | ||
409 | static int cgroup_open(struct inode *inode, struct file *file) | ||
410 | { | ||
411 | struct pid *pid = PROC_I(inode)->pid; | ||
412 | return single_open(file, proc_cgroup_show, pid); | ||
413 | } | ||
414 | |||
415 | static const struct file_operations proc_cgroup_operations = { | ||
416 | .open = cgroup_open, | ||
417 | .read = seq_read, | ||
418 | .llseek = seq_lseek, | ||
419 | .release = single_release, | ||
420 | }; | ||
421 | #endif | ||
422 | |||
423 | #ifdef CONFIG_PROC_PID_CPUSET | ||
424 | |||
425 | static int cpuset_open(struct inode *inode, struct file *file) | ||
426 | { | ||
427 | struct pid *pid = PROC_I(inode)->pid; | ||
428 | return single_open(file, proc_cpuset_show, pid); | ||
429 | } | ||
430 | |||
431 | static const struct file_operations proc_cpuset_operations = { | ||
432 | .open = cpuset_open, | ||
433 | .read = seq_read, | ||
434 | .llseek = seq_lseek, | ||
435 | .release = single_release, | ||
436 | }; | ||
437 | #endif | ||
438 | |||
408 | static int proc_oom_score(struct task_struct *task, char *buffer) | 439 | static int proc_oom_score(struct task_struct *task, char *buffer) |
409 | { | 440 | { |
410 | unsigned long totalpages = totalram_pages + total_swap_pages; | 441 | unsigned long totalpages = totalram_pages + total_swap_pages; |
@@ -1621,6 +1652,15 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags) | |||
1621 | return 0; | 1652 | return 0; |
1622 | } | 1653 | } |
1623 | 1654 | ||
1655 | int pid_delete_dentry(const struct dentry *dentry) | ||
1656 | { | ||
1657 | /* Is the task we represent dead? | ||
1658 | * If so, then don't put the dentry on the lru list, | ||
1659 | * kill it immediately. | ||
1660 | */ | ||
1661 | return !proc_pid(dentry->d_inode)->tasks[PIDTYPE_PID].first; | ||
1662 | } | ||
1663 | |||
1624 | const struct dentry_operations pid_dentry_operations = | 1664 | const struct dentry_operations pid_dentry_operations = |
1625 | { | 1665 | { |
1626 | .d_revalidate = pid_revalidate, | 1666 | .d_revalidate = pid_revalidate, |
@@ -2893,7 +2933,7 @@ retry: | |||
2893 | return iter; | 2933 | return iter; |
2894 | } | 2934 | } |
2895 | 2935 | ||
2896 | #define TGID_OFFSET (FIRST_PROCESS_ENTRY) | 2936 | #define TGID_OFFSET (FIRST_PROCESS_ENTRY + 1) |
2897 | 2937 | ||
2898 | static int proc_pid_fill_cache(struct file *filp, void *dirent, filldir_t filldir, | 2938 | static int proc_pid_fill_cache(struct file *filp, void *dirent, filldir_t filldir, |
2899 | struct tgid_iter iter) | 2939 | struct tgid_iter iter) |
@@ -2916,13 +2956,21 @@ int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir) | |||
2916 | struct tgid_iter iter; | 2956 | struct tgid_iter iter; |
2917 | struct pid_namespace *ns; | 2957 | struct pid_namespace *ns; |
2918 | filldir_t __filldir; | 2958 | filldir_t __filldir; |
2959 | loff_t pos = filp->f_pos; | ||
2919 | 2960 | ||
2920 | if (filp->f_pos >= PID_MAX_LIMIT + TGID_OFFSET) | 2961 | if (pos >= PID_MAX_LIMIT + TGID_OFFSET) |
2921 | goto out; | 2962 | goto out; |
2922 | 2963 | ||
2923 | ns = filp->f_dentry->d_sb->s_fs_info; | 2964 | if (pos == TGID_OFFSET - 1) { |
2965 | if (proc_fill_cache(filp, dirent, filldir, "self", 4, | ||
2966 | NULL, NULL, NULL) < 0) | ||
2967 | goto out; | ||
2968 | iter.tgid = 0; | ||
2969 | } else { | ||
2970 | iter.tgid = pos - TGID_OFFSET; | ||
2971 | } | ||
2924 | iter.task = NULL; | 2972 | iter.task = NULL; |
2925 | iter.tgid = filp->f_pos - TGID_OFFSET; | 2973 | ns = filp->f_dentry->d_sb->s_fs_info; |
2926 | for (iter = next_tgid(ns, iter); | 2974 | for (iter = next_tgid(ns, iter); |
2927 | iter.task; | 2975 | iter.task; |
2928 | iter.tgid += 1, iter = next_tgid(ns, iter)) { | 2976 | iter.tgid += 1, iter = next_tgid(ns, iter)) { |