2010-03-06 04:44:06 +07:00
|
|
|
#ifndef _LINUX_COREDUMP_H
|
|
|
|
#define _LINUX_COREDUMP_H
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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)
|
|
|
|
{
|
2010-10-15 00:57:40 +07:00
|
|
|
return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, addr, nr, &file->f_pos) == nr;
|
2010-03-06 04:44:06 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int dump_seek(struct file *file, loff_t off)
|
|
|
|
{
|
2010-03-11 06:21:22 +07:00
|
|
|
int ret = 1;
|
|
|
|
|
2010-03-06 04:44:06 +07:00
|
|
|
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;
|
2010-03-11 06:21:22 +07:00
|
|
|
if (!dump_write(file, buf, n)) {
|
|
|
|
ret = 0;
|
|
|
|
break;
|
|
|
|
}
|
2010-03-06 04:44:06 +07:00
|
|
|
off -= n;
|
|
|
|
}
|
|
|
|
free_page((unsigned long)buf);
|
|
|
|
}
|
2010-03-11 06:21:22 +07:00
|
|
|
return ret;
|
2010-03-06 04:44:06 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* _LINUX_COREDUMP_H */
|