diff options
Diffstat (limited to 'fs/exec.c')
| -rw-r--r-- | fs/exec.c | 40 |
1 files changed, 40 insertions, 0 deletions
| @@ -2014,3 +2014,43 @@ fail_creds: | |||
| 2014 | fail: | 2014 | fail: |
| 2015 | return; | 2015 | return; |
| 2016 | } | 2016 | } |
| 2017 | |||
| 2018 | /* | ||
| 2019 | * Core dumping helper functions. These are the only things you should | ||
| 2020 | * do on a core-file: use only these functions to write out all the | ||
| 2021 | * necessary info. | ||
| 2022 | */ | ||
| 2023 | int dump_write(struct file *file, const void *addr, int nr) | ||
| 2024 | { | ||
| 2025 | return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, addr, nr, &file->f_pos) == nr; | ||
| 2026 | } | ||
| 2027 | EXPORT_SYMBOL(dump_write); | ||
| 2028 | |||
| 2029 | int dump_seek(struct file *file, loff_t off) | ||
| 2030 | { | ||
| 2031 | int ret = 1; | ||
| 2032 | |||
| 2033 | if (file->f_op->llseek && file->f_op->llseek != no_llseek) { | ||
| 2034 | if (file->f_op->llseek(file, off, SEEK_CUR) < 0) | ||
| 2035 | return 0; | ||
| 2036 | } else { | ||
| 2037 | char *buf = (char *)get_zeroed_page(GFP_KERNEL); | ||
| 2038 | |||
| 2039 | if (!buf) | ||
| 2040 | return 0; | ||
| 2041 | while (off > 0) { | ||
| 2042 | unsigned long n = off; | ||
| 2043 | |||
| 2044 | if (n > PAGE_SIZE) | ||
| 2045 | n = PAGE_SIZE; | ||
| 2046 | if (!dump_write(file, buf, n)) { | ||
| 2047 | ret = 0; | ||
| 2048 | break; | ||
| 2049 | } | ||
| 2050 | off -= n; | ||
| 2051 | } | ||
| 2052 | free_page((unsigned long)buf); | ||
| 2053 | } | ||
| 2054 | return ret; | ||
| 2055 | } | ||
| 2056 | EXPORT_SYMBOL(dump_seek); | ||
