From ae51455231bef7a38257a80fb4ab25886c3c6a05 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Thu, 14 Oct 2010 14:32:06 -0700 Subject: [PATCH] --- yaml --- r: 211506 b: refs/heads/master c: 3aa0ce825ade0cf5506e32ccf51d01fc8d22a9cf h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/fs/exec.c | 38 ++++++++++++++++++++++++++++++++++ trunk/include/linux/coredump.h | 34 ++---------------------------- 3 files changed, 41 insertions(+), 33 deletions(-) diff --git a/[refs] b/[refs] index 4b28596214f3..1962f2a78c3e 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: ae42d8d44195a614c78a636683fe65ed31744cbd +refs/heads/master: 3aa0ce825ade0cf5506e32ccf51d01fc8d22a9cf diff --git a/trunk/fs/exec.c b/trunk/fs/exec.c index 828dd2461d6b..03278c984ba0 100644 --- a/trunk/fs/exec.c +++ b/trunk/fs/exec.c @@ -2014,3 +2014,41 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs) fail: return; } + +/* + * Core dumping helper functions. These are the only things you should + * do on a core-file: use only these functions to write out all the + * necessary info. + */ +int dump_write(struct file *file, const void *addr, int nr) +{ + return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, addr, nr, &file->f_pos) == nr; +} + +int dump_seek(struct file *file, loff_t off) +{ + int ret = 1; + + 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)) { + ret = 0; + break; + } + off -= n; + } + free_page((unsigned long)buf); + } + return ret; +} diff --git a/trunk/include/linux/coredump.h b/trunk/include/linux/coredump.h index 59579cfee6a0..ba4b85a6d9b8 100644 --- a/trunk/include/linux/coredump.h +++ b/trunk/include/linux/coredump.h @@ -9,37 +9,7 @@ * 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 access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, addr, nr, &file->f_pos) == nr; -} - -static inline int dump_seek(struct file *file, loff_t off) -{ - int ret = 1; - - 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)) { - ret = 0; - break; - } - off -= n; - } - free_page((unsigned long)buf); - } - return ret; -} +extern int dump_write(struct file *file, const void *addr, int nr); +extern int dump_seek(struct file *file, loff_t off); #endif /* _LINUX_COREDUMP_H */