aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorMiklos Szeredi <miklos@szeredi.hu>2005-09-06 18:18:22 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-09-07 19:57:43 -0400
commit0494f6ec5d3a015d53b57e37280b93c19446676a (patch)
treeb48855ab886d962d50807047eeff086ee50b882a /fs
parent09dd17d3e5e43ea6d3f3a12829108c4ca13ff810 (diff)
[PATCH] use get_fs_struct() in proc
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 <miklos@szeredi.hu> Cc: <viro@parcelfarce.linux.theplanet.co.uk> Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/proc/base.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 520978e49e92..73b1e94171b7 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -297,15 +297,21 @@ static int proc_fd_link(struct inode *inode, struct dentry **dentry, struct vfsm
297 return -ENOENT; 297 return -ENOENT;
298} 298}
299 299
300static int proc_cwd_link(struct inode *inode, struct dentry **dentry, struct vfsmount **mnt) 300static struct fs_struct *get_fs_struct(struct task_struct *task)
301{ 301{
302 struct fs_struct *fs; 302 struct fs_struct *fs;
303 int result = -ENOENT; 303 task_lock(task);
304 task_lock(proc_task(inode)); 304 fs = task->fs;
305 fs = proc_task(inode)->fs;
306 if(fs) 305 if(fs)
307 atomic_inc(&fs->count); 306 atomic_inc(&fs->count);
308 task_unlock(proc_task(inode)); 307 task_unlock(task);
308 return fs;
309}
310
311static int proc_cwd_link(struct inode *inode, struct dentry **dentry, struct vfsmount **mnt)
312{
313 struct fs_struct *fs = get_fs_struct(proc_task(inode));
314 int result = -ENOENT;
309 if (fs) { 315 if (fs) {
310 read_lock(&fs->lock); 316 read_lock(&fs->lock);
311 *mnt = mntget(fs->pwdmnt); 317 *mnt = mntget(fs->pwdmnt);
@@ -319,13 +325,8 @@ static int proc_cwd_link(struct inode *inode, struct dentry **dentry, struct vfs
319 325
320static int proc_root_link(struct inode *inode, struct dentry **dentry, struct vfsmount **mnt) 326static int proc_root_link(struct inode *inode, struct dentry **dentry, struct vfsmount **mnt)
321{ 327{
322 struct fs_struct *fs; 328 struct fs_struct *fs = get_fs_struct(proc_task(inode));
323 int result = -ENOENT; 329 int result = -ENOENT;
324 task_lock(proc_task(inode));
325 fs = proc_task(inode)->fs;
326 if(fs)
327 atomic_inc(&fs->count);
328 task_unlock(proc_task(inode));
329 if (fs) { 330 if (fs) {
330 read_lock(&fs->lock); 331 read_lock(&fs->lock);
331 *mnt = mntget(fs->rootmnt); 332 *mnt = mntget(fs->rootmnt);