cleaning up after merge
[linux-2.6.git] / fs / proc / proc_misc.c
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  *                      <kernel@FultonGreen.com>
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>
23 #include <linux/fs.h>
24 #include <linux/tty.h>
25 #include <linux/string.h>
26 #include <linux/mman.h>
27 #include <linux/proc_fs.h>
28 #include <linux/ioport.h>
29 #include <linux/mm.h>
30 #include <linux/mmzone.h>
31 #include <linux/pagemap.h>
32 #include <linux/swap.h>
33 #include <linux/slab.h>
34 #include <linux/smp.h>
35 #include <linux/signal.h>
36 #include <linux/module.h>
37 #include <linux/init.h>
38 #include <linux/smp_lock.h>
39 #include <linux/seq_file.h>
40 #include <linux/times.h>
41 #include <linux/profile.h>
42 #include <linux/blkdev.h>
43 #include <linux/hugetlb.h>
44 #include <linux/jiffies.h>
45 #include <linux/sysrq.h>
46 #include <linux/vmalloc.h>
47 #include <linux/crash_dump.h>
48 #include <asm/uaccess.h>
49 #include <asm/pgtable.h>
50 #include <asm/io.h>
51 #include <asm/tlb.h>
52 #include <asm/div64.h>
53 #include "internal.h"
54 #include <linux/vs_cvirt.h>
55
56 #define LOAD_INT(x) ((x) >> FSHIFT)
57 #define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100)
58 /*
59  * Warning: stuff below (imported functions) assumes that its output will fit
60  * into one page. For some of those functions it may be wrong. Moreover, we
61  * have a way to deal with that gracefully. Right now I used straightforward
62  * wrappers, but this needs further analysis wrt potential overflows.
63  */
64 extern int get_hardware_list(char *);
65 extern int get_stram_list(char *);
66 extern int get_filesystem_list(char *);
67 extern int get_exec_domain_list(char *);
68 extern int get_dma_list(char *);
69 extern int get_locks_status (char *, char **, off_t, int);
70
71 static int proc_calc_metrics(char *page, char **start, off_t off,
72                                  int count, int *eof, int len)
73 {
74         if (len <= off+count) *eof = 1;
75         *start = page + off;
76         len -= off;
77         if (len>count) len = count;
78         if (len<0) len = 0;
79         return len;
80 }
81
82 static int loadavg_read_proc(char *page, char **start, off_t off,
83                                  int count, int *eof, void *data)
84 {
85         unsigned int running, threads;
86         int a, b, c;
87         int len;
88
89         if (vx_flags(VXF_VIRT_LOAD, 0)) {
90                 struct vx_info *vxi = current->vx_info;
91
92                 a = vxi->cvirt.load[0] + (FIXED_1/200);
93                 b = vxi->cvirt.load[1] + (FIXED_1/200);
94                 c = vxi->cvirt.load[2] + (FIXED_1/200);
95
96                 running = atomic_read(&vxi->cvirt.nr_running);
97                 threads = atomic_read(&vxi->cvirt.nr_threads);
98         } else {
99                 a = avenrun[0] + (FIXED_1/200);
100                 b = avenrun[1] + (FIXED_1/200);
101                 c = avenrun[2] + (FIXED_1/200);
102
103                 running = nr_running();
104                 threads = nr_threads;
105         }
106         len = sprintf(page,"%d.%02d %d.%02d %d.%02d %d/%d %d\n",
107                 LOAD_INT(a), LOAD_FRAC(a),
108                 LOAD_INT(b), LOAD_FRAC(b),
109                 LOAD_INT(c), LOAD_FRAC(c),
110                 running, threads, last_pid);
111         return proc_calc_metrics(page, start, off, count, eof, len);
112 }
113
114 static int uptime_read_proc(char *page, char **start, off_t off,
115                                  int count, int *eof, void *data)
116 {
117         struct timespec uptime;
118         struct timespec idle;
119         int len;
120         cputime_t idletime = cputime_add(init_task.utime, init_task.stime);
121
122         do_posix_clock_monotonic_gettime(&uptime);
123         cputime_to_timespec(idletime, &idle);
124         if (vx_flags(VXF_VIRT_UPTIME, 0))
125                 vx_vsi_uptime(&uptime, &idle);
126
127         len = sprintf(page,"%lu.%02lu %lu.%02lu\n",
128                         (unsigned long) uptime.tv_sec,
129                         (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
130                         (unsigned long) idle.tv_sec,
131                         (idle.tv_nsec / (NSEC_PER_SEC / 100)));
132
133         return proc_calc_metrics(page, start, off, count, eof, len);
134 }
135
136 static int meminfo_read_proc(char *page, char **start, off_t off,
137                                  int count, int *eof, void *data)
138 {
139         struct sysinfo i;
140         int len;
141         unsigned long inactive;
142         unsigned long active;
143         unsigned long free;
144         unsigned long committed;
145         unsigned long allowed;
146         struct vmalloc_info vmi;
147         long cached;
148
149         get_zone_counts(&active, &inactive, &free);
150
151 /*
152  * display in kilobytes.
153  */
154 #define K(x) ((x) << (PAGE_SHIFT - 10))
155         si_meminfo(&i);
156         si_swapinfo(&i);
157         committed = atomic_read(&vm_committed_space);
158         allowed = ((totalram_pages - hugetlb_total_pages())
159                 * sysctl_overcommit_ratio / 100) + total_swap_pages;
160
161         cached = global_page_state(NR_FILE_PAGES) -
162                         total_swapcache_pages - i.bufferram;
163         if (cached < 0 || vx_flags(VXF_VIRT_MEM, 0))
164                 cached = 0;
165
166         get_vmalloc_info(&vmi);
167
168         /*
169          * Tagged format, for easy grepping and expansion.
170          */
171         len = sprintf(page,
172                 "MemTotal:     %8lu kB\n"
173                 "MemFree:      %8lu kB\n"
174                 "Buffers:      %8lu kB\n"
175                 "Cached:       %8lu kB\n"
176                 "SwapCached:   %8lu kB\n"
177                 "Active:       %8lu kB\n"
178                 "Inactive:     %8lu kB\n"
179                 "HighTotal:    %8lu kB\n"
180                 "HighFree:     %8lu kB\n"
181                 "LowTotal:     %8lu kB\n"
182                 "LowFree:      %8lu kB\n"
183                 "SwapTotal:    %8lu kB\n"
184                 "SwapFree:     %8lu kB\n"
185                 "Dirty:        %8lu kB\n"
186                 "Writeback:    %8lu kB\n"
187                 "AnonPages:    %8lu kB\n"
188                 "Mapped:       %8lu kB\n"
189                 "Slab:         %8lu kB\n"
190                 "PageTables:   %8lu kB\n"
191                 "NFS_Unstable: %8lu kB\n"
192                 "Bounce:       %8lu kB\n"
193                 "CommitLimit:  %8lu kB\n"
194                 "Committed_AS: %8lu kB\n"
195                 "VmallocTotal: %8lu kB\n"
196                 "VmallocUsed:  %8lu kB\n"
197                 "VmallocChunk: %8lu kB\n",
198                 K(i.totalram),
199                 K(i.freeram),
200                 K(i.bufferram),
201                 K(cached),
202                 K(total_swapcache_pages),
203                 K(active),
204                 K(inactive),
205                 K(i.totalhigh),
206                 K(i.freehigh),
207                 K(i.totalram-i.totalhigh),
208                 K(i.freeram-i.freehigh),
209                 K(i.totalswap),
210                 K(i.freeswap),
211                 K(global_page_state(NR_FILE_DIRTY)),
212                 K(global_page_state(NR_WRITEBACK)),
213                 K(global_page_state(NR_ANON_PAGES)),
214                 K(global_page_state(NR_FILE_MAPPED)),
215                 K(global_page_state(NR_SLAB)),
216                 K(global_page_state(NR_PAGETABLE)),
217                 K(global_page_state(NR_UNSTABLE_NFS)),
218                 K(global_page_state(NR_BOUNCE)),
219                 K(allowed),
220                 K(committed),
221                 (unsigned long)VMALLOC_TOTAL >> 10,
222                 vmi.used >> 10,
223                 vmi.largest_chunk >> 10
224                 );
225
226                 len += hugetlb_report_meminfo(page + len);
227
228         return proc_calc_metrics(page, start, off, count, eof, len);
229 #undef K
230 }
231
232 extern struct seq_operations fragmentation_op;
233 static int fragmentation_open(struct inode *inode, struct file *file)
234 {
235         (void)inode;
236         return seq_open(file, &fragmentation_op);
237 }
238
239 static struct file_operations fragmentation_file_operations = {
240         .open           = fragmentation_open,
241         .read           = seq_read,
242         .llseek         = seq_lseek,
243         .release        = seq_release,
244 };
245
246 extern struct seq_operations zoneinfo_op;
247 static int zoneinfo_open(struct inode *inode, struct file *file)
248 {
249         return seq_open(file, &zoneinfo_op);
250 }
251
252 static struct file_operations proc_zoneinfo_file_operations = {
253         .open           = zoneinfo_open,
254         .read           = seq_read,
255         .llseek         = seq_lseek,
256         .release        = seq_release,
257 };
258
259 static int version_read_proc(char *page, char **start, off_t off,
260                                  int count, int *eof, void *data)
261 {
262         int len;
263
264         len = sprintf(page, vx_linux_banner,
265                 vx_new_uts(release),
266                 vx_new_uts(version));
267         return proc_calc_metrics(page, start, off, count, eof, len);
268 }
269
270 extern struct seq_operations cpuinfo_op;
271 static int cpuinfo_open(struct inode *inode, struct file *file)
272 {
273         return seq_open(file, &cpuinfo_op);
274 }
275
276 static struct file_operations proc_cpuinfo_operations = {
277         .open           = cpuinfo_open,
278         .read           = seq_read,
279         .llseek         = seq_lseek,
280         .release        = seq_release,
281 };
282
283 static int devinfo_show(struct seq_file *f, void *v)
284 {
285         int i = *(loff_t *) v;
286
287         if (i < CHRDEV_MAJOR_HASH_SIZE) {
288                 if (i == 0)
289                         seq_printf(f, "Character devices:\n");
290                 chrdev_show(f, i);
291         } else {
292                 i -= CHRDEV_MAJOR_HASH_SIZE;
293                 if (i == 0)
294                         seq_printf(f, "\nBlock devices:\n");
295                 blkdev_show(f, i);
296         }
297         return 0;
298 }
299
300 static void *devinfo_start(struct seq_file *f, loff_t *pos)
301 {
302         if (*pos < (BLKDEV_MAJOR_HASH_SIZE + CHRDEV_MAJOR_HASH_SIZE))
303                 return pos;
304         return NULL;
305 }
306
307 static void *devinfo_next(struct seq_file *f, void *v, loff_t *pos)
308 {
309         (*pos)++;
310         if (*pos >= (BLKDEV_MAJOR_HASH_SIZE + CHRDEV_MAJOR_HASH_SIZE))
311                 return NULL;
312         return pos;
313 }
314
315 static void devinfo_stop(struct seq_file *f, void *v)
316 {
317         /* Nothing to do */
318 }
319
320 static struct seq_operations devinfo_ops = {
321         .start = devinfo_start,
322         .next  = devinfo_next,
323         .stop  = devinfo_stop,
324         .show  = devinfo_show
325 };
326
327 static int devinfo_open(struct inode *inode, struct file *filp)
328 {
329         return seq_open(filp, &devinfo_ops);
330 }
331
332 static struct file_operations proc_devinfo_operations = {
333         .open           = devinfo_open,
334         .read           = seq_read,
335         .llseek         = seq_lseek,
336         .release        = seq_release,
337 };
338
339 extern struct seq_operations vmstat_op;
340 static int vmstat_open(struct inode *inode, struct file *file)
341 {
342         return seq_open(file, &vmstat_op);
343 }
344 static struct file_operations proc_vmstat_file_operations = {
345         .open           = vmstat_open,
346         .read           = seq_read,
347         .llseek         = seq_lseek,
348         .release        = seq_release,
349 };
350
351 #ifdef CONFIG_PROC_HARDWARE
352 static int hardware_read_proc(char *page, char **start, off_t off,
353                                  int count, int *eof, void *data)
354 {
355         int len = get_hardware_list(page);
356         return proc_calc_metrics(page, start, off, count, eof, len);
357 }
358 #endif
359
360 #ifdef CONFIG_STRAM_PROC
361 static int stram_read_proc(char *page, char **start, off_t off,
362                                  int count, int *eof, void *data)
363 {
364         int len = get_stram_list(page);
365         return proc_calc_metrics(page, start, off, count, eof, len);
366 }
367 #endif
368
369 extern struct seq_operations partitions_op;
370 static int partitions_open(struct inode *inode, struct file *file)
371 {
372         return seq_open(file, &partitions_op);
373 }
374 static struct file_operations proc_partitions_operations = {
375         .open           = partitions_open,
376         .read           = seq_read,
377         .llseek         = seq_lseek,
378         .release        = seq_release,
379 };
380
381 extern struct seq_operations diskstats_op;
382 static int diskstats_open(struct inode *inode, struct file *file)
383 {
384         return seq_open(file, &diskstats_op);
385 }
386 static struct file_operations proc_diskstats_operations = {
387         .open           = diskstats_open,
388         .read           = seq_read,
389         .llseek         = seq_lseek,
390         .release        = seq_release,
391 };
392
393 #ifdef CONFIG_MODULES
394 extern struct seq_operations modules_op;
395 static int modules_open(struct inode *inode, struct file *file)
396 {
397         return seq_open(file, &modules_op);
398 }
399 static struct file_operations proc_modules_operations = {
400         .open           = modules_open,
401         .read           = seq_read,
402         .llseek         = seq_lseek,
403         .release        = seq_release,
404 };
405 #endif
406
407 #ifdef CONFIG_SLAB
408 extern struct seq_operations slabinfo_op;
409 extern ssize_t slabinfo_write(struct file *, const char __user *, size_t, loff_t *);
410 static int slabinfo_open(struct inode *inode, struct file *file)
411 {
412         return seq_open(file, &slabinfo_op);
413 }
414 static struct file_operations proc_slabinfo_operations = {
415         .open           = slabinfo_open,
416         .read           = seq_read,
417         .write          = slabinfo_write,
418         .llseek         = seq_lseek,
419         .release        = seq_release,
420 };
421
422 #ifdef CONFIG_DEBUG_SLAB_LEAK
423 extern struct seq_operations slabstats_op;
424 static int slabstats_open(struct inode *inode, struct file *file)
425 {
426         unsigned long *n = kzalloc(PAGE_SIZE, GFP_KERNEL);
427         int ret = -ENOMEM;
428         if (n) {
429                 ret = seq_open(file, &slabstats_op);
430                 if (!ret) {
431                         struct seq_file *m = file->private_data;
432                         *n = PAGE_SIZE / (2 * sizeof(unsigned long));
433                         m->private = n;
434                         n = NULL;
435                 }
436                 kfree(n);
437         }
438         return ret;
439 }
440
441 static int slabstats_release(struct inode *inode, struct file *file)
442 {
443         struct seq_file *m = file->private_data;
444         kfree(m->private);
445         return seq_release(inode, file);
446 }
447
448 static struct file_operations proc_slabstats_operations = {
449         .open           = slabstats_open,
450         .read           = seq_read,
451         .llseek         = seq_lseek,
452         .release        = slabstats_release,
453 };
454 #endif
455 #endif
456
457 static int show_stat(struct seq_file *p, void *v)
458 {
459         int i;
460         unsigned long jif;
461         cputime64_t user, nice, system, idle, iowait, irq, softirq, steal;
462         u64 sum = 0;
463
464         user = nice = system = idle = iowait =
465                 irq = softirq = steal = cputime64_zero;
466         jif = - wall_to_monotonic.tv_sec;
467         if (wall_to_monotonic.tv_nsec)
468                 --jif;
469
470         for_each_possible_cpu(i) {
471                 int j;
472
473                 user = cputime64_add(user, kstat_cpu(i).cpustat.user);
474                 nice = cputime64_add(nice, kstat_cpu(i).cpustat.nice);
475                 system = cputime64_add(system, kstat_cpu(i).cpustat.system);
476                 idle = cputime64_add(idle, kstat_cpu(i).cpustat.idle);
477                 iowait = cputime64_add(iowait, kstat_cpu(i).cpustat.iowait);
478                 irq = cputime64_add(irq, kstat_cpu(i).cpustat.irq);
479                 softirq = cputime64_add(softirq, kstat_cpu(i).cpustat.softirq);
480                 steal = cputime64_add(steal, kstat_cpu(i).cpustat.steal);
481                 for (j = 0 ; j < NR_IRQS ; j++)
482                         sum += kstat_cpu(i).irqs[j];
483         }
484
485         seq_printf(p, "cpu  %llu %llu %llu %llu %llu %llu %llu %llu\n",
486                 (unsigned long long)cputime64_to_clock_t(user),
487                 (unsigned long long)cputime64_to_clock_t(nice),
488                 (unsigned long long)cputime64_to_clock_t(system),
489                 (unsigned long long)cputime64_to_clock_t(idle),
490                 (unsigned long long)cputime64_to_clock_t(iowait),
491                 (unsigned long long)cputime64_to_clock_t(irq),
492                 (unsigned long long)cputime64_to_clock_t(softirq),
493                 (unsigned long long)cputime64_to_clock_t(steal));
494         for_each_online_cpu(i) {
495
496                 /* Copy values here to work around gcc-2.95.3, gcc-2.96 */
497                 user = kstat_cpu(i).cpustat.user;
498                 nice = kstat_cpu(i).cpustat.nice;
499                 system = kstat_cpu(i).cpustat.system;
500                 idle = kstat_cpu(i).cpustat.idle;
501                 iowait = kstat_cpu(i).cpustat.iowait;
502                 irq = kstat_cpu(i).cpustat.irq;
503                 softirq = kstat_cpu(i).cpustat.softirq;
504                 steal = kstat_cpu(i).cpustat.steal;
505                 seq_printf(p, "cpu%d %llu %llu %llu %llu %llu %llu %llu %llu\n",
506                         i,
507                         (unsigned long long)cputime64_to_clock_t(user),
508                         (unsigned long long)cputime64_to_clock_t(nice),
509                         (unsigned long long)cputime64_to_clock_t(system),
510                         (unsigned long long)cputime64_to_clock_t(idle),
511                         (unsigned long long)cputime64_to_clock_t(iowait),
512                         (unsigned long long)cputime64_to_clock_t(irq),
513                         (unsigned long long)cputime64_to_clock_t(softirq),
514                         (unsigned long long)cputime64_to_clock_t(steal));
515         }
516         seq_printf(p, "intr %llu", (unsigned long long)sum);
517
518 #if !defined(CONFIG_PPC64) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
519         for (i = 0; i < NR_IRQS; i++)
520                 seq_printf(p, " %u", kstat_irqs(i));
521 #endif
522
523         seq_printf(p,
524                 "\nctxt %llu\n"
525                 "btime %lu\n"
526                 "processes %lu\n"
527                 "procs_running %lu\n"
528                 "procs_blocked %lu\n",
529                 nr_context_switches(),
530                 (unsigned long)jif,
531                 total_forks,
532                 nr_running(),
533                 nr_iowait());
534
535         return 0;
536 }
537
538 static int stat_open(struct inode *inode, struct file *file)
539 {
540         unsigned size = 4096 * (1 + num_possible_cpus() / 32);
541         char *buf;
542         struct seq_file *m;
543         int res;
544
545         /* don't ask for more than the kmalloc() max size, currently 128 KB */
546         if (size > 128 * 1024)
547                 size = 128 * 1024;
548         buf = kmalloc(size, GFP_KERNEL);
549         if (!buf)
550                 return -ENOMEM;
551
552         res = single_open(file, show_stat, NULL);
553         if (!res) {
554                 m = file->private_data;
555                 m->buf = buf;
556                 m->size = size;
557         } else
558                 kfree(buf);
559         return res;
560 }
561 static struct file_operations proc_stat_operations = {
562         .open           = stat_open,
563         .read           = seq_read,
564         .llseek         = seq_lseek,
565         .release        = single_release,
566 };
567
568 /*
569  * /proc/interrupts
570  */
571 static void *int_seq_start(struct seq_file *f, loff_t *pos)
572 {
573         return (*pos <= NR_IRQS) ? pos : NULL;
574 }
575
576 static void *int_seq_next(struct seq_file *f, void *v, loff_t *pos)
577 {
578         (*pos)++;
579         if (*pos > NR_IRQS)
580                 return NULL;
581         return pos;
582 }
583
584 static void int_seq_stop(struct seq_file *f, void *v)
585 {
586         /* Nothing to do */
587 }
588
589
590 extern int show_interrupts(struct seq_file *f, void *v); /* In arch code */
591 static struct seq_operations int_seq_ops = {
592         .start = int_seq_start,
593         .next  = int_seq_next,
594         .stop  = int_seq_stop,
595         .show  = show_interrupts
596 };
597
598 static int interrupts_open(struct inode *inode, struct file *filp)
599 {
600         return seq_open(filp, &int_seq_ops);
601 }
602
603 static struct file_operations proc_interrupts_operations = {
604         .open           = interrupts_open,
605         .read           = seq_read,
606         .llseek         = seq_lseek,
607         .release        = seq_release,
608 };
609
610 static int filesystems_read_proc(char *page, char **start, off_t off,
611                                  int count, int *eof, void *data)
612 {
613         int len = get_filesystem_list(page);
614         return proc_calc_metrics(page, start, off, count, eof, len);
615 }
616
617 static int cmdline_read_proc(char *page, char **start, off_t off,
618                                  int count, int *eof, void *data)
619 {
620         int len;
621
622         len = sprintf(page, "%s\n", saved_command_line);
623         return proc_calc_metrics(page, start, off, count, eof, len);
624 }
625
626 static int locks_read_proc(char *page, char **start, off_t off,
627                                  int count, int *eof, void *data)
628 {
629         int len = get_locks_status(page, start, off, count);
630
631         if (len < count)
632                 *eof = 1;
633         return len;
634 }
635
636 static int execdomains_read_proc(char *page, char **start, off_t off,
637                                  int count, int *eof, void *data)
638 {
639         int len = get_exec_domain_list(page);
640         return proc_calc_metrics(page, start, off, count, eof, len);
641 }
642
643 #ifdef CONFIG_MAGIC_SYSRQ
644 /*
645  * writing 'C' to /proc/sysrq-trigger is like sysrq-C
646  */
647 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
648                                    size_t count, loff_t *ppos)
649 {
650         if (count) {
651                 char c;
652
653                 if (get_user(c, buf))
654                         return -EFAULT;
655                 __handle_sysrq(c, NULL, NULL, 0);
656         }
657         return count;
658 }
659
660 static struct file_operations proc_sysrq_trigger_operations = {
661         .write          = write_sysrq_trigger,
662 };
663 #endif
664
665 struct proc_dir_entry *proc_root_kcore;
666
667 void create_seq_entry(char *name, mode_t mode, const struct file_operations *f)
668 {
669         struct proc_dir_entry *entry;
670         entry = create_proc_entry(name, mode, NULL);
671         if (entry)
672                 entry->proc_fops = f;
673 }
674
675 void __init proc_misc_init(void)
676 {
677         struct proc_dir_entry *entry;
678         static struct {
679                 char *name;
680                 int (*read_proc)(char*,char**,off_t,int,int*,void*);
681         } *p, simple_ones[] = {
682                 {"loadavg",     loadavg_read_proc},
683                 {"uptime",      uptime_read_proc},
684                 {"meminfo",     meminfo_read_proc},
685                 {"version",     version_read_proc},
686 #ifdef CONFIG_PROC_HARDWARE
687                 {"hardware",    hardware_read_proc},
688 #endif
689 #ifdef CONFIG_STRAM_PROC
690                 {"stram",       stram_read_proc},
691 #endif
692                 {"filesystems", filesystems_read_proc},
693                 {"cmdline",     cmdline_read_proc},
694                 {"locks",       locks_read_proc},
695                 {"execdomains", execdomains_read_proc},
696                 {NULL,}
697         };
698         for (p = simple_ones; p->name; p++)
699                 create_proc_read_entry(p->name, 0, NULL, p->read_proc, NULL);
700
701         proc_symlink("mounts", NULL, "self/mounts");
702
703         /* And now for trickier ones */
704         entry = create_proc_entry("kmsg", S_IRUSR, &proc_root);
705         if (entry)
706                 entry->proc_fops = &proc_kmsg_operations;
707         create_seq_entry("devices", 0, &proc_devinfo_operations);
708         create_seq_entry("cpuinfo", 0, &proc_cpuinfo_operations);
709         create_seq_entry("partitions", 0, &proc_partitions_operations);
710         create_seq_entry("stat", 0, &proc_stat_operations);
711         create_seq_entry("interrupts", 0, &proc_interrupts_operations);
712 #ifdef CONFIG_SLAB
713         create_seq_entry("slabinfo",S_IWUSR|S_IRUGO,&proc_slabinfo_operations);
714 #ifdef CONFIG_DEBUG_SLAB_LEAK
715         create_seq_entry("slab_allocators", 0 ,&proc_slabstats_operations);
716 #endif
717 #endif
718         create_seq_entry("buddyinfo",S_IRUGO, &fragmentation_file_operations);
719         create_seq_entry("vmstat",S_IRUGO, &proc_vmstat_file_operations);
720         create_seq_entry("zoneinfo",S_IRUGO, &proc_zoneinfo_file_operations);
721         create_seq_entry("diskstats", 0, &proc_diskstats_operations);
722 #ifdef CONFIG_MODULES
723         create_seq_entry("modules", 0, &proc_modules_operations);
724 #endif
725 #ifdef CONFIG_SCHEDSTATS
726         create_seq_entry("schedstat", 0, &proc_schedstat_operations);
727 #endif
728 #ifdef CONFIG_PROC_KCORE
729         proc_root_kcore = create_proc_entry("kcore", S_IRUSR, NULL);
730         if (proc_root_kcore) {
731                 proc_root_kcore->proc_fops = &proc_kcore_operations;
732                 proc_root_kcore->size =
733                                 (size_t)high_memory - PAGE_OFFSET + PAGE_SIZE;
734         }
735 #endif
736 #ifdef CONFIG_PROC_VMCORE
737         proc_vmcore = create_proc_entry("vmcore", S_IRUSR, NULL);
738         if (proc_vmcore)
739                 proc_vmcore->proc_fops = &proc_vmcore_operations;
740 #endif
741 #ifdef CONFIG_MAGIC_SYSRQ
742         entry = create_proc_entry("sysrq-trigger", S_IWUSR, NULL);
743         if (entry)
744                 entry->proc_fops = &proc_sysrq_trigger_operations;
745 #endif
746 }