aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/coredump.h
diff options
context:
space:
mode:
authorDaisuke HATAYAMA <d.hatayama@jp.fujitsu.com>2010-03-05 16:44:06 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2010-03-06 14:26:45 -0500
commit088e7af73a962fcc8883b7a6392544d8342553d6 (patch)
tree5dce5b991cad1071522b464bd83943a1b6e885b2 /include/linux/coredump.h
parent05f47fda9fc5b17bfab189e9d54228025befc996 (diff)
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>
Diffstat (limited to 'include/linux/coredump.h')
-rw-r--r--include/linux/coredump.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/include/linux/coredump.h b/include/linux/coredump.h
new file mode 100644
index 000000000000..b3c91d7cede4
--- /dev/null
+++ b/include/linux/coredump.h
@@ -0,0 +1,41 @@
1#ifndef _LINUX_COREDUMP_H
2#define _LINUX_COREDUMP_H
3
4#include <linux/types.h>
5#include <linux/mm.h>
6#include <linux/fs.h>
7
8/*
9 * These are the only things you should do on a core-file: use only these
10 * functions to write out all the necessary info.
11 */
12static inline int dump_write(struct file *file, const void *addr, int nr)
13{
14 return file->f_op->write(file, addr, nr, &file->f_pos) == nr;
15}
16
17static inline int dump_seek(struct file *file, loff_t off)
18{
19 if (file->f_op->llseek && file->f_op->llseek != no_llseek) {
20 if (file->f_op->llseek(file, off, SEEK_CUR) < 0)
21 return 0;
22 } else {
23 char *buf = (char *)get_zeroed_page(GFP_KERNEL);
24
25 if (!buf)
26 return 0;
27 while (off > 0) {
28 unsigned long n = off;
29
30 if (n > PAGE_SIZE)
31 n = PAGE_SIZE;
32 if (!dump_write(file, buf, n))
33 return 0;
34 off -= n;
35 }
36 free_page((unsigned long)buf);
37 }
38 return 1;
39}
40
41#endif /* _LINUX_COREDUMP_H */