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