diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-10-19 17:06:36 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-10-19 17:06:36 -0400 |
commit | 809b4e00baf006a990a73329ba381d536c6fa277 (patch) | |
tree | e949e0efd019d6f932537aba762792b07a84351c /fs/exec.c | |
parent | a0a55682b83fd5f012afadcf415b030d7424ae68 (diff) | |
parent | 79a94c3538bda6869d7bb150b5e02dd3a72314dd (diff) |
Merge branch 'devel-stable' into devel
Diffstat (limited to 'fs/exec.c')
-rw-r--r-- | fs/exec.c | 38 |
1 files changed, 38 insertions, 0 deletions
@@ -2014,3 +2014,41 @@ 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 | |||
2028 | int dump_seek(struct file *file, loff_t off) | ||
2029 | { | ||
2030 | int ret = 1; | ||
2031 | |||
2032 | if (file->f_op->llseek && file->f_op->llseek != no_llseek) { | ||
2033 | if (file->f_op->llseek(file, off, SEEK_CUR) < 0) | ||
2034 | return 0; | ||
2035 | } else { | ||
2036 | char *buf = (char *)get_zeroed_page(GFP_KERNEL); | ||
2037 | |||
2038 | if (!buf) | ||
2039 | return 0; | ||
2040 | while (off > 0) { | ||
2041 | unsigned long n = off; | ||
2042 | |||
2043 | if (n > PAGE_SIZE) | ||
2044 | n = PAGE_SIZE; | ||
2045 | if (!dump_write(file, buf, n)) { | ||
2046 | ret = 0; | ||
2047 | break; | ||
2048 | } | ||
2049 | off -= n; | ||
2050 | } | ||
2051 | free_page((unsigned long)buf); | ||
2052 | } | ||
2053 | return ret; | ||
2054 | } | ||