diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2013-10-05 22:24:29 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-11-09 00:16:24 -0500 |
commit | cdc3d5627d5f7c4e6b6372b9fb39cba0fe6a9b2a (patch) | |
tree | a171558a3396fbcf89a82a065d4f0742ddc22076 /arch/powerpc/platforms | |
parent | e6c1baa9b562ca296d57178c44f3894795d13d32 (diff) |
switch elf_coredump_extra_notes_write() to dump_emit()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'arch/powerpc/platforms')
-rw-r--r-- | arch/powerpc/platforms/cell/spu_syscalls.c | 5 | ||||
-rw-r--r-- | arch/powerpc/platforms/cell/spufs/coredump.c | 44 | ||||
-rw-r--r-- | arch/powerpc/platforms/cell/spufs/spufs.h | 3 |
3 files changed, 22 insertions, 30 deletions
diff --git a/arch/powerpc/platforms/cell/spu_syscalls.c b/arch/powerpc/platforms/cell/spu_syscalls.c index db4e638cf408..3844f1397fc3 100644 --- a/arch/powerpc/platforms/cell/spu_syscalls.c +++ b/arch/powerpc/platforms/cell/spu_syscalls.c @@ -25,6 +25,7 @@ #include <linux/module.h> #include <linux/syscalls.h> #include <linux/rcupdate.h> +#include <linux/binfmts.h> #include <asm/spu.h> @@ -126,7 +127,7 @@ int elf_coredump_extra_notes_size(void) return ret; } -int elf_coredump_extra_notes_write(struct file *file, loff_t *foffset) +int elf_coredump_extra_notes_write(struct coredump_params *cprm) { struct spufs_calls *calls; int ret; @@ -135,7 +136,7 @@ int elf_coredump_extra_notes_write(struct file *file, loff_t *foffset) if (!calls) return 0; - ret = calls->coredump_extra_notes_write(file, foffset); + ret = calls->coredump_extra_notes_write(cprm); spufs_calls_put(calls); diff --git a/arch/powerpc/platforms/cell/spufs/coredump.c b/arch/powerpc/platforms/cell/spufs/coredump.c index c9500ea7be2f..5d9b0a288f36 100644 --- a/arch/powerpc/platforms/cell/spufs/coredump.c +++ b/arch/powerpc/platforms/cell/spufs/coredump.c @@ -27,6 +27,8 @@ #include <linux/gfp.h> #include <linux/list.h> #include <linux/syscalls.h> +#include <linux/coredump.h> +#include <linux/binfmts.h> #include <asm/uaccess.h> @@ -52,35 +54,24 @@ static ssize_t do_coredump_read(int num, struct spu_context *ctx, void *buffer, * These are the only things you should do on a core-file: use only these * functions to write out all the necessary info. */ -static int spufs_dump_write(struct file *file, const void *addr, int nr, loff_t *foffset) +static int spufs_dump_write(struct coredump_params *cprm, const void *addr, int nr) { - unsigned long limit = rlimit(RLIMIT_CORE); - ssize_t written; - - if (*foffset + nr > limit) + if (!dump_emit(cprm, addr, nr)) return -EIO; - - written = file->f_op->write(file, addr, nr, &file->f_pos); - *foffset += written; - - if (written != nr) - return -EIO; - return 0; } -static int spufs_dump_align(struct file *file, char *buf, loff_t new_off, - loff_t *foffset) +static int spufs_dump_align(struct coredump_params *cprm, char *buf, loff_t new_off) { int rc, size; - size = min((loff_t)PAGE_SIZE, new_off - *foffset); + size = min((loff_t)PAGE_SIZE, new_off - cprm->written); memset(buf, 0, size); rc = 0; - while (rc == 0 && new_off > *foffset) { - size = min((loff_t)PAGE_SIZE, new_off - *foffset); - rc = spufs_dump_write(file, buf, size, foffset); + while (rc == 0 && new_off > cprm->written) { + size = min((loff_t)PAGE_SIZE, new_off - cprm->written); + rc = spufs_dump_write(cprm, buf, size); } return rc; @@ -165,7 +156,7 @@ int spufs_coredump_extra_notes_size(void) } static int spufs_arch_write_note(struct spu_context *ctx, int i, - struct file *file, int dfd, loff_t *foffset) + struct coredump_params *cprm, int dfd) { loff_t pos = 0; int sz, rc, nread, total = 0; @@ -186,22 +177,22 @@ static int spufs_arch_write_note(struct spu_context *ctx, int i, en.n_descsz = sz; en.n_type = NT_SPU; - rc = spufs_dump_write(file, &en, sizeof(en), foffset); + rc = spufs_dump_write(cprm, &en, sizeof(en)); if (rc) goto out; - rc = spufs_dump_write(file, fullname, en.n_namesz, foffset); + rc = spufs_dump_write(cprm, fullname, en.n_namesz); if (rc) goto out; - rc = spufs_dump_align(file, buf, roundup(*foffset, 4), foffset); + rc = spufs_dump_align(cprm, buf, roundup(cprm->written, 4)); if (rc) goto out; do { nread = do_coredump_read(i, ctx, buf, bufsz, &pos); if (nread > 0) { - rc = spufs_dump_write(file, buf, nread, foffset); + rc = spufs_dump_write(cprm, buf, nread); if (rc) goto out; total += nread; @@ -213,15 +204,14 @@ static int spufs_arch_write_note(struct spu_context *ctx, int i, goto out; } - rc = spufs_dump_align(file, buf, roundup(*foffset - total + sz, 4), - foffset); + rc = spufs_dump_align(cprm, buf, roundup(cprm->written - total + sz, 4)); out: free_page((unsigned long)buf); return rc; } -int spufs_coredump_extra_notes_write(struct file *file, loff_t *foffset) +int spufs_coredump_extra_notes_write(struct coredump_params *cprm) { struct spu_context *ctx; int fd, j, rc; @@ -233,7 +223,7 @@ int spufs_coredump_extra_notes_write(struct file *file, loff_t *foffset) return rc; for (j = 0; spufs_coredump_read[j].name != NULL; j++) { - rc = spufs_arch_write_note(ctx, j, file, fd, foffset); + rc = spufs_arch_write_note(ctx, j, cprm, fd); if (rc) { spu_release_saved(ctx); return rc; diff --git a/arch/powerpc/platforms/cell/spufs/spufs.h b/arch/powerpc/platforms/cell/spufs/spufs.h index 67852ade4c01..0ba3c9598358 100644 --- a/arch/powerpc/platforms/cell/spufs/spufs.h +++ b/arch/powerpc/platforms/cell/spufs/spufs.h @@ -247,12 +247,13 @@ extern const struct spufs_tree_descr spufs_dir_debug_contents[]; /* system call implementation */ extern struct spufs_calls spufs_calls; +struct coredump_params; long spufs_run_spu(struct spu_context *ctx, u32 *npc, u32 *status); long spufs_create(struct path *nd, struct dentry *dentry, unsigned int flags, umode_t mode, struct file *filp); /* ELF coredump callbacks for writing SPU ELF notes */ extern int spufs_coredump_extra_notes_size(void); -extern int spufs_coredump_extra_notes_write(struct file *file, loff_t *foffset); +extern int spufs_coredump_extra_notes_write(struct coredump_params *cprm); extern const struct file_operations spufs_context_fops; |