maps4: move clear_refs code to task_mmu.c

This puts all the clear_refs code where it belongs and probably lets things
compile on MMU-less systems as well.

Signed-off-by: Matt Mackall <mpm@selenic.com>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Dave Hansen <haveblue@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Matt Mackall
2008-02-04 22:29:03 -08:00
committed by Linus Torvalds
parent 4752c36978
commit f248dcb34d
4 changed files with 39 additions and 54 deletions

View File

@@ -88,10 +88,6 @@
* in /proc for a task before it execs a suid executable.
*/
/* Worst case buffer size needed for holding an integer. */
#define PROC_NUMBUF 13
struct pid_entry {
char *name;
int len;
@@ -935,42 +931,6 @@ static const struct file_operations proc_oom_adjust_operations = {
.write = oom_adjust_write,
};
#ifdef CONFIG_MMU
static ssize_t clear_refs_write(struct file *file, const char __user *buf,
size_t count, loff_t *ppos)
{
struct task_struct *task;
char buffer[PROC_NUMBUF], *end;
struct mm_struct *mm;
memset(buffer, 0, sizeof(buffer));
if (count > sizeof(buffer) - 1)
count = sizeof(buffer) - 1;
if (copy_from_user(buffer, buf, count))
return -EFAULT;
if (!simple_strtol(buffer, &end, 0))
return -EINVAL;
if (*end == '\n')
end++;
task = get_proc_task(file->f_path.dentry->d_inode);
if (!task)
return -ESRCH;
mm = get_task_mm(task);
if (mm) {
clear_refs_smap(mm);
mmput(mm);
}
put_task_struct(task);
if (end - buffer == 0)
return -EIO;
return end - buffer;
}
static struct file_operations proc_clear_refs_operations = {
.write = clear_refs_write,
};
#endif
#ifdef CONFIG_AUDITSYSCALL
#define TMPBUFLEN 21
static ssize_t proc_loginuid_read(struct file * file, char __user * buf,