From ecc8c7725e6c21528329b34acae2a1d64b3af89b Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sat, 5 Oct 2013 15:32:35 -0400 Subject: new helper: dump_emit() dump_write() analog, takes core_dump_params instead of file, keeps track of the amount written in cprm->written and checks for cprm->limit. Start using it in binfmt_elf.c... Signed-off-by: Al Viro --- fs/coredump.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'fs/coredump.c') diff --git a/fs/coredump.c b/fs/coredump.c index 42c3b842366..319f973bab7 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -693,6 +693,20 @@ int dump_write(struct file *file, const void *addr, int nr) } EXPORT_SYMBOL(dump_write); +int dump_emit(struct coredump_params *cprm, const void *addr, int nr) +{ + struct file *file = cprm->file; + if (dump_interrupted() || !access_ok(VERIFY_READ, addr, nr)) + return 0; + if (cprm->written + nr > cprm->limit) + return 0; + if (file->f_op->write(file, addr, nr, &file->f_pos) != nr) + return 0; + cprm->written += nr; + return 1; +} +EXPORT_SYMBOL(dump_emit); + int dump_seek(struct file *file, loff_t off) { int ret = 1; -- cgit v1.2.3-18-g5258