Merge commit 'v2.6.30' into for-2.6.31
[safe/jmp/linux-2.6] / fs / proc / kcore.c
index 1be7308..59b43a0 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/mm.h>
 #include <linux/proc_fs.h>
 #include <linux/user.h>
-#include <linux/a.out.h>
 #include <linux/capability.h>
 #include <linux/elf.h>
 #include <linux/elfcore.h>
 
 #define CORE_STR "CORE"
 
+#ifndef ELF_CORE_EFLAGS
+#define ELF_CORE_EFLAGS        0
+#endif
+
+static struct proc_dir_entry *proc_root_kcore;
+
 static int open_kcore(struct inode * inode, struct file * filp)
 {
        return capable(CAP_SYS_RAWIO) ? 0 : -EPERM;
@@ -31,7 +36,7 @@ static int open_kcore(struct inode * inode, struct file * filp)
 
 static ssize_t read_kcore(struct file *, char __user *, size_t, loff_t *);
 
-const struct file_operations proc_kcore_operations = {
+static const struct file_operations proc_kcore_operations = {
        .read           = read_kcore,
        .open           = open_kcore,
 };
@@ -165,11 +170,7 @@ static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
        elf->e_entry    = 0;
        elf->e_phoff    = sizeof(struct elfhdr);
        elf->e_shoff    = 0;
-#if defined(CONFIG_H8300)
-       elf->e_flags    = ELF_FLAGS;
-#else
-       elf->e_flags    = 0;
-#endif
+       elf->e_flags    = ELF_CORE_EFLAGS;
        elf->e_ehsize   = sizeof(struct elfhdr);
        elf->e_phentsize= sizeof(struct elf_phdr);
        elf->e_phnum    = nphdr;
@@ -325,7 +326,7 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
                if (m == NULL) {
                        if (clear_user(buffer, tsz))
                                return -EFAULT;
-               } else if ((start >= VMALLOC_START) && (start < VMALLOC_END)) {
+               } else if (is_vmalloc_addr((void *)start)) {
                        char * elf_buf;
                        struct vm_struct *m;
                        unsigned long curstart = start;
@@ -400,3 +401,13 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
 
        return acc;
 }
+
+static int __init proc_kcore_init(void)
+{
+       proc_root_kcore = proc_create("kcore", S_IRUSR, NULL, &proc_kcore_operations);
+       if (proc_root_kcore)
+               proc_root_kcore->size =
+                               (size_t)high_memory - PAGE_OFFSET + PAGE_SIZE;
+       return 0;
+}
+module_init(proc_kcore_init);