Skip to content

Commit 6e62775

Browse files
author
Alexey Dobriyan
committed
proc: move /proc/execdomains to kernel/exec_domain.c
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
1 parent cf9887f commit 6e62775

2 files changed

Lines changed: 27 additions & 15 deletions

File tree

‎fs/proc/proc_misc.c‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
* have a way to deal with that gracefully. Right now I used straightforward
6464
* wrappers, but this needs further analysis wrt potential overflows.
6565
*/
66-
extern int get_exec_domain_list(char *);
6766

6867
static int proc_calc_metrics(char *page, char **start, off_t off,
6968
int count, int *eof, int len)
@@ -486,13 +485,6 @@ static const struct file_operations proc_locks_operations = {
486485
};
487486
#endif /* CONFIG_FILE_LOCKING */
488487

489-
static int execdomains_read_proc(char *page, char **start, off_t off,
490-
int count, int *eof, void *data)
491-
{
492-
int len = get_exec_domain_list(page);
493-
return proc_calc_metrics(page, start, off, count, eof, len);
494-
}
495-
496488
#ifdef CONFIG_PROC_PAGE_MONITOR
497489
#define KPMSIZE sizeof(u64)
498490
#define KPMMASK (KPMSIZE - 1)
@@ -632,7 +624,6 @@ void __init proc_misc_init(void)
632624
char *name;
633625
int (*read_proc)(char*,char**,off_t,int,int*,void*);
634626
} *p, simple_ones[] = {
635-
{"execdomains", execdomains_read_proc},
636627
{NULL,}
637628
};
638629
for (p = simple_ones; p->name; p++)

‎kernel/exec_domain.c‎

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
#include <linux/kmod.h>
1313
#include <linux/module.h>
1414
#include <linux/personality.h>
15+
#include <linux/proc_fs.h>
1516
#include <linux/sched.h>
17+
#include <linux/seq_file.h>
1618
#include <linux/syscalls.h>
1719
#include <linux/sysctl.h>
1820
#include <linux/types.h>
@@ -173,20 +175,39 @@ __set_personality(u_long personality)
173175
return 0;
174176
}
175177

176-
int
177-
get_exec_domain_list(char *page)
178+
#ifdef CONFIG_PROC_FS
179+
static int execdomains_proc_show(struct seq_file *m, void *v)
178180
{
179181
struct exec_domain *ep;
180-
int len = 0;
181182

182183
read_lock(&exec_domains_lock);
183-
for (ep = exec_domains; ep && len < PAGE_SIZE - 80; ep = ep->next)
184-
len += sprintf(page + len, "%d-%d\t%-16s\t[%s]\n",
184+
for (ep = exec_domains; ep; ep = ep->next)
185+
seq_printf(m, "%d-%d\t%-16s\t[%s]\n",
185186
ep->pers_low, ep->pers_high, ep->name,
186187
module_name(ep->module));
187188
read_unlock(&exec_domains_lock);
188-
return (len);
189+
return 0;
190+
}
191+
192+
static int execdomains_proc_open(struct inode *inode, struct file *file)
193+
{
194+
return single_open(file, execdomains_proc_show, NULL);
195+
}
196+
197+
static const struct file_operations execdomains_proc_fops = {
198+
.open = execdomains_proc_open,
199+
.read = seq_read,
200+
.llseek = seq_lseek,
201+
.release = single_release,
202+
};
203+
204+
static int __init proc_execdomains_init(void)
205+
{
206+
proc_create("execdomains", 0, NULL, &execdomains_proc_fops);
207+
return 0;
189208
}
209+
module_init(proc_execdomains_init);
210+
#endif
190211

191212
asmlinkage long
192213
sys_personality(u_long personality)

0 commit comments

Comments
 (0)