Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 211506
b: refs/heads/master
c: 3aa0ce8
h: refs/heads/master
v: v3
  • Loading branch information
Linus Torvalds committed Oct 14, 2010
1 parent 0507153 commit ae51455
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 33 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ae42d8d44195a614c78a636683fe65ed31744cbd
refs/heads/master: 3aa0ce825ade0cf5506e32ccf51d01fc8d22a9cf
38 changes: 38 additions & 0 deletions trunk/fs/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
34 changes: 2 additions & 32 deletions trunk/include/linux/coredump.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

0 comments on commit ae51455

Please sign in to comment.