From 6a8d624cbc6f55ddcd9de90be52447b01e8d3724 Mon Sep 17 00:00:00 2001 From: Vivek Goyal Date: Sat, 25 Jun 2005 14:58:24 -0700 Subject: [PATCH] --- yaml --- r: 3350 b: refs/heads/master c: 315c215c0a7324894541d43b0e720f20cafca92e h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/drivers/char/mem.c | 51 ++++++++++++---------------------------- 2 files changed, 16 insertions(+), 37 deletions(-) diff --git a/[refs] b/[refs] index 6c3bee897451..3243dd90f680 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 50b1fdbd81edcc8bd343ca44aca2b87a29e2f15c +refs/heads/master: 315c215c0a7324894541d43b0e720f20cafca92e diff --git a/trunk/drivers/char/mem.c b/trunk/drivers/char/mem.c index 01b3c17ca851..b64108dd765b 100644 --- a/trunk/drivers/char/mem.c +++ b/trunk/drivers/char/mem.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -278,55 +279,33 @@ static int mmap_kmem(struct file * file, struct vm_area_struct * vma) #ifdef CONFIG_CRASH_DUMP /* * Read memory corresponding to the old kernel. - * If we are reading from the reserved section, which is - * actually used by the current kernel, we just return zeroes. - * Or if we are reading from the first 640k, we return from the - * backed up area. */ -static ssize_t read_oldmem(struct file * file, char * buf, +static ssize_t read_oldmem(struct file *file, char __user *buf, size_t count, loff_t *ppos) { - unsigned long pfn; - unsigned backup_start, backup_end, relocate_start; - size_t read=0, csize; - - backup_start = CRASH_BACKUP_BASE / PAGE_SIZE; - backup_end = backup_start + (CRASH_BACKUP_SIZE / PAGE_SIZE); - relocate_start = (CRASH_BACKUP_BASE + CRASH_BACKUP_SIZE) / PAGE_SIZE; + unsigned long pfn, offset; + size_t read = 0, csize; + int rc = 0; while(count) { pfn = *ppos / PAGE_SIZE; + if (pfn > saved_max_pfn) + return read; - csize = (count > PAGE_SIZE) ? PAGE_SIZE : count; - - /* Perform translation (see comment above) */ - if ((pfn >= backup_start) && (pfn < backup_end)) { - if (clear_user(buf, csize)) { - read = -EFAULT; - goto done; - } - - goto copy_done; - } else if (pfn < (CRASH_RELOCATE_SIZE / PAGE_SIZE)) - pfn += relocate_start; - - if (pfn > saved_max_pfn) { - read = 0; - goto done; - } - - if (copy_oldmem_page(pfn, buf, csize, 1)) { - read = -EFAULT; - goto done; - } + offset = (unsigned long)(*ppos % PAGE_SIZE); + if (count > PAGE_SIZE - offset) + csize = PAGE_SIZE - offset; + else + csize = count; -copy_done: + rc = copy_oldmem_page(pfn, buf, csize, offset, 1); + if (rc < 0) + return rc; buf += csize; *ppos += csize; read += csize; count -= csize; } -done: return read; } #endif