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