This patch makes the /proc/|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 --- 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 from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/