aboutsummaryrefslogtreecommitdiffstats
path: root/fs/exec.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-10-14 17:32:06 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-10-14 17:32:06 -0400
commit3aa0ce825ade0cf5506e32ccf51d01fc8d22a9cf (patch)
tree77ca43d663b62922a743de3729a8b8b47eafb887 /fs/exec.c
parentae42d8d44195a614c78a636683fe65ed31744cbd (diff)
Un-inline the core-dump helper functions
Tony Luck reports that the addition of the access_ok() check in commit 0eead9ab41da ("Don't dump task struct in a.out core-dumps") broke the ia64 compile due to missing the necessary header file includes. Rather than add yet another include (<asm/unistd.h>) to make everything happy, just uninline the silly core dump helper functions and move the bodies to fs/exec.c where they make a lot more sense. dump_seek() in particular was too big to be an inline function anyway, and none of them are in any way performance-critical. And we really don't need to mess up our include file headers more than they already are. Reported-and-tested-by: Tony Luck <tony.luck@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/exec.c')
-rw-r--r--fs/exec.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/fs/exec.c b/fs/exec.c
index 828dd2461d6b..03278c984ba0 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -2014,3 +2014,41 @@ fail_creds:
2014fail: 2014fail:
2015 return; 2015 return;
2016} 2016}
2017
2018/*
2019 * Core dumping helper functions. These are the only things you should
2020 * do on a core-file: use only these functions to write out all the
2021 * necessary info.
2022 */
2023int dump_write(struct file *file, const void *addr, int nr)
2024{
2025 return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, addr, nr, &file->f_pos) == nr;
2026}
2027
2028int dump_seek(struct file *file, loff_t off)
2029{
2030 int ret = 1;
2031
2032 if (file->f_op->llseek && file->f_op->llseek != no_llseek) {
2033 if (file->f_op->llseek(file, off, SEEK_CUR) < 0)
2034 return 0;
2035 } else {
2036 char *buf = (char *)get_zeroed_page(GFP_KERNEL);
2037
2038 if (!buf)
2039 return 0;
2040 while (off > 0) {
2041 unsigned long n = off;
2042
2043 if (n > PAGE_SIZE)
2044 n = PAGE_SIZE;
2045 if (!dump_write(file, buf, n)) {
2046 ret = 0;
2047 break;
2048 }
2049 off -= n;
2050 }
2051 free_page((unsigned long)buf);
2052 }
2053 return ret;
2054}