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