This patch cleans up proc_cwd_link() and proc_root_link() by factoring
out common code into get_fs_struct().

Signed-off-by: Miklos Szeredi <[EMAIL PROTECTED]>

Index: linux/fs/proc/base.c
===================================================================
--- linux.orig/fs/proc/base.c   2005-08-19 14:47:20.000000000 +0200
+++ linux/fs/proc/base.c        2005-08-19 14:47:35.000000000 +0200
@@ -298,15 +298,21 @@ static int proc_fd_link(struct inode *in
        return -ENOENT;
 }
 
-static int proc_cwd_link(struct inode *inode, struct dentry **dentry, struct 
vfsmount **mnt)
+static struct fs_struct *get_fs_struct(struct task_struct *task)
 {
        struct fs_struct *fs;
-       int result = -ENOENT;
-       task_lock(proc_task(inode));
-       fs = proc_task(inode)->fs;
+       task_lock(task);
+       fs = task->fs;
        if(fs)
                atomic_inc(&fs->count);
-       task_unlock(proc_task(inode));
+       task_unlock(task);
+       return fs;
+}
+
+static int proc_cwd_link(struct inode *inode, struct dentry **dentry, struct 
vfsmount **mnt)
+{
+       struct fs_struct *fs = get_fs_struct(proc_task(inode));
+       int result = -ENOENT;
        if (fs) {
                read_lock(&fs->lock);
                *mnt = mntget(fs->pwdmnt);
@@ -320,13 +326,8 @@ static int proc_cwd_link(struct inode *i
 
 static int proc_root_link(struct inode *inode, struct dentry **dentry, struct 
vfsmount **mnt)
 {
-       struct fs_struct *fs;
+       struct fs_struct *fs = get_fs_struct(proc_task(inode));
        int result = -ENOENT;
-       task_lock(proc_task(inode));
-       fs = proc_task(inode)->fs;
-       if(fs)
-               atomic_inc(&fs->count);
-       task_unlock(proc_task(inode));
        if (fs) {
                read_lock(&fs->lock);
                *mnt = mntget(fs->rootmnt);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to