diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2013-10-05 15:32:35 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-11-09 00:16:22 -0500 |
commit | ecc8c7725e6c21528329b34acae2a1d64b3af89b (patch) | |
tree | ae1790c2ce0fe1c1f02e2bd0795b6636d65b4587 /fs/coredump.c | |
parent | 7d2f551f6dc933f87933e906e48583169bbc7c27 (diff) |
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 <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/coredump.c')
-rw-r--r-- | fs/coredump.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/fs/coredump.c b/fs/coredump.c index 42c3b8423669..319f973bab72 100644 --- a/fs/coredump.c +++ b/fs/coredump.c | |||
@@ -693,6 +693,20 @@ int dump_write(struct file *file, const void *addr, int nr) | |||
693 | } | 693 | } |
694 | EXPORT_SYMBOL(dump_write); | 694 | EXPORT_SYMBOL(dump_write); |
695 | 695 | ||
696 | int dump_emit(struct coredump_params *cprm, const void *addr, int nr) | ||
697 | { | ||
698 | struct file *file = cprm->file; | ||
699 | if (dump_interrupted() || !access_ok(VERIFY_READ, addr, nr)) | ||
700 | return 0; | ||
701 | if (cprm->written + nr > cprm->limit) | ||
702 | return 0; | ||
703 | if (file->f_op->write(file, addr, nr, &file->f_pos) != nr) | ||
704 | return 0; | ||
705 | cprm->written += nr; | ||
706 | return 1; | ||
707 | } | ||
708 | EXPORT_SYMBOL(dump_emit); | ||
709 | |||
696 | int dump_seek(struct file *file, loff_t off) | 710 | int dump_seek(struct file *file, loff_t off) |
697 | { | 711 | { |
698 | int ret = 1; | 712 | int ret = 1; |