Blame view

include/linux/coredump.h 938 Bytes
088e7af73   Daisuke HATAYAMA   coredump: move du...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  #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)
  {
  	return file->f_op->write(file, addr, nr, &file->f_pos) == nr;
  }
  
  static inline int dump_seek(struct file *file, loff_t off)
  {
6e3e37a5a   André Goddard Rosa   coredump: plug a ...
19
  	int ret = 1;
088e7af73   Daisuke HATAYAMA   coredump: move du...
20
21
22
23
24
25
26
27
28
29
30
31
32
  	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;
6e3e37a5a   André Goddard Rosa   coredump: plug a ...
33
34
35
36
  			if (!dump_write(file, buf, n)) {
  				ret = 0;
  				break;
  			}
088e7af73   Daisuke HATAYAMA   coredump: move du...
37
38
39
40
  			off -= n;
  		}
  		free_page((unsigned long)buf);
  	}
6e3e37a5a   André Goddard Rosa   coredump: plug a ...
41
  	return ret;
088e7af73   Daisuke HATAYAMA   coredump: move du...
42
43
44
  }
  
  #endif /* _LINUX_COREDUMP_H */