mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-20 05:31:15 +00:00
mm: introduce coredump parameter structure
Introduce coredump parameter data structure (struct coredump_params) to simplify binfmt->core_dump() arguments. Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com> Suggested-by: Ingo Molnar <mingo@elte.hu> Cc: Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Roland McGrath <roland@redhat.com> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
9cd80bbb07
commit
f6151dfea2
7 changed files with 69 additions and 53 deletions
|
@ -45,7 +45,7 @@ static unsigned long elf_map(struct file *, unsigned long, struct elf_phdr *,
|
|||
* don't even try.
|
||||
*/
|
||||
#ifdef CONFIG_ELF_CORE
|
||||
static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit);
|
||||
static int elf_core_dump(struct coredump_params *cprm);
|
||||
#else
|
||||
#define elf_core_dump NULL
|
||||
#endif
|
||||
|
@ -1272,8 +1272,9 @@ static int writenote(struct memelfnote *men, struct file *file,
|
|||
}
|
||||
#undef DUMP_WRITE
|
||||
|
||||
#define DUMP_WRITE(addr, nr) \
|
||||
if ((size += (nr)) > limit || !dump_write(file, (addr), (nr))) \
|
||||
#define DUMP_WRITE(addr, nr) \
|
||||
if ((size += (nr)) > cprm->limit || \
|
||||
!dump_write(cprm->file, (addr), (nr))) \
|
||||
goto end_coredump;
|
||||
|
||||
static void fill_elf_header(struct elfhdr *elf, int segs,
|
||||
|
@ -1901,7 +1902,7 @@ static struct vm_area_struct *next_vma(struct vm_area_struct *this_vma,
|
|||
* and then they are actually written out. If we run out of core limit
|
||||
* we just truncate.
|
||||
*/
|
||||
static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit)
|
||||
static int elf_core_dump(struct coredump_params *cprm)
|
||||
{
|
||||
int has_dumped = 0;
|
||||
mm_segment_t fs;
|
||||
|
@ -1947,7 +1948,7 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, un
|
|||
* notes. This also sets up the file header.
|
||||
*/
|
||||
if (!fill_note_info(elf, segs + 1, /* including notes section */
|
||||
&info, signr, regs))
|
||||
&info, cprm->signr, cprm->regs))
|
||||
goto cleanup;
|
||||
|
||||
has_dumped = 1;
|
||||
|
@ -2009,14 +2010,14 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, un
|
|||
#endif
|
||||
|
||||
/* write out the notes section */
|
||||
if (!write_note_info(&info, file, &foffset))
|
||||
if (!write_note_info(&info, cprm->file, &foffset))
|
||||
goto end_coredump;
|
||||
|
||||
if (elf_coredump_extra_notes_write(file, &foffset))
|
||||
if (elf_coredump_extra_notes_write(cprm->file, &foffset))
|
||||
goto end_coredump;
|
||||
|
||||
/* Align to page */
|
||||
if (!dump_seek(file, dataoff - foffset))
|
||||
if (!dump_seek(cprm->file, dataoff - foffset))
|
||||
goto end_coredump;
|
||||
|
||||
for (vma = first_vma(current, gate_vma); vma != NULL;
|
||||
|
@ -2033,12 +2034,13 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, un
|
|||
page = get_dump_page(addr);
|
||||
if (page) {
|
||||
void *kaddr = kmap(page);
|
||||
stop = ((size += PAGE_SIZE) > limit) ||
|
||||
!dump_write(file, kaddr, PAGE_SIZE);
|
||||
stop = ((size += PAGE_SIZE) > cprm->limit) ||
|
||||
!dump_write(cprm->file, kaddr,
|
||||
PAGE_SIZE);
|
||||
kunmap(page);
|
||||
page_cache_release(page);
|
||||
} else
|
||||
stop = !dump_seek(file, PAGE_SIZE);
|
||||
stop = !dump_seek(cprm->file, PAGE_SIZE);
|
||||
if (stop)
|
||||
goto end_coredump;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue