From: Oleg Nesterov <oleg@redhat.com>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Alexey Dobriyan <adobriyan@gmail.com>,
Al Viro <viro@zeniv.linux.org.uk>,
Vasiliy Kulikov <segoon@openwall.com>,
David Rientjes <rientjes@google.com>
Subject: Re: [Patch v2] proc: clean up /proc/<pid>/environ handling
Date: Tue, 3 Apr 2012 17:02:25 +0200 [thread overview]
Message-ID: <20120403150225.GA6152@redhat.com> (raw)
In-Reply-To: <1333441703-8180-1-git-send-email-xiyou.wangcong@gmail.com>
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.
next prev parent reply other threads:[~2012-04-03 15:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20120328153936.495f567a.akpm@linux-foundation.org>
2012-04-03 8:28 ` [Patch v2] proc: clean up /proc/<pid>/environ handling Cong Wang
2012-04-03 15:02 ` Oleg Nesterov [this message]
2012-04-04 5:58 ` Cong Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120403150225.GA6152@redhat.com \
--to=oleg@redhat.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rientjes@google.com \
--cc=segoon@openwall.com \
--cc=viro@zeniv.linux.org.uk \
--cc=xiyou.wangcong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.