diff options
author | Daisuke HATAYAMA <d.hatayama@jp.fujitsu.com> | 2010-03-05 16:44:06 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-03-06 14:26:45 -0500 |
commit | 088e7af73a962fcc8883b7a6392544d8342553d6 (patch) | |
tree | 5dce5b991cad1071522b464bd83943a1b6e885b2 /fs/binfmt_aout.c | |
parent | 05f47fda9fc5b17bfab189e9d54228025befc996 (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 'fs/binfmt_aout.c')
-rw-r--r-- | fs/binfmt_aout.c | 49 |
1 files changed, 9 insertions, 40 deletions
diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c index d2f8872dd767..15d80bb35d6f 100644 --- a/fs/binfmt_aout.c +++ b/fs/binfmt_aout.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/binfmts.h> | 24 | #include <linux/binfmts.h> |
25 | #include <linux/personality.h> | 25 | #include <linux/personality.h> |
26 | #include <linux/init.h> | 26 | #include <linux/init.h> |
27 | #include <linux/coredump.h> | ||
27 | 28 | ||
28 | #include <asm/system.h> | 29 | #include <asm/system.h> |
29 | #include <asm/uaccess.h> | 30 | #include <asm/uaccess.h> |
@@ -60,42 +61,6 @@ static int set_brk(unsigned long start, unsigned long end) | |||
60 | } | 61 | } |
61 | 62 | ||
62 | /* | 63 | /* |
63 | * These are the only things you should do on a core-file: use only these | ||
64 | * macros to write out all the necessary info. | ||
65 | */ | ||
66 | |||
67 | static int dump_write(struct file *file, const void *addr, int nr) | ||
68 | { | ||
69 | return file->f_op->write(file, addr, nr, &file->f_pos) == nr; | ||
70 | } | ||
71 | |||
72 | static int dump_seek(struct file *file, loff_t off) | ||
73 | { | ||
74 | if (file->f_op->llseek && file->f_op->llseek != no_llseek) { | ||
75 | if (file->f_op->llseek(file, off, SEEK_CUR) < 0) | ||
76 | return 0; | ||
77 | } else { | ||
78 | char *buf = (char *)get_zeroed_page(GFP_KERNEL); | ||
79 | if (!buf) | ||
80 | return 0; | ||
81 | while (off > 0) { | ||
82 | unsigned long n = off; | ||
83 | if (n > PAGE_SIZE) | ||
84 | n = PAGE_SIZE; | ||
85 | if (!dump_write(file, buf, n)) | ||
86 | return 0; | ||
87 | off -= n; | ||
88 | } | ||
89 | free_page((unsigned long)buf); | ||
90 | } | ||
91 | return 1; | ||
92 | } | ||
93 | |||
94 | #define DUMP_WRITE(addr, nr) \ | ||
95 | if (!dump_write(file, (void *)(addr), (nr))) \ | ||
96 | goto end_coredump; | ||
97 | |||
98 | /* | ||
99 | * Routine writes a core dump image in the current directory. | 64 | * Routine writes a core dump image in the current directory. |
100 | * Currently only a stub-function. | 65 | * Currently only a stub-function. |
101 | * | 66 | * |
@@ -146,7 +111,8 @@ static int aout_core_dump(struct coredump_params *cprm) | |||
146 | 111 | ||
147 | set_fs(KERNEL_DS); | 112 | set_fs(KERNEL_DS); |
148 | /* struct user */ | 113 | /* struct user */ |
149 | DUMP_WRITE(&dump,sizeof(dump)); | 114 | if (!dump_write(file, &dump, sizeof(dump))) |
115 | goto end_coredump; | ||
150 | /* Now dump all of the user data. Include malloced stuff as well */ | 116 | /* Now dump all of the user data. Include malloced stuff as well */ |
151 | if (!dump_seek(cprm->file, PAGE_SIZE - sizeof(dump))) | 117 | if (!dump_seek(cprm->file, PAGE_SIZE - sizeof(dump))) |
152 | goto end_coredump; | 118 | goto end_coredump; |
@@ -156,17 +122,20 @@ static int aout_core_dump(struct coredump_params *cprm) | |||
156 | if (dump.u_dsize != 0) { | 122 | if (dump.u_dsize != 0) { |
157 | dump_start = START_DATA(dump); | 123 | dump_start = START_DATA(dump); |
158 | dump_size = dump.u_dsize << PAGE_SHIFT; | 124 | dump_size = dump.u_dsize << PAGE_SHIFT; |
159 | DUMP_WRITE(dump_start,dump_size); | 125 | if (!dump_write(file, dump_start, dump_size)) |
126 | goto end_coredump; | ||
160 | } | 127 | } |
161 | /* Now prepare to dump the stack area */ | 128 | /* Now prepare to dump the stack area */ |
162 | if (dump.u_ssize != 0) { | 129 | if (dump.u_ssize != 0) { |
163 | dump_start = START_STACK(dump); | 130 | dump_start = START_STACK(dump); |
164 | dump_size = dump.u_ssize << PAGE_SHIFT; | 131 | dump_size = dump.u_ssize << PAGE_SHIFT; |
165 | DUMP_WRITE(dump_start,dump_size); | 132 | if (!dump_write(file, dump_start, dump_size)) |
133 | goto end_coredump; | ||
166 | } | 134 | } |
167 | /* Finally dump the task struct. Not be used by gdb, but could be useful */ | 135 | /* Finally dump the task struct. Not be used by gdb, but could be useful */ |
168 | set_fs(KERNEL_DS); | 136 | set_fs(KERNEL_DS); |
169 | DUMP_WRITE(current,sizeof(*current)); | 137 | if (!dump_write(file, current, sizeof(*current))) |
138 | goto end_coredump; | ||
170 | end_coredump: | 139 | end_coredump: |
171 | set_fs(fs); | 140 | set_fs(fs); |
172 | return has_dumped; | 141 | return has_dumped; |