forked from microsoft/WSL2-Linux-Kernel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
coredump: move dump_write() and dump_seek() into a header file
My next patch will replace ELF_CORE_EXTRA_* macros by functions, putting them into other newly created *.c files. Then, each files will contain dump_write(), where each pair of binfmt_*.c and elfcore.c should be the same. So, this patch moves them into a header file with dump_seek(). Also, the patch deletes confusing DUMP_WRITE macros in each files. Signed-off-by: Daisuke HATAYAMA <d.hatayama@jp.fujitsu.com> Cc: "Luck, Tony" <tony.luck@intel.com> Cc: Jeff Dike <jdike@addtoit.com> Cc: David Howells <dhowells@redhat.com> Cc: Greg Ungerer <gerg@snapgear.com> Cc: Roland McGrath <roland@redhat.com> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: Andi Kleen <andi@firstfloor.org> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Cc: <linux-arch@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
- Loading branch information
Showing
4 changed files
with
79 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#ifndef _LINUX_COREDUMP_H | ||
#define _LINUX_COREDUMP_H | ||
|
||
#include <linux/types.h> | ||
#include <linux/mm.h> | ||
#include <linux/fs.h> | ||
|
||
/* | ||
* These are the only things you should do on a core-file: use only these | ||
* functions to write out all the necessary info. | ||
*/ | ||
static inline int dump_write(struct file *file, const void *addr, int nr) | ||
{ | ||
return file->f_op->write(file, addr, nr, &file->f_pos) == nr; | ||
} | ||
|
||
static inline int dump_seek(struct file *file, loff_t off) | ||
{ | ||
if (file->f_op->llseek && file->f_op->llseek != no_llseek) { | ||
if (file->f_op->llseek(file, off, SEEK_CUR) < 0) | ||
return 0; | ||
} else { | ||
char *buf = (char *)get_zeroed_page(GFP_KERNEL); | ||
|
||
if (!buf) | ||
return 0; | ||
while (off > 0) { | ||
unsigned long n = off; | ||
|
||
if (n > PAGE_SIZE) | ||
n = PAGE_SIZE; | ||
if (!dump_write(file, buf, n)) | ||
return 0; | ||
off -= n; | ||
} | ||
free_page((unsigned long)buf); | ||
} | ||
return 1; | ||
} | ||
|
||
#endif /* _LINUX_COREDUMP_H */ |