0001
0002
0003
0004
0005
0006
0007
0008 #include <linux/init.h>
0009 #include <linux/module.h>
0010 #include <linux/errno.h>
0011 #include <linux/time.h>
0012 #include <linux/kernel.h>
0013 #include <linux/string.h>
0014 #include <linux/mman.h>
0015 #include <linux/proc_fs.h>
0016 #include <linux/mm.h>
0017 #include <linux/mmzone.h>
0018 #include <linux/pagemap.h>
0019 #include <linux/swap.h>
0020 #include <linux/smp.h>
0021 #include <linux/seq_file.h>
0022 #include <linux/hugetlb.h>
0023 #include <linux/vmalloc.h>
0024 #include <asm/tlb.h>
0025 #include <asm/div64.h>
0026 #include "internal.h"
0027
0028
0029
0030
0031 static int nommu_region_show(struct seq_file *m, struct vm_region *region)
0032 {
0033 unsigned long ino = 0;
0034 struct file *file;
0035 dev_t dev = 0;
0036 int flags;
0037
0038 flags = region->vm_flags;
0039 file = region->vm_file;
0040
0041 if (file) {
0042 struct inode *inode = file_inode(region->vm_file);
0043 dev = inode->i_sb->s_dev;
0044 ino = inode->i_ino;
0045 }
0046
0047 seq_setwidth(m, 25 + sizeof(void *) * 6 - 1);
0048 seq_printf(m,
0049 "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu ",
0050 region->vm_start,
0051 region->vm_end,
0052 flags & VM_READ ? 'r' : '-',
0053 flags & VM_WRITE ? 'w' : '-',
0054 flags & VM_EXEC ? 'x' : '-',
0055 flags & VM_MAYSHARE ? flags & VM_SHARED ? 'S' : 's' : 'p',
0056 ((loff_t)region->vm_pgoff) << PAGE_SHIFT,
0057 MAJOR(dev), MINOR(dev), ino);
0058
0059 if (file) {
0060 seq_pad(m, ' ');
0061 seq_file_path(m, file, "");
0062 }
0063
0064 seq_putc(m, '\n');
0065 return 0;
0066 }
0067
0068
0069
0070
0071
0072 static int nommu_region_list_show(struct seq_file *m, void *_p)
0073 {
0074 struct rb_node *p = _p;
0075
0076 return nommu_region_show(m, rb_entry(p, struct vm_region, vm_rb));
0077 }
0078
0079 static void *nommu_region_list_start(struct seq_file *m, loff_t *_pos)
0080 {
0081 struct rb_node *p;
0082 loff_t pos = *_pos;
0083
0084 down_read(&nommu_region_sem);
0085
0086 for (p = rb_first(&nommu_region_tree); p; p = rb_next(p))
0087 if (pos-- == 0)
0088 return p;
0089 return NULL;
0090 }
0091
0092 static void nommu_region_list_stop(struct seq_file *m, void *v)
0093 {
0094 up_read(&nommu_region_sem);
0095 }
0096
0097 static void *nommu_region_list_next(struct seq_file *m, void *v, loff_t *pos)
0098 {
0099 (*pos)++;
0100 return rb_next((struct rb_node *) v);
0101 }
0102
0103 static const struct seq_operations proc_nommu_region_list_seqop = {
0104 .start = nommu_region_list_start,
0105 .next = nommu_region_list_next,
0106 .stop = nommu_region_list_stop,
0107 .show = nommu_region_list_show
0108 };
0109
0110 static int __init proc_nommu_init(void)
0111 {
0112 proc_create_seq("maps", S_IRUGO, NULL, &proc_nommu_region_list_seqop);
0113 return 0;
0114 }
0115
0116 fs_initcall(proc_nommu_init);