diff options
Diffstat (limited to 'fs/proc/base.c')
-rw-r--r-- | fs/proc/base.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c index c447e0743a3c..3b455371e7ff 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -127,6 +127,25 @@ struct pid_entry { | |||
127 | NULL, &proc_single_file_operations, \ | 127 | NULL, &proc_single_file_operations, \ |
128 | { .proc_show = &proc_##OTYPE } ) | 128 | { .proc_show = &proc_##OTYPE } ) |
129 | 129 | ||
130 | /* | ||
131 | * Count the number of hardlinks for the pid_entry table, excluding the . | ||
132 | * and .. links. | ||
133 | */ | ||
134 | static unsigned int pid_entry_count_dirs(const struct pid_entry *entries, | ||
135 | unsigned int n) | ||
136 | { | ||
137 | unsigned int i; | ||
138 | unsigned int count; | ||
139 | |||
140 | count = 0; | ||
141 | for (i = 0; i < n; ++i) { | ||
142 | if (S_ISDIR(entries[i].mode)) | ||
143 | ++count; | ||
144 | } | ||
145 | |||
146 | return count; | ||
147 | } | ||
148 | |||
130 | int maps_protect; | 149 | int maps_protect; |
131 | EXPORT_SYMBOL(maps_protect); | 150 | EXPORT_SYMBOL(maps_protect); |
132 | 151 | ||
@@ -2585,10 +2604,9 @@ static struct dentry *proc_pid_instantiate(struct inode *dir, | |||
2585 | inode->i_op = &proc_tgid_base_inode_operations; | 2604 | inode->i_op = &proc_tgid_base_inode_operations; |
2586 | inode->i_fop = &proc_tgid_base_operations; | 2605 | inode->i_fop = &proc_tgid_base_operations; |
2587 | inode->i_flags|=S_IMMUTABLE; | 2606 | inode->i_flags|=S_IMMUTABLE; |
2588 | inode->i_nlink = 5; | 2607 | |
2589 | #ifdef CONFIG_SECURITY | 2608 | inode->i_nlink = 2 + pid_entry_count_dirs(tgid_base_stuff, |
2590 | inode->i_nlink += 1; | 2609 | ARRAY_SIZE(tgid_base_stuff)); |
2591 | #endif | ||
2592 | 2610 | ||
2593 | dentry->d_op = &pid_dentry_operations; | 2611 | dentry->d_op = &pid_dentry_operations; |
2594 | 2612 | ||
@@ -2816,10 +2834,9 @@ static struct dentry *proc_task_instantiate(struct inode *dir, | |||
2816 | inode->i_op = &proc_tid_base_inode_operations; | 2834 | inode->i_op = &proc_tid_base_inode_operations; |
2817 | inode->i_fop = &proc_tid_base_operations; | 2835 | inode->i_fop = &proc_tid_base_operations; |
2818 | inode->i_flags|=S_IMMUTABLE; | 2836 | inode->i_flags|=S_IMMUTABLE; |
2819 | inode->i_nlink = 4; | 2837 | |
2820 | #ifdef CONFIG_SECURITY | 2838 | inode->i_nlink = 2 + pid_entry_count_dirs(tid_base_stuff, |
2821 | inode->i_nlink += 1; | 2839 | ARRAY_SIZE(tid_base_stuff)); |
2822 | #endif | ||
2823 | 2840 | ||
2824 | dentry->d_op = &pid_dentry_operations; | 2841 | dentry->d_op = &pid_dentry_operations; |
2825 | 2842 | ||