From: Matt Helsley <matthltc@us.ibm.com>
To: Linux-Kernel <linux-kernel@vger.kernel.org>,
linux-mm <linux-mm@kvack.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Al Viro <viro@ftp.linux.org.uk>,
Dave Hansen <haveblue@us.ibm.com>
Subject: [RFC][PATCH 3/3] [RFC][PATCH] Make /proc/pid/exe symlink changeable
Date: Wed, 31 Oct 2007 20:35:11 -0700 [thread overview]
Message-ID: <20071101044124.835937000@us.ibm.com> (raw)
In-Reply-To: <20071101033508.720885000@us.ibm.com>
[-- Attachment #1: writeable_proc_pid_exe --]
[-- Type: text/plain, Size: 2745 bytes --]
This patch makes the /proc/<pid>|self/exe symlink writeable. This
functionality could be useful to potential checkpoint/restart implementations
restarting Java VMs, for example. Java uses this symlink to locate
JAVAHOME so any restarted Java program requires that /proc/self/exe points to
the jvm and not the restart exectuable.
Signed-off-by: Matt Helsley <matthltc@us.ibm.com>
---
fs/proc/base.c | 37 ++++++++++++++++++++++++++++++++++++-
1 file changed, 36 insertions(+), 1 deletion(-)
Index: linux-2.6.23/fs/proc/base.c
===================================================================
--- linux-2.6.23.orig/fs/proc/base.c
+++ linux-2.6.23/fs/proc/base.c
@@ -930,10 +930,37 @@ static const struct file_operations proc
.release = single_release,
};
#endif
+static int proc_pid_exe_symlink(struct inode *inode, struct dentry *dentry,
+ const char *path)
+{
+ struct file *new_exe_file;
+ struct task_struct *task;
+ struct mm_struct *mm;
+ int error;
+
+ if (!proc_fd_access_allowed(dentry->d_inode))
+ return -EACCES;
+ task = get_proc_task(inode);
+ if (!task)
+ return -ENOENT;
+ mm = get_task_mm(task);
+ put_task_struct(task);
+ if (!mm)
+ return -ENOENT;
+ new_exe_file = open_exec(path);
+ error = PTR_ERR(new_exe_file);
+ if (!IS_ERR(error)) {
+ set_mm_exe_file(mm, new_exe_file);
+ error = 0;
+ }
+ mmput(mm);
+ return error;
+}
+
static int proc_exe_link(struct inode *inode, struct dentry **dentry,
struct vfsmount **mnt)
{
struct task_struct *task;
struct mm_struct *mm;
@@ -1027,10 +1054,16 @@ static const struct inode_operations pro
.readlink = proc_pid_readlink,
.follow_link = proc_pid_follow_link,
.setattr = proc_setattr,
};
+static const struct inode_operations proc_pid_exe_inode_operations = {
+ .readlink = proc_pid_readlink,
+ .follow_link = proc_pid_follow_link,
+ .symlink = proc_pid_exe_symlink,
+ .setattr = proc_setattr,
+};
/* building an inode */
static int task_dumpable(struct task_struct *task)
{
@@ -2087,11 +2120,13 @@ static const struct pid_entry tgid_base_
REG("numa_maps", S_IRUGO, numa_maps),
#endif
REG("mem", S_IRUSR|S_IWUSR, mem),
LNK("cwd", cwd),
LNK("root", root),
- LNK("exe", exe),
+ NOD("exe", (S_IFLNK|S_IRWXUGO),
+ &proc_pid_exe_inode_operations, NULL,
+ { .proc_get_link = &proc_exe_link }),
REG("mounts", S_IRUGO, mounts),
REG("mountstats", S_IRUSR, mountstats),
#ifdef CONFIG_MMU
REG("clear_refs", S_IWUSR, clear_refs),
REG("smaps", S_IRUGO, smaps),
--
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
prev parent reply other threads:[~2007-11-01 4:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-01 3:35 [RFC][PATCH 0/3] Procfs Task exe Symlinks Matt Helsley
2007-11-01 3:35 ` [RFC][PATCH 1/3] [RFC][PATCH] Fix procfs task exe symlinks Matt Helsley
2007-11-01 19:25 ` Andrew Morton
2007-11-01 19:52 ` Matt Helsley
2007-11-01 3:35 ` [RFC][PATCH 2/3] [RFC][PATCH] Add spinlock in mm to protext exe reference Matt Helsley
2007-11-01 3:35 ` Matt Helsley [this message]
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=20071101044124.835937000@us.ibm.com \
--to=matthltc@us.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=haveblue@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=viro@ftp.linux.org.uk \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox