diff options
author | Mike Frysinger <vapier@gentoo.org> | 2011-03-29 09:05:12 -0400 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2011-03-29 09:05:12 -0400 |
commit | f55f199b7d76a01e7ce9d1c3bb004327e075c327 (patch) | |
tree | 66aecc92b98f3425aeeed19cccfe29de017ade7e /mm | |
parent | b554cb426a955a267dba524f98f99e29bc947643 (diff) |
NOMMU: implement access_remote_vm
Recent vm changes brought in a new function which the core procfs code
utilizes. So implement it for nommu systems too to avoid link failures.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: David Howells <dhowells@redhat.com>
Tested-by: Simon Horman <horms@verge.net.au>
Tested-by: Ithamar Adema <ithamar.adema@team-embedded.nl>
Acked-by: Greg Ungerer <gerg@uclinux.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/nommu.c | 52 |
1 files changed, 39 insertions, 13 deletions
diff --git a/mm/nommu.c b/mm/nommu.c index cb86e7d5e7f5..c4c542c736a9 100644 --- a/mm/nommu.c +++ b/mm/nommu.c | |||
@@ -1971,21 +1971,10 @@ int filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
1971 | } | 1971 | } |
1972 | EXPORT_SYMBOL(filemap_fault); | 1972 | EXPORT_SYMBOL(filemap_fault); |
1973 | 1973 | ||
1974 | /* | 1974 | static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm, |
1975 | * Access another process' address space. | 1975 | unsigned long addr, void *buf, int len, int write) |
1976 | * - source/target buffer must be kernel space | ||
1977 | */ | ||
1978 | int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write) | ||
1979 | { | 1976 | { |
1980 | struct vm_area_struct *vma; | 1977 | struct vm_area_struct *vma; |
1981 | struct mm_struct *mm; | ||
1982 | |||
1983 | if (addr + len < addr) | ||
1984 | return 0; | ||
1985 | |||
1986 | mm = get_task_mm(tsk); | ||
1987 | if (!mm) | ||
1988 | return 0; | ||
1989 | 1978 | ||
1990 | down_read(&mm->mmap_sem); | 1979 | down_read(&mm->mmap_sem); |
1991 | 1980 | ||
@@ -2010,6 +1999,43 @@ int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, in | |||
2010 | } | 1999 | } |
2011 | 2000 | ||
2012 | up_read(&mm->mmap_sem); | 2001 | up_read(&mm->mmap_sem); |
2002 | |||
2003 | return len; | ||
2004 | } | ||
2005 | |||
2006 | /** | ||
2007 | * @access_remote_vm - access another process' address space | ||
2008 | * @mm: the mm_struct of the target address space | ||
2009 | * @addr: start address to access | ||
2010 | * @buf: source or destination buffer | ||
2011 | * @len: number of bytes to transfer | ||
2012 | * @write: whether the access is a write | ||
2013 | * | ||
2014 | * The caller must hold a reference on @mm. | ||
2015 | */ | ||
2016 | int access_remote_vm(struct mm_struct *mm, unsigned long addr, | ||
2017 | void *buf, int len, int write) | ||
2018 | { | ||
2019 | return __access_remote_vm(NULL, mm, addr, buf, len, write); | ||
2020 | } | ||
2021 | |||
2022 | /* | ||
2023 | * Access another process' address space. | ||
2024 | * - source/target buffer must be kernel space | ||
2025 | */ | ||
2026 | int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write) | ||
2027 | { | ||
2028 | struct mm_struct *mm; | ||
2029 | |||
2030 | if (addr + len < addr) | ||
2031 | return 0; | ||
2032 | |||
2033 | mm = get_task_mm(tsk); | ||
2034 | if (!mm) | ||
2035 | return 0; | ||
2036 | |||
2037 | len = __access_remote_vm(tsk, mm, addr, buf, len, write); | ||
2038 | |||
2013 | mmput(mm); | 2039 | mmput(mm); |
2014 | return len; | 2040 | return len; |
2015 | } | 2041 | } |