summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorJiri Slaby <jirislaby@gmail.com>2009-11-27 15:25:03 +0100
committerJiri Slaby <jslaby@suse.cz>2009-12-09 20:18:07 +0100
commitd97c5c2d5682990e3d798fc9468777eb767f1684 (patch)
tree9be82ef41129bf3762c6b4596cdc808cc2d13490 /fs
parent35d44b92ea8439c0e3d61b1d3a09de7009d7cf48 (diff)
FS: proc, switch limits reading to fops
Use fops instead of proc_info_read. We will need fops for limits writing and the code would look ugly if we used NOD("limits", S_IFREG|S_IRUSR|S_IWUSR, NULL, &proc_pid_limits_operations, { .proc_read = proc_pid_limits }), We will just use REG("limits", S_IRUSR|S_IWUSR, proc_pid_limits_operations), Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/proc/base.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c
index af643b5aefe8..be4733cfb72f 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -477,19 +477,30 @@ static const struct limit_names lnames[RLIM_NLIMITS] = {
};
/* Display limits for a process */
-static int proc_pid_limits(struct task_struct *task, char *buffer)
+static ssize_t limits_read(struct file *file, char __user *buf, size_t rcount,
+ loff_t *ppos)
{
- unsigned int i;
- int count = 0;
- unsigned long flags;
- char *bufptr = buffer;
-
struct rlimit rlim[RLIM_NLIMITS];
+ struct task_struct *task;
+ unsigned long flags;
+ unsigned int i;
+ ssize_t count = 0;
+ char *bufptr;
- if (!lock_task_sighand(task, &flags))
+ task = get_proc_task(file->f_path.dentry->d_inode);
+ if (!task)
+ return -ESRCH;
+ if (!lock_task_sighand(task, &flags)) {
+ put_task_struct(task);
return 0;
+ }
memcpy(rlim, task->signal->rlim, sizeof(struct rlimit) * RLIM_NLIMITS);
unlock_task_sighand(task, &flags);
+ put_task_struct(task);
+
+ bufptr = (char *)__get_free_page(GFP_TEMPORARY);
+ if (!bufptr)
+ return -ENOMEM;
/*
* print the file header
@@ -518,9 +529,17 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
count += sprintf(&bufptr[count], "\n");
}
+ count = simple_read_from_buffer(buf, rcount, ppos, bufptr, count);
+
+ free_page((unsigned long)bufptr);
+
return count;
}
+static const struct file_operations proc_pid_limits_operations = {
+ .read = limits_read,
+};
+
#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
static int proc_pid_syscall(struct task_struct *task, char *buffer)
{
@@ -2500,7 +2519,7 @@ static const struct pid_entry tgid_base_stuff[] = {
INF("auxv", S_IRUSR, proc_pid_auxv),
ONE("status", S_IRUGO, proc_pid_status),
ONE("personality", S_IRUSR, proc_pid_personality),
- INF("limits", S_IRUSR, proc_pid_limits),
+ REG("limits", S_IRUSR, proc_pid_limits_operations),
#ifdef CONFIG_SCHED_DEBUG
REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
#endif
@@ -2834,7 +2853,7 @@ static const struct pid_entry tid_base_stuff[] = {
INF("auxv", S_IRUSR, proc_pid_auxv),
ONE("status", S_IRUGO, proc_pid_status),
ONE("personality", S_IRUSR, proc_pid_personality),
- INF("limits", S_IRUSR, proc_pid_limits),
+ REG("limits", S_IRUSR, proc_pid_limits_operations),
#ifdef CONFIG_SCHED_DEBUG
REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
#endif