23 #include <linux/elf.h>
28 #include <linux/list.h>
31 #include <asm/uaccess.h>
36 size_t size, loff_t *off)
45 ret =
snprintf(buffer, size,
"0x%.16llx", data);
55 static int spufs_dump_write(
struct file *
file,
const void *
addr,
int nr, loff_t *foffset)
60 if (*foffset + nr > limit)
63 written = file->
f_op->write(file, addr, nr, &file->
f_pos);
72 static int spufs_dump_align(
struct file *file,
char *
buf, loff_t new_off,
81 while (rc == 0 && new_off > *foffset) {
83 rc = spufs_dump_write(file, buf, size, foffset);
89 static int spufs_ctx_note_size(
struct spu_context *ctx,
int dfd)
99 sprintf(fullname,
"SPU/%d/%s", dfd, name);
109 static int match_context(
const void *
v,
struct file *file,
unsigned fd)
114 ctx =
SPUFS_I(file->f_dentry->d_inode)->i_ctx;
115 if (ctx->
flags & SPU_CREATE_NOSCHED)
132 static struct spu_context *coredump_next_context(
int *fd)
140 return SPUFS_I(file->f_dentry->d_inode)->i_ctx;
146 int size = 0,
rc,
fd;
149 while ((ctx = coredump_next_context(&fd)) !=
NULL) {
153 rc = spufs_ctx_note_size(ctx, fd);
167 static int spufs_arch_write_note(
struct spu_context *ctx,
int i,
168 struct file *file,
int dfd, loff_t *foffset)
171 int sz,
rc, nread, total = 0;
174 char fullname[80], *
buf;
184 sprintf(fullname,
"SPU/%d/%s", dfd, name);
185 en.n_namesz =
strlen(fullname) + 1;
189 rc = spufs_dump_write(file, &en,
sizeof(en), foffset);
193 rc = spufs_dump_write(file, fullname, en.n_namesz, foffset);
197 rc = spufs_dump_align(file, buf,
roundup(*foffset, 4), foffset);
202 nread = do_coredump_read(i, ctx, buf, bufsz, &pos);
204 rc = spufs_dump_write(file, buf, nread, foffset);
209 }
while (nread == bufsz && total < sz);
216 rc = spufs_dump_align(file, buf,
roundup(*foffset - total + sz, 4),
230 while ((ctx = coredump_next_context(&fd)) !=
NULL) {
236 rc = spufs_arch_write_note(ctx, j, file, fd, foffset);