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