]> Git Repo - linux.git/blame - fs/proc/proc_misc.c
proc: switch /proc/version to seq_file
[linux.git] / fs / proc / proc_misc.c
CommitLineData
1da177e4
LT
1/*
2 * linux/fs/proc/proc_misc.c
3 *
4 * linux/fs/proc/array.c
5 * Copyright (C) 1992 by Linus Torvalds
6 * based on ideas by Darren Senn
7 *
8 * This used to be the part of array.c. See the rest of history and credits
9 * there. I took this into a separate file and switched the thing to generic
10 * proc_file_inode_operations, leaving in array.c only per-process stuff.
11 * Inumbers allocation made dynamic (via create_proc_entry()). AV, May 1999.
12 *
13 * Changes:
14 * Fulton Green : Encapsulated position metric calculations.
15 * <[email protected]>
16 */
17
18#include <linux/types.h>
19#include <linux/errno.h>
20#include <linux/time.h>
21#include <linux/kernel.h>
22#include <linux/kernel_stat.h>
7170be5f 23#include <linux/fs.h>
1da177e4
LT
24#include <linux/tty.h>
25#include <linux/string.h>
26#include <linux/mman.h>
4b856152 27#include <linux/quicklist.h>
1da177e4
LT
28#include <linux/proc_fs.h>
29#include <linux/ioport.h>
1da177e4
LT
30#include <linux/mm.h>
31#include <linux/mmzone.h>
32#include <linux/pagemap.h>
c7fb03a4 33#include <linux/irq.h>
f74596d0 34#include <linux/interrupt.h>
1da177e4
LT
35#include <linux/swap.h>
36#include <linux/slab.h>
a0db701a 37#include <linux/genhd.h>
1da177e4
LT
38#include <linux/smp.h>
39#include <linux/signal.h>
40#include <linux/module.h>
41#include <linux/init.h>
1da177e4
LT
42#include <linux/seq_file.h>
43#include <linux/times.h>
44#include <linux/profile.h>
7bf65382 45#include <linux/utsname.h>
1da177e4
LT
46#include <linux/blkdev.h>
47#include <linux/hugetlb.h>
48#include <linux/jiffies.h>
1da177e4 49#include <linux/vmalloc.h>
666bfddb 50#include <linux/crash_dump.h>
61a58c6c 51#include <linux/pid_namespace.h>
161f47bf 52#include <linux/bootmem.h>
1da177e4
LT
53#include <asm/uaccess.h>
54#include <asm/pgtable.h>
55#include <asm/io.h>
56#include <asm/tlb.h>
57#include <asm/div64.h>
58#include "internal.h"
59
1da177e4
LT
60/*
61 * Warning: stuff below (imported functions) assumes that its output will fit
62 * into one page. For some of those functions it may be wrong. Moreover, we
63 * have a way to deal with that gracefully. Right now I used straightforward
64 * wrappers, but this needs further analysis wrt potential overflows.
65 */
66extern int get_hardware_list(char *);
67extern int get_stram_list(char *);
1da177e4 68extern int get_exec_domain_list(char *);
1da177e4
LT
69
70static int proc_calc_metrics(char *page, char **start, off_t off,
71 int count, int *eof, int len)
72{
73 if (len <= off+count) *eof = 1;
74 *start = page + off;
75 len -= off;
76 if (len>count) len = count;
77 if (len<0) len = 0;
78 return len;
79}
80
1da177e4
LT
81static int fragmentation_open(struct inode *inode, struct file *file)
82{
83 (void)inode;
84 return seq_open(file, &fragmentation_op);
85}
86
00977a59 87static const struct file_operations fragmentation_file_operations = {
1da177e4
LT
88 .open = fragmentation_open,
89 .read = seq_read,
90 .llseek = seq_lseek,
91 .release = seq_release,
92};
93
467c996c
MG
94static int pagetypeinfo_open(struct inode *inode, struct file *file)
95{
96 return seq_open(file, &pagetypeinfo_op);
97}
98
99static const struct file_operations pagetypeinfo_file_ops = {
100 .open = pagetypeinfo_open,
101 .read = seq_read,
102 .llseek = seq_lseek,
103 .release = seq_release,
104};
105
295ab934
ND
106static int zoneinfo_open(struct inode *inode, struct file *file)
107{
108 return seq_open(file, &zoneinfo_op);
109}
110
00977a59 111static const struct file_operations proc_zoneinfo_file_operations = {
295ab934
ND
112 .open = zoneinfo_open,
113 .read = seq_read,
114 .llseek = seq_lseek,
115 .release = seq_release,
116};
117
03a44825 118extern const struct seq_operations cpuinfo_op;
1da177e4
LT
119static int cpuinfo_open(struct inode *inode, struct file *file)
120{
121 return seq_open(file, &cpuinfo_op);
122}
7170be5f 123
00977a59 124static const struct file_operations proc_cpuinfo_operations = {
68eef3b4
JK
125 .open = cpuinfo_open,
126 .read = seq_read,
127 .llseek = seq_lseek,
128 .release = seq_release,
7170be5f
NH
129};
130
68eef3b4 131static int devinfo_show(struct seq_file *f, void *v)
7170be5f 132{
68eef3b4
JK
133 int i = *(loff_t *) v;
134
135 if (i < CHRDEV_MAJOR_HASH_SIZE) {
136 if (i == 0)
137 seq_printf(f, "Character devices:\n");
138 chrdev_show(f, i);
9361401e
DH
139 }
140#ifdef CONFIG_BLOCK
141 else {
68eef3b4
JK
142 i -= CHRDEV_MAJOR_HASH_SIZE;
143 if (i == 0)
144 seq_printf(f, "\nBlock devices:\n");
145 blkdev_show(f, i);
7170be5f 146 }
9361401e 147#endif
68eef3b4 148 return 0;
7170be5f
NH
149}
150
68eef3b4 151static void *devinfo_start(struct seq_file *f, loff_t *pos)
7170be5f 152{
68eef3b4
JK
153 if (*pos < (BLKDEV_MAJOR_HASH_SIZE + CHRDEV_MAJOR_HASH_SIZE))
154 return pos;
155 return NULL;
7170be5f
NH
156}
157
68eef3b4 158static void *devinfo_next(struct seq_file *f, void *v, loff_t *pos)
7170be5f 159{
68eef3b4
JK
160 (*pos)++;
161 if (*pos >= (BLKDEV_MAJOR_HASH_SIZE + CHRDEV_MAJOR_HASH_SIZE))
162 return NULL;
163 return pos;
7170be5f
NH
164}
165
68eef3b4 166static void devinfo_stop(struct seq_file *f, void *v)
7170be5f 167{
68eef3b4 168 /* Nothing to do */
7170be5f
NH
169}
170
03a44825 171static const struct seq_operations devinfo_ops = {
68eef3b4
JK
172 .start = devinfo_start,
173 .next = devinfo_next,
174 .stop = devinfo_stop,
175 .show = devinfo_show
7170be5f
NH
176};
177
68eef3b4 178static int devinfo_open(struct inode *inode, struct file *filp)
7170be5f 179{
68eef3b4 180 return seq_open(filp, &devinfo_ops);
7170be5f
NH
181}
182
00977a59 183static const struct file_operations proc_devinfo_operations = {
7170be5f
NH
184 .open = devinfo_open,
185 .read = seq_read,
186 .llseek = seq_lseek,
187 .release = seq_release,
188};
189
1da177e4
LT
190static int vmstat_open(struct inode *inode, struct file *file)
191{
192 return seq_open(file, &vmstat_op);
193}
00977a59 194static const struct file_operations proc_vmstat_file_operations = {
1da177e4
LT
195 .open = vmstat_open,
196 .read = seq_read,
197 .llseek = seq_lseek,
198 .release = seq_release,
199};
200
201#ifdef CONFIG_PROC_HARDWARE
202static int hardware_read_proc(char *page, char **start, off_t off,
203 int count, int *eof, void *data)
204{
205 int len = get_hardware_list(page);
206 return proc_calc_metrics(page, start, off, count, eof, len);
207}
208#endif
209
210#ifdef CONFIG_STRAM_PROC
211static int stram_read_proc(char *page, char **start, off_t off,
212 int count, int *eof, void *data)
213{
214 int len = get_stram_list(page);
215 return proc_calc_metrics(page, start, off, count, eof, len);
216}
217#endif
218
9361401e 219#ifdef CONFIG_BLOCK
1da177e4
LT
220static int partitions_open(struct inode *inode, struct file *file)
221{
222 return seq_open(file, &partitions_op);
223}
00977a59 224static const struct file_operations proc_partitions_operations = {
1da177e4
LT
225 .open = partitions_open,
226 .read = seq_read,
227 .llseek = seq_lseek,
228 .release = seq_release,
229};
230
1da177e4
LT
231static int diskstats_open(struct inode *inode, struct file *file)
232{
233 return seq_open(file, &diskstats_op);
234}
00977a59 235static const struct file_operations proc_diskstats_operations = {
1da177e4
LT
236 .open = diskstats_open,
237 .read = seq_read,
238 .llseek = seq_lseek,
239 .release = seq_release,
240};
9361401e 241#endif
1da177e4
LT
242
243#ifdef CONFIG_MODULES
03a44825 244extern const struct seq_operations modules_op;
1da177e4
LT
245static int modules_open(struct inode *inode, struct file *file)
246{
247 return seq_open(file, &modules_op);
248}
00977a59 249static const struct file_operations proc_modules_operations = {
1da177e4
LT
250 .open = modules_open,
251 .read = seq_read,
252 .llseek = seq_lseek,
253 .release = seq_release,
254};
255#endif
256
158a9624 257#ifdef CONFIG_SLABINFO
1da177e4
LT
258static int slabinfo_open(struct inode *inode, struct file *file)
259{
260 return seq_open(file, &slabinfo_op);
261}
00977a59 262static const struct file_operations proc_slabinfo_operations = {
1da177e4
LT
263 .open = slabinfo_open,
264 .read = seq_read,
265 .write = slabinfo_write,
266 .llseek = seq_lseek,
267 .release = seq_release,
268};
871751e2
AV
269
270#ifdef CONFIG_DEBUG_SLAB_LEAK
03a44825 271extern const struct seq_operations slabstats_op;
871751e2
AV
272static int slabstats_open(struct inode *inode, struct file *file)
273{
274 unsigned long *n = kzalloc(PAGE_SIZE, GFP_KERNEL);
275 int ret = -ENOMEM;
276 if (n) {
277 ret = seq_open(file, &slabstats_op);
278 if (!ret) {
279 struct seq_file *m = file->private_data;
280 *n = PAGE_SIZE / (2 * sizeof(unsigned long));
281 m->private = n;
282 n = NULL;
283 }
284 kfree(n);
285 }
286 return ret;
287}
288
00977a59 289static const struct file_operations proc_slabstats_operations = {
871751e2
AV
290 .open = slabstats_open,
291 .read = seq_read,
292 .llseek = seq_lseek,
09f0892e 293 .release = seq_release_private,
871751e2
AV
294};
295#endif
10cef602 296#endif
1da177e4 297
a10aa579
CL
298#ifdef CONFIG_MMU
299static int vmalloc_open(struct inode *inode, struct file *file)
300{
a47a126a
ED
301 unsigned int *ptr = NULL;
302 int ret;
303
304 if (NUMA_BUILD)
305 ptr = kmalloc(nr_node_ids * sizeof(unsigned int), GFP_KERNEL);
306 ret = seq_open(file, &vmalloc_op);
307 if (!ret) {
308 struct seq_file *m = file->private_data;
309 m->private = ptr;
310 } else
311 kfree(ptr);
312 return ret;
a10aa579
CL
313}
314
315static const struct file_operations proc_vmalloc_operations = {
316 .open = vmalloc_open,
317 .read = seq_read,
318 .llseek = seq_lseek,
a47a126a 319 .release = seq_release_private,
a10aa579
CL
320};
321#endif
322
a2eddfa9
JB
323#ifndef arch_irq_stat_cpu
324#define arch_irq_stat_cpu(cpu) 0
325#endif
326#ifndef arch_irq_stat
327#define arch_irq_stat() 0
328#endif
329
1da177e4
LT
330static int show_stat(struct seq_file *p, void *v)
331{
c7fb03a4 332 int i, j;
1da177e4
LT
333 unsigned long jif;
334 cputime64_t user, nice, system, idle, iowait, irq, softirq, steal;
5e84cfde 335 cputime64_t guest;
1da177e4 336 u64 sum = 0;
924b42d5 337 struct timespec boottime;
c7fb03a4 338 unsigned int per_irq_sum;
1da177e4
LT
339
340 user = nice = system = idle = iowait =
341 irq = softirq = steal = cputime64_zero;
5e84cfde 342 guest = cputime64_zero;
924b42d5
TJ
343 getboottime(&boottime);
344 jif = boottime.tv_sec;
1da177e4 345
0a945022 346 for_each_possible_cpu(i) {
1da177e4
LT
347 user = cputime64_add(user, kstat_cpu(i).cpustat.user);
348 nice = cputime64_add(nice, kstat_cpu(i).cpustat.nice);
349 system = cputime64_add(system, kstat_cpu(i).cpustat.system);
350 idle = cputime64_add(idle, kstat_cpu(i).cpustat.idle);
351 iowait = cputime64_add(iowait, kstat_cpu(i).cpustat.iowait);
352 irq = cputime64_add(irq, kstat_cpu(i).cpustat.irq);
353 softirq = cputime64_add(softirq, kstat_cpu(i).cpustat.softirq);
354 steal = cputime64_add(steal, kstat_cpu(i).cpustat.steal);
5e84cfde 355 guest = cputime64_add(guest, kstat_cpu(i).cpustat.guest);
2cc21ef8 356
2be3b52a 357 for_each_irq_nr(j)
2cc21ef8 358 sum += kstat_irqs_cpu(j, i);
c7fb03a4 359
a2eddfa9 360 sum += arch_irq_stat_cpu(i);
1da177e4 361 }
a2eddfa9 362 sum += arch_irq_stat();
1da177e4 363
5e84cfde 364 seq_printf(p, "cpu %llu %llu %llu %llu %llu %llu %llu %llu %llu\n",
1da177e4
LT
365 (unsigned long long)cputime64_to_clock_t(user),
366 (unsigned long long)cputime64_to_clock_t(nice),
367 (unsigned long long)cputime64_to_clock_t(system),
368 (unsigned long long)cputime64_to_clock_t(idle),
369 (unsigned long long)cputime64_to_clock_t(iowait),
370 (unsigned long long)cputime64_to_clock_t(irq),
371 (unsigned long long)cputime64_to_clock_t(softirq),
5e84cfde
LV
372 (unsigned long long)cputime64_to_clock_t(steal),
373 (unsigned long long)cputime64_to_clock_t(guest));
1da177e4
LT
374 for_each_online_cpu(i) {
375
376 /* Copy values here to work around gcc-2.95.3, gcc-2.96 */
377 user = kstat_cpu(i).cpustat.user;
378 nice = kstat_cpu(i).cpustat.nice;
379 system = kstat_cpu(i).cpustat.system;
380 idle = kstat_cpu(i).cpustat.idle;
381 iowait = kstat_cpu(i).cpustat.iowait;
382 irq = kstat_cpu(i).cpustat.irq;
383 softirq = kstat_cpu(i).cpustat.softirq;
384 steal = kstat_cpu(i).cpustat.steal;
5e84cfde
LV
385 guest = kstat_cpu(i).cpustat.guest;
386 seq_printf(p,
387 "cpu%d %llu %llu %llu %llu %llu %llu %llu %llu %llu\n",
1da177e4
LT
388 i,
389 (unsigned long long)cputime64_to_clock_t(user),
390 (unsigned long long)cputime64_to_clock_t(nice),
391 (unsigned long long)cputime64_to_clock_t(system),
392 (unsigned long long)cputime64_to_clock_t(idle),
393 (unsigned long long)cputime64_to_clock_t(iowait),
394 (unsigned long long)cputime64_to_clock_t(irq),
395 (unsigned long long)cputime64_to_clock_t(softirq),
5e84cfde
LV
396 (unsigned long long)cputime64_to_clock_t(steal),
397 (unsigned long long)cputime64_to_clock_t(guest));
1da177e4
LT
398 }
399 seq_printf(p, "intr %llu", (unsigned long long)sum);
400
c7fb03a4 401 /* sum again ? it could be updated? */
2be3b52a 402 for_each_irq_nr(j) {
c7fb03a4 403 per_irq_sum = 0;
c7fb03a4 404
2cc21ef8
TG
405 for_each_possible_cpu(i)
406 per_irq_sum += kstat_irqs_cpu(j, i);
c7fb03a4 407
c7fb03a4 408 seq_printf(p, " %u", per_irq_sum);
c7fb03a4 409 }
1da177e4
LT
410
411 seq_printf(p,
412 "\nctxt %llu\n"
413 "btime %lu\n"
414 "processes %lu\n"
415 "procs_running %lu\n"
416 "procs_blocked %lu\n",
417 nr_context_switches(),
418 (unsigned long)jif,
419 total_forks,
420 nr_running(),
421 nr_iowait());
422
423 return 0;
424}
425
426static int stat_open(struct inode *inode, struct file *file)
427{
428 unsigned size = 4096 * (1 + num_possible_cpus() / 32);
429 char *buf;
430 struct seq_file *m;
431 int res;
432
433 /* don't ask for more than the kmalloc() max size, currently 128 KB */
434 if (size > 128 * 1024)
435 size = 128 * 1024;
436 buf = kmalloc(size, GFP_KERNEL);
437 if (!buf)
438 return -ENOMEM;
439
440 res = single_open(file, show_stat, NULL);
441 if (!res) {
442 m = file->private_data;
443 m->buf = buf;
444 m->size = size;
445 } else
446 kfree(buf);
447 return res;
448}
00977a59 449static const struct file_operations proc_stat_operations = {
1da177e4
LT
450 .open = stat_open,
451 .read = seq_read,
452 .llseek = seq_lseek,
453 .release = single_release,
454};
455
1da177e4
LT
456/*
457 * /proc/interrupts
458 */
459static void *int_seq_start(struct seq_file *f, loff_t *pos)
460{
da27c118 461 return (*pos <= nr_irqs) ? pos : NULL;
1da177e4
LT
462}
463
52b17329 464
1da177e4
LT
465static void *int_seq_next(struct seq_file *f, void *v, loff_t *pos)
466{
467 (*pos)++;
52b17329 468 return (*pos <= nr_irqs) ? pos : NULL;
1da177e4
LT
469}
470
471static void int_seq_stop(struct seq_file *f, void *v)
472{
473 /* Nothing to do */
474}
475
03a44825 476static const struct seq_operations int_seq_ops = {
1da177e4
LT
477 .start = int_seq_start,
478 .next = int_seq_next,
479 .stop = int_seq_stop,
480 .show = show_interrupts
481};
482
483static int interrupts_open(struct inode *inode, struct file *filp)
484{
485 return seq_open(filp, &int_seq_ops);
486}
487
00977a59 488static const struct file_operations proc_interrupts_operations = {
1da177e4
LT
489 .open = interrupts_open,
490 .read = seq_read,
491 .llseek = seq_lseek,
492 .release = seq_release,
493};
494
495static int filesystems_read_proc(char *page, char **start, off_t off,
496 int count, int *eof, void *data)
497{
498 int len = get_filesystem_list(page);
499 return proc_calc_metrics(page, start, off, count, eof, len);
500}
501
502static int cmdline_read_proc(char *page, char **start, off_t off,
503 int count, int *eof, void *data)
504{
505 int len;
506
507 len = sprintf(page, "%s\n", saved_command_line);
508 return proc_calc_metrics(page, start, off, count, eof, len);
509}
510
bfcd17a6 511#ifdef CONFIG_FILE_LOCKING
7f8ada98 512static int locks_open(struct inode *inode, struct file *filp)
1da177e4 513{
7f8ada98 514 return seq_open(filp, &locks_seq_operations);
1da177e4
LT
515}
516
7f8ada98
PE
517static const struct file_operations proc_locks_operations = {
518 .open = locks_open,
519 .read = seq_read,
520 .llseek = seq_lseek,
521 .release = seq_release,
522};
bfcd17a6 523#endif /* CONFIG_FILE_LOCKING */
7f8ada98 524
1da177e4
LT
525static int execdomains_read_proc(char *page, char **start, off_t off,
526 int count, int *eof, void *data)
527{
528 int len = get_exec_domain_list(page);
529 return proc_calc_metrics(page, start, off, count, eof, len);
530}
531
1e883281 532#ifdef CONFIG_PROC_PAGE_MONITOR
161f47bf
MM
533#define KPMSIZE sizeof(u64)
534#define KPMMASK (KPMSIZE - 1)
535/* /proc/kpagecount - an array exposing page counts
536 *
537 * Each entry is a u64 representing the corresponding
538 * physical page count.
539 */
540static ssize_t kpagecount_read(struct file *file, char __user *buf,
541 size_t count, loff_t *ppos)
542{
543 u64 __user *out = (u64 __user *)buf;
544 struct page *ppage;
545 unsigned long src = *ppos;
546 unsigned long pfn;
547 ssize_t ret = 0;
548 u64 pcount;
549
550 pfn = src / KPMSIZE;
551 count = min_t(size_t, count, (max_pfn * KPMSIZE) - src);
552 if (src & KPMMASK || count & KPMMASK)
4710d1ac 553 return -EINVAL;
161f47bf
MM
554
555 while (count > 0) {
304daa81
MM
556 ppage = NULL;
557 if (pfn_valid(pfn))
558 ppage = pfn_to_page(pfn);
559 pfn++;
161f47bf
MM
560 if (!ppage)
561 pcount = 0;
562 else
bbcdac0c 563 pcount = page_mapcount(ppage);
161f47bf
MM
564
565 if (put_user(pcount, out++)) {
566 ret = -EFAULT;
567 break;
568 }
569
570 count -= KPMSIZE;
571 }
572
573 *ppos += (char __user *)out - buf;
574 if (!ret)
575 ret = (char __user *)out - buf;
576 return ret;
577}
578
579static struct file_operations proc_kpagecount_operations = {
580 .llseek = mem_lseek,
581 .read = kpagecount_read,
582};
583
304daa81
MM
584/* /proc/kpageflags - an array exposing page flags
585 *
586 * Each entry is a u64 representing the corresponding
587 * physical page flags.
588 */
589
590/* These macros are used to decouple internal flags from exported ones */
591
592#define KPF_LOCKED 0
593#define KPF_ERROR 1
594#define KPF_REFERENCED 2
595#define KPF_UPTODATE 3
596#define KPF_DIRTY 4
597#define KPF_LRU 5
598#define KPF_ACTIVE 6
599#define KPF_SLAB 7
600#define KPF_WRITEBACK 8
601#define KPF_RECLAIM 9
602#define KPF_BUDDY 10
603
604#define kpf_copy_bit(flags, srcpos, dstpos) (((flags >> srcpos) & 1) << dstpos)
605
606static ssize_t kpageflags_read(struct file *file, char __user *buf,
607 size_t count, loff_t *ppos)
608{
609 u64 __user *out = (u64 __user *)buf;
610 struct page *ppage;
611 unsigned long src = *ppos;
612 unsigned long pfn;
613 ssize_t ret = 0;
614 u64 kflags, uflags;
615
616 pfn = src / KPMSIZE;
617 count = min_t(unsigned long, count, (max_pfn * KPMSIZE) - src);
618 if (src & KPMMASK || count & KPMMASK)
4710d1ac 619 return -EINVAL;
304daa81
MM
620
621 while (count > 0) {
622 ppage = NULL;
623 if (pfn_valid(pfn))
624 ppage = pfn_to_page(pfn);
625 pfn++;
626 if (!ppage)
627 kflags = 0;
628 else
629 kflags = ppage->flags;
630
631 uflags = kpf_copy_bit(KPF_LOCKED, PG_locked, kflags) |
632 kpf_copy_bit(kflags, KPF_ERROR, PG_error) |
633 kpf_copy_bit(kflags, KPF_REFERENCED, PG_referenced) |
634 kpf_copy_bit(kflags, KPF_UPTODATE, PG_uptodate) |
635 kpf_copy_bit(kflags, KPF_DIRTY, PG_dirty) |
636 kpf_copy_bit(kflags, KPF_LRU, PG_lru) |
637 kpf_copy_bit(kflags, KPF_ACTIVE, PG_active) |
638 kpf_copy_bit(kflags, KPF_SLAB, PG_slab) |
639 kpf_copy_bit(kflags, KPF_WRITEBACK, PG_writeback) |
640 kpf_copy_bit(kflags, KPF_RECLAIM, PG_reclaim) |
641 kpf_copy_bit(kflags, KPF_BUDDY, PG_buddy);
642
643 if (put_user(uflags, out++)) {
644 ret = -EFAULT;
645 break;
646 }
647
648 count -= KPMSIZE;
649 }
650
651 *ppos += (char __user *)out - buf;
652 if (!ret)
653 ret = (char __user *)out - buf;
654 return ret;
655}
656
657static struct file_operations proc_kpageflags_operations = {
658 .llseek = mem_lseek,
659 .read = kpageflags_read,
660};
1e883281 661#endif /* CONFIG_PROC_PAGE_MONITOR */
304daa81 662
1da177e4
LT
663struct proc_dir_entry *proc_root_kcore;
664
1da177e4
LT
665void __init proc_misc_init(void)
666{
1da177e4
LT
667 static struct {
668 char *name;
669 int (*read_proc)(char*,char**,off_t,int,int*,void*);
670 } *p, simple_ones[] = {
1da177e4
LT
671#ifdef CONFIG_PROC_HARDWARE
672 {"hardware", hardware_read_proc},
673#endif
674#ifdef CONFIG_STRAM_PROC
675 {"stram", stram_read_proc},
676#endif
1da177e4
LT
677 {"filesystems", filesystems_read_proc},
678 {"cmdline", cmdline_read_proc},
1da177e4
LT
679 {"execdomains", execdomains_read_proc},
680 {NULL,}
681 };
682 for (p = simple_ones; p->name; p++)
683 create_proc_read_entry(p->name, 0, NULL, p->read_proc, NULL);
684
685 proc_symlink("mounts", NULL, "self/mounts");
686
687 /* And now for trickier ones */
c36264df 688#ifdef CONFIG_PRINTK
c74c120a 689 proc_create("kmsg", S_IRUSR, NULL, &proc_kmsg_operations);
c36264df 690#endif
bfcd17a6 691#ifdef CONFIG_FILE_LOCKING
0d5c9f5f 692 proc_create("locks", 0, NULL, &proc_locks_operations);
bfcd17a6 693#endif
0d5c9f5f
AD
694 proc_create("devices", 0, NULL, &proc_devinfo_operations);
695 proc_create("cpuinfo", 0, NULL, &proc_cpuinfo_operations);
9361401e 696#ifdef CONFIG_BLOCK
0d5c9f5f 697 proc_create("partitions", 0, NULL, &proc_partitions_operations);
9361401e 698#endif
0d5c9f5f
AD
699 proc_create("stat", 0, NULL, &proc_stat_operations);
700 proc_create("interrupts", 0, NULL, &proc_interrupts_operations);
158a9624 701#ifdef CONFIG_SLABINFO
0d5c9f5f 702 proc_create("slabinfo",S_IWUSR|S_IRUGO,NULL,&proc_slabinfo_operations);
871751e2 703#ifdef CONFIG_DEBUG_SLAB_LEAK
0d5c9f5f 704 proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
871751e2 705#endif
a10aa579
CL
706#endif
707#ifdef CONFIG_MMU
708 proc_create("vmallocinfo", S_IRUSR, NULL, &proc_vmalloc_operations);
10cef602 709#endif
0d5c9f5f
AD
710 proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
711 proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
712 proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
713 proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
9361401e 714#ifdef CONFIG_BLOCK
0d5c9f5f 715 proc_create("diskstats", 0, NULL, &proc_diskstats_operations);
9361401e 716#endif
1da177e4 717#ifdef CONFIG_MODULES
0d5c9f5f 718 proc_create("modules", 0, NULL, &proc_modules_operations);
1da177e4
LT
719#endif
720#ifdef CONFIG_SCHEDSTATS
0d5c9f5f 721 proc_create("schedstat", 0, NULL, &proc_schedstat_operations);
1da177e4
LT
722#endif
723#ifdef CONFIG_PROC_KCORE
0d5c9f5f
AD
724 proc_root_kcore = proc_create("kcore", S_IRUSR, NULL, &proc_kcore_operations);
725 if (proc_root_kcore)
1da177e4
LT
726 proc_root_kcore->size =
727 (size_t)high_memory - PAGE_OFFSET + PAGE_SIZE;
1da177e4 728#endif
1e883281 729#ifdef CONFIG_PROC_PAGE_MONITOR
0d5c9f5f
AD
730 proc_create("kpagecount", S_IRUSR, NULL, &proc_kpagecount_operations);
731 proc_create("kpageflags", S_IRUSR, NULL, &proc_kpageflags_operations);
1e883281 732#endif
666bfddb 733#ifdef CONFIG_PROC_VMCORE
0d5c9f5f 734 proc_vmcore = proc_create("vmcore", S_IRUSR, NULL, &proc_vmcore_operations);
666bfddb 735#endif
1da177e4 736}
This page took 0.634318 seconds and 4 git commands to generate.