#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>
#include <linux/vmalloc.h>
static ssize_t read_kcore(struct file *, char __user *, size_t, loff_t *);
-struct file_operations proc_kcore_operations = {
+const struct file_operations proc_kcore_operations = {
.read = read_kcore,
.open = open_kcore,
};
};
static struct kcore_list *kclist;
-static rwlock_t kclist_lock = RW_LOCK_UNLOCKED;
+static DEFINE_RWLOCK(kclist_lock);
void
kclist_add(struct kcore_list *new, void *addr, size_t size)
write_unlock(&kclist_lock);
}
-struct kcore_list *
-kclist_del(void *addr)
-{
- struct kcore_list *m, **p = &kclist;
-
- write_lock(&kclist_lock);
- for (m = *p; m; p = &m->next) {
- if (m->addr == (unsigned long)addr) {
- *p = m->next;
- write_unlock(&kclist_lock);
- return m;
- }
- }
- write_unlock(&kclist_lock);
- return NULL;
-}
-
static size_t get_kcore_size(int *nphdr, size_t *elf_buflen)
{
size_t try, size;
}
*elf_buflen = sizeof(struct elfhdr) +
(*nphdr + 2)*sizeof(struct elf_phdr) +
- 3 * sizeof(struct memelfnote) +
+ 3 * (sizeof(struct elf_note) + 4) +
sizeof(struct elf_prstatus) +
sizeof(struct elf_prpsinfo) +
sizeof(struct task_struct);
/*
* determine size of ELF note
*/
-int notesize(struct memelfnote *en)
+static int notesize(struct memelfnote *en)
{
int sz;
/*
* store a note in the header buffer
*/
-char *storenote(struct memelfnote *men, char *bufp)
+static char *storenote(struct memelfnote *men, char *bufp)
{
struct elf_note en;
* store an ELF coredump header in the supplied buffer
* nphdr is the number of elf_phdr to insert
*/
-void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff, struct kcore_list *clist)
+static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
{
struct elf_prstatus prstatus; /* NT_PRSTATUS */
struct elf_prpsinfo prpsinfo; /* NT_PRPSINFO */
nhdr->p_align = 0;
/* setup ELF PT_LOAD program header for every area */
- for (m=clist; m; m=m->next) {
+ for (m=kclist; m; m=m->next) {
phdr = (struct elf_phdr *) bufp;
bufp += sizeof(struct elf_phdr);
offset += sizeof(struct elf_phdr);
unsigned long start;
read_lock(&kclist_lock);
- tsz = get_kcore_size(&nphdr, &elf_buflen);
- proc_root_kcore->size = size = tsz + elf_buflen;
+ proc_root_kcore->size = size = get_kcore_size(&nphdr, &elf_buflen);
if (buflen == 0 || *fpos >= size) {
read_unlock(&kclist_lock);
return 0;
return -ENOMEM;
}
memset(elf_buf, 0, elf_buflen);
- elf_kcore_store_hdr(elf_buf, nphdr, elf_buflen, kclist);
+ elf_kcore_store_hdr(elf_buf, nphdr, elf_buflen);
read_unlock(&kclist_lock);
if (copy_to_user(buffer, elf_buf + *fpos, tsz)) {
kfree(elf_buf);