Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 137581
b: refs/heads/master
c: 7c2c7d9
h: refs/heads/master
i:
  137579: 75d810d
v: v3
  • Loading branch information
Hugh Dickins authored and Linus Torvalds committed Mar 29, 2009
1 parent 67fef68 commit 8ed4300
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 35 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e426b64c412aaa3e9eb3e4b261dc5be0d5a83e78
refs/heads/master: 7c2c7d993044cddc5010f6f429b100c63bc7dffb
50 changes: 16 additions & 34 deletions trunk/fs/proc/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,22 @@ static unsigned int pid_entry_count_dirs(const struct pid_entry *entries,
return count;
}

static struct fs_struct *get_fs_struct(struct task_struct *task)
static int get_fs_path(struct task_struct *task, struct path *path, bool root)
{
struct fs_struct *fs;
int result = -ENOENT;

task_lock(task);
fs = task->fs;
if(fs)
atomic_inc(&fs->count);
if (fs) {
read_lock(&fs->lock);
*path = root ? fs->root : fs->pwd;
path_get(path);
read_unlock(&fs->lock);
result = 0;
}
task_unlock(task);
return fs;
return result;
}

static int get_nr_threads(struct task_struct *tsk)
Expand All @@ -172,42 +179,24 @@ static int get_nr_threads(struct task_struct *tsk)
static int proc_cwd_link(struct inode *inode, struct path *path)
{
struct task_struct *task = get_proc_task(inode);
struct fs_struct *fs = NULL;
int result = -ENOENT;

if (task) {
fs = get_fs_struct(task);
result = get_fs_path(task, path, 0);
put_task_struct(task);
}
if (fs) {
read_lock(&fs->lock);
*path = fs->pwd;
path_get(&fs->pwd);
read_unlock(&fs->lock);
result = 0;
put_fs_struct(fs);
}
return result;
}

static int proc_root_link(struct inode *inode, struct path *path)
{
struct task_struct *task = get_proc_task(inode);
struct fs_struct *fs = NULL;
int result = -ENOENT;

if (task) {
fs = get_fs_struct(task);
result = get_fs_path(task, path, 1);
put_task_struct(task);
}
if (fs) {
read_lock(&fs->lock);
*path = fs->root;
path_get(&fs->root);
read_unlock(&fs->lock);
result = 0;
put_fs_struct(fs);
}
return result;
}

Expand Down Expand Up @@ -596,7 +585,6 @@ static int mounts_open_common(struct inode *inode, struct file *file,
struct task_struct *task = get_proc_task(inode);
struct nsproxy *nsp;
struct mnt_namespace *ns = NULL;
struct fs_struct *fs = NULL;
struct path root;
struct proc_mounts *p;
int ret = -EINVAL;
Expand All @@ -610,22 +598,16 @@ static int mounts_open_common(struct inode *inode, struct file *file,
get_mnt_ns(ns);
}
rcu_read_unlock();
if (ns)
fs = get_fs_struct(task);
if (ns && get_fs_path(task, &root, 1) == 0)
ret = 0;
put_task_struct(task);
}

if (!ns)
goto err;
if (!fs)
if (ret)
goto err_put_ns;

read_lock(&fs->lock);
root = fs->root;
path_get(&root);
read_unlock(&fs->lock);
put_fs_struct(fs);

ret = -ENOMEM;
p = kmalloc(sizeof(struct proc_mounts), GFP_KERNEL);
if (!p)
Expand Down

0 comments on commit 8ed4300

Please sign in to comment.