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