lkml.org 
[lkml]   [2012]   [Apr]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [Patch v2] proc: clean up /proc/<pid>/environ handling
On 04/03, Cong Wang wrote:
>
> +static int environ_open(struct inode *inode, struct file *file)
> +{
> + struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode);
> + struct mm_struct *mm;
> +
> + if (!task)
> + return -ESRCH;
> +
> + mm = mm_for_maps(task);
> + put_task_struct(task);
> +
> + if (IS_ERR(mm))
> + return PTR_ERR(mm);
> +
> + if (mm) {
> + /* ensure this mm_struct can't be freed */
> + atomic_inc(&mm->mm_count);
> + /* but do not pin its memory */
> + mmput(mm);
> + }
> +
> + file->private_data = mm;
> +
> + return 0;
> +}

Well, can we unify this code with mem_open() ? Say, let it be
__mem_open() or whatever, then mem_open() can use the common
helper and add FMODE_UNSIGNED_OFFSET. Just we need another
argument for mm_access.

> +static int environ_release(struct inode *inode, struct file *file)
> +{
> + struct mm_struct *mm = file->private_data;
> + if (mm)
> + mmdrop(mm);
> + return 0;
> +}

Again, this is identical with mem_release(), proc_environ_operations
can simply use it instead.

Oleg.



\
 
 \ /
  Last update: 2012-04-03 17:05    [W:0.036 / U:0.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site