[PATCH 12/13] Use struct path argument in proc_get_link()

2007-10-22 Thread Bharata B Rao
Replace the (vfsmnt, dentry) arguments in proc_inode operation proc_get_link()
by struct path.

Also, this should eventually allow do_proc_readlink() to call d_path() with
a struct path argument.

Signed-off-by: Bharata B Rao <[EMAIL PROTECTED]>
---
 fs/proc/base.c  |   60 +---
 fs/proc/internal.h  |2 -
 fs/proc/task_mmu.c  |6 ++--
 fs/proc/task_nommu.c|6 ++--
 include/linux/proc_fs.h |2 -
 5 files changed, 35 insertions(+), 41 deletions(-)

--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -153,7 +153,7 @@ static int get_nr_threads(struct task_st
return count;
 }
 
-static int proc_cwd_link(struct inode *inode, struct dentry **dentry, struct 
vfsmount **mnt)
+static int proc_cwd_link(struct inode *inode, struct path *path)
 {
struct task_struct *task = get_proc_task(inode);
struct fs_struct *fs = NULL;
@@ -165,8 +165,8 @@ static int proc_cwd_link(struct inode *i
}
if (fs) {
read_lock(>lock);
-   *mnt = mntget(fs->pwd.mnt);
-   *dentry = dget(fs->pwd.dentry);
+   *path = fs->pwd;
+   path_get(path);
read_unlock(>lock);
result = 0;
put_fs_struct(fs);
@@ -174,7 +174,7 @@ static int proc_cwd_link(struct inode *i
return result;
 }
 
-static int proc_root_link(struct inode *inode, struct dentry **dentry, struct 
vfsmount **mnt)
+static int proc_root_link(struct inode *inode, struct path *path)
 {
struct task_struct *task = get_proc_task(inode);
struct fs_struct *fs = NULL;
@@ -186,8 +186,8 @@ static int proc_root_link(struct inode *
}
if (fs) {
read_lock(>lock);
-   *mnt = mntget(fs->root.mnt);
-   *dentry = dget(fs->root.dentry);
+   *path = fs->root;
+   path_get(path);
read_unlock(>lock);
result = 0;
put_fs_struct(fs);
@@ -1039,34 +1039,32 @@ static void *proc_pid_follow_link(struct
if (!proc_fd_access_allowed(inode))
goto out;
 
-   error = PROC_I(inode)->op.proc_get_link(inode, >path.dentry,
-   >path.mnt);
+   error = PROC_I(inode)->op.proc_get_link(inode, >path);
nd->last_type = LAST_BIND;
 out:
return ERR_PTR(error);
 }
 
-static int do_proc_readlink(struct dentry *dentry, struct vfsmount *mnt,
-   char __user *buffer, int buflen)
+static int do_proc_readlink(struct path *path, char __user *buffer, int buflen)
 {
struct inode * inode;
char *tmp = (char*)__get_free_page(GFP_TEMPORARY);
-   char *path;
+   char *pathname;
int len;
 
if (!tmp)
return -ENOMEM;
 
-   inode = dentry->d_inode;
-   path = d_path(dentry, mnt, tmp, PAGE_SIZE);
-   len = PTR_ERR(path);
-   if (IS_ERR(path))
+   inode = path->dentry->d_inode;
+   pathname = d_path(path->dentry, path->mnt, tmp, PAGE_SIZE);
+   len = PTR_ERR(pathname);
+   if (IS_ERR(pathname))
goto out;
-   len = tmp + PAGE_SIZE - 1 - path;
+   len = tmp + PAGE_SIZE - 1 - pathname;
 
if (len > buflen)
len = buflen;
-   if (copy_to_user(buffer, path, len))
+   if (copy_to_user(buffer, pathname, len))
len = -EFAULT;
  out:
free_page((unsigned long)tmp);
@@ -1077,20 +1075,18 @@ static int proc_pid_readlink(struct dent
 {
int error = -EACCES;
struct inode *inode = dentry->d_inode;
-   struct dentry *de;
-   struct vfsmount *mnt = NULL;
+   struct path path;
 
/* Are we allowed to snoop on the tasks file descriptors? */
if (!proc_fd_access_allowed(inode))
goto out;
 
-   error = PROC_I(inode)->op.proc_get_link(inode, , );
+   error = PROC_I(inode)->op.proc_get_link(inode, );
if (error)
goto out;
 
-   error = do_proc_readlink(de, mnt, buffer, buflen);
-   dput(de);
-   mntput(mnt);
+   error = do_proc_readlink(, buffer, buflen);
+   path_put();
 out:
return error;
 }
@@ -1317,8 +1313,7 @@ out:
 
 #define PROC_FDINFO_MAX 64
 
-static int proc_fd_info(struct inode *inode, struct dentry **dentry,
-   struct vfsmount **mnt, char *info)
+static int proc_fd_info(struct inode *inode, struct path *path, char *info)
 {
struct task_struct *task = get_proc_task(inode);
struct files_struct *files = NULL;
@@ -1337,10 +1332,10 @@ static int proc_fd_info(struct inode *in
spin_lock(>file_lock);
file = fcheck_files(files, fd);
if (file) {
-   if (mnt)
-   *mnt = mntget(file->f_path.mnt);
-   if (dentry)
-   *dentry = 

[PATCH 12/13] Use struct path argument in proc_get_link()

2007-10-22 Thread Bharata B Rao
Replace the (vfsmnt, dentry) arguments in proc_inode operation proc_get_link()
by struct path.

Also, this should eventually allow do_proc_readlink() to call d_path() with
a struct path argument.

Signed-off-by: Bharata B Rao [EMAIL PROTECTED]
---
 fs/proc/base.c  |   60 +---
 fs/proc/internal.h  |2 -
 fs/proc/task_mmu.c  |6 ++--
 fs/proc/task_nommu.c|6 ++--
 include/linux/proc_fs.h |2 -
 5 files changed, 35 insertions(+), 41 deletions(-)

--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -153,7 +153,7 @@ static int get_nr_threads(struct task_st
return count;
 }
 
-static int proc_cwd_link(struct inode *inode, struct dentry **dentry, struct 
vfsmount **mnt)
+static int proc_cwd_link(struct inode *inode, struct path *path)
 {
struct task_struct *task = get_proc_task(inode);
struct fs_struct *fs = NULL;
@@ -165,8 +165,8 @@ static int proc_cwd_link(struct inode *i
}
if (fs) {
read_lock(fs-lock);
-   *mnt = mntget(fs-pwd.mnt);
-   *dentry = dget(fs-pwd.dentry);
+   *path = fs-pwd;
+   path_get(path);
read_unlock(fs-lock);
result = 0;
put_fs_struct(fs);
@@ -174,7 +174,7 @@ static int proc_cwd_link(struct inode *i
return result;
 }
 
-static int proc_root_link(struct inode *inode, struct dentry **dentry, struct 
vfsmount **mnt)
+static int proc_root_link(struct inode *inode, struct path *path)
 {
struct task_struct *task = get_proc_task(inode);
struct fs_struct *fs = NULL;
@@ -186,8 +186,8 @@ static int proc_root_link(struct inode *
}
if (fs) {
read_lock(fs-lock);
-   *mnt = mntget(fs-root.mnt);
-   *dentry = dget(fs-root.dentry);
+   *path = fs-root;
+   path_get(path);
read_unlock(fs-lock);
result = 0;
put_fs_struct(fs);
@@ -1039,34 +1039,32 @@ static void *proc_pid_follow_link(struct
if (!proc_fd_access_allowed(inode))
goto out;
 
-   error = PROC_I(inode)-op.proc_get_link(inode, nd-path.dentry,
-   nd-path.mnt);
+   error = PROC_I(inode)-op.proc_get_link(inode, nd-path);
nd-last_type = LAST_BIND;
 out:
return ERR_PTR(error);
 }
 
-static int do_proc_readlink(struct dentry *dentry, struct vfsmount *mnt,
-   char __user *buffer, int buflen)
+static int do_proc_readlink(struct path *path, char __user *buffer, int buflen)
 {
struct inode * inode;
char *tmp = (char*)__get_free_page(GFP_TEMPORARY);
-   char *path;
+   char *pathname;
int len;
 
if (!tmp)
return -ENOMEM;
 
-   inode = dentry-d_inode;
-   path = d_path(dentry, mnt, tmp, PAGE_SIZE);
-   len = PTR_ERR(path);
-   if (IS_ERR(path))
+   inode = path-dentry-d_inode;
+   pathname = d_path(path-dentry, path-mnt, tmp, PAGE_SIZE);
+   len = PTR_ERR(pathname);
+   if (IS_ERR(pathname))
goto out;
-   len = tmp + PAGE_SIZE - 1 - path;
+   len = tmp + PAGE_SIZE - 1 - pathname;
 
if (len  buflen)
len = buflen;
-   if (copy_to_user(buffer, path, len))
+   if (copy_to_user(buffer, pathname, len))
len = -EFAULT;
  out:
free_page((unsigned long)tmp);
@@ -1077,20 +1075,18 @@ static int proc_pid_readlink(struct dent
 {
int error = -EACCES;
struct inode *inode = dentry-d_inode;
-   struct dentry *de;
-   struct vfsmount *mnt = NULL;
+   struct path path;
 
/* Are we allowed to snoop on the tasks file descriptors? */
if (!proc_fd_access_allowed(inode))
goto out;
 
-   error = PROC_I(inode)-op.proc_get_link(inode, de, mnt);
+   error = PROC_I(inode)-op.proc_get_link(inode, path);
if (error)
goto out;
 
-   error = do_proc_readlink(de, mnt, buffer, buflen);
-   dput(de);
-   mntput(mnt);
+   error = do_proc_readlink(path, buffer, buflen);
+   path_put(path);
 out:
return error;
 }
@@ -1317,8 +1313,7 @@ out:
 
 #define PROC_FDINFO_MAX 64
 
-static int proc_fd_info(struct inode *inode, struct dentry **dentry,
-   struct vfsmount **mnt, char *info)
+static int proc_fd_info(struct inode *inode, struct path *path, char *info)
 {
struct task_struct *task = get_proc_task(inode);
struct files_struct *files = NULL;
@@ -1337,10 +1332,10 @@ static int proc_fd_info(struct inode *in
spin_lock(files-file_lock);
file = fcheck_files(files, fd);
if (file) {
-   if (mnt)
-   *mnt = mntget(file-f_path.mnt);
-   if (dentry)
-   *dentry =