From: Bharata B Rao <bharata@linux.vnet.ibm.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Jan Blunck <jblunck@suse.de>,
Andreas Gruenbacher <agruen@suse.de>,
Christoph Hellwig <hch@lst.de>,
viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org
Subject: [PATCH 10/13] Make set_fs_{root,pwd} take a struct path
Date: Mon, 22 Oct 2007 12:32:02 +0530 [thread overview]
Message-ID: <20071022070202.GK6489@in.ibm.com> (raw)
In-Reply-To: <20071022065352.GA6489@in.ibm.com>
From: Jan Blunck <jblunck@suse.de>
In nearly all cases the set_fs_{root,pwd}() calls work on a struct
path. Change the function to reflect this and use path_get() here.
Signed-off-by: Jan Blunck <jblunck@suse.de>
Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
Acked-by: Christoph Hellwig <hch@lst.de>
---
fs/namespace.c | 28 ++++++++++++++--------------
fs/open.c | 12 ++++--------
include/linux/fs_struct.h | 4 ++--
3 files changed, 20 insertions(+), 24 deletions(-)
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -2040,15 +2040,14 @@ out1:
* Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values.
* It can block. Requires the big lock held.
*/
-void set_fs_root(struct fs_struct *fs, struct vfsmount *mnt,
- struct dentry *dentry)
+void set_fs_root(struct fs_struct *fs, struct path *path)
{
struct path old_root;
write_lock(&fs->lock);
old_root = fs->root;
- fs->root.mnt = mntget(mnt);
- fs->root.dentry = dget(dentry);
+ fs->root = *path;
+ path_get(path);
write_unlock(&fs->lock);
if (old_root.dentry)
path_put(&old_root);
@@ -2058,15 +2057,14 @@ void set_fs_root(struct fs_struct *fs, s
* Replace the fs->{pwdmnt,pwd} with {mnt,dentry}. Put the old values.
* It can block. Requires the big lock held.
*/
-void set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt,
- struct dentry *dentry)
+void set_fs_pwd(struct fs_struct *fs, struct path *path)
{
struct path old_pwd;
write_lock(&fs->lock);
old_pwd = fs->pwd;
- fs->pwd.mnt = mntget(mnt);
- fs->pwd.dentry = dget(dentry);
+ fs->pwd = *path;
+ path_get(path);
write_unlock(&fs->lock);
if (old_pwd.dentry)
@@ -2087,12 +2085,10 @@ static void chroot_fs_refs(struct nameid
task_unlock(p);
if (fs->root.dentry == old_nd->path.dentry
&& fs->root.mnt == old_nd->path.mnt)
- set_fs_root(fs, new_nd->path.mnt,
- new_nd->path.dentry);
+ set_fs_root(fs, &new_nd->path);
if (fs->pwd.dentry == old_nd->path.dentry
&& fs->pwd.mnt == old_nd->path.mnt)
- set_fs_pwd(fs, new_nd->path.mnt,
- new_nd->path.dentry);
+ set_fs_pwd(fs, &new_nd->path);
put_fs_struct(fs);
} else
task_unlock(p);
@@ -2235,6 +2231,7 @@ static void __init init_mount_tree(void)
{
struct vfsmount *mnt;
struct mnt_namespace *ns;
+ struct path root;
mnt = do_kern_mount("rootfs", 0, "rootfs", NULL);
if (IS_ERR(mnt))
@@ -2253,8 +2250,11 @@ static void __init init_mount_tree(void)
init_task.nsproxy->mnt_ns = ns;
get_mnt_ns(ns);
- set_fs_pwd(current->fs, ns->root, ns->root->mnt_root);
- set_fs_root(current->fs, ns->root, ns->root->mnt_root);
+ root.mnt = ns->root;
+ root.dentry = ns->root->mnt_root;
+
+ set_fs_pwd(current->fs, &root);
+ set_fs_root(current->fs, &root);
}
void __init mnt_init(void)
--- a/fs/open.c
+++ b/fs/open.c
@@ -501,7 +501,7 @@ asmlinkage long sys_chdir(const char __u
if (error)
goto dput_and_out;
- set_fs_pwd(current->fs, nd.path.mnt, nd.path.dentry);
+ set_fs_pwd(current->fs, &nd.path);
dput_and_out:
path_put(&nd.path);
@@ -512,9 +512,7 @@ out:
asmlinkage long sys_fchdir(unsigned int fd)
{
struct file *file;
- struct dentry *dentry;
struct inode *inode;
- struct vfsmount *mnt;
int error;
error = -EBADF;
@@ -522,9 +520,7 @@ asmlinkage long sys_fchdir(unsigned int
if (!file)
goto out;
- dentry = file->f_path.dentry;
- mnt = file->f_path.mnt;
- inode = dentry->d_inode;
+ inode = file->f_path.dentry->d_inode;
error = -ENOTDIR;
if (!S_ISDIR(inode->i_mode))
@@ -532,7 +528,7 @@ asmlinkage long sys_fchdir(unsigned int
error = file_permission(file, MAY_EXEC);
if (!error)
- set_fs_pwd(current->fs, mnt, dentry);
+ set_fs_pwd(current->fs, &file->f_path);
out_putf:
fput(file);
out:
@@ -556,7 +552,7 @@ asmlinkage long sys_chroot(const char __
if (!capable(CAP_SYS_CHROOT))
goto dput_and_out;
- set_fs_root(current->fs, nd.path.mnt, nd.path.dentry);
+ set_fs_root(current->fs, &nd.path);
set_fs_altroot();
error = 0;
dput_and_out:
--- a/include/linux/fs_struct.h
+++ b/include/linux/fs_struct.h
@@ -20,8 +20,8 @@ extern struct kmem_cache *fs_cachep;
extern void exit_fs(struct task_struct *);
extern void set_fs_altroot(void);
-extern void set_fs_root(struct fs_struct *, struct vfsmount *, struct dentry *);
-extern void set_fs_pwd(struct fs_struct *, struct vfsmount *, struct dentry *);
+extern void set_fs_root(struct fs_struct *, struct path *);
+extern void set_fs_pwd(struct fs_struct *, struct path *);
extern struct fs_struct *copy_fs_struct(struct fs_struct *);
extern void put_fs_struct(struct fs_struct *);
next prev parent reply other threads:[~2007-10-22 7:02 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-22 6:53 [PATCH 00/13] Use struct path in struct nameidata Bharata B Rao
2007-10-22 6:54 ` [PATCH 01/13] Don't touch fs_struct in drivers Bharata B Rao
2007-10-22 6:55 ` [PATCH 02/13] Don't touch fs_struct in usermodehelper Bharata B Rao
2007-10-22 6:56 ` [PATCH 03/13] Remove path_release_on_umount() Bharata B Rao
2007-10-22 6:57 ` [PATCH 04/13] Move struct path into its own header Bharata B Rao
2007-10-22 6:58 ` [PATCH 05/13] Embed a struct path into struct nameidata instead of nd->{dentry,mnt} Bharata B Rao
2007-10-22 6:59 ` [PATCH 06/13] Introduce path_put() Bharata B Rao
2007-10-22 6:59 ` [PATCH 07/13] Use path_put() in a few places instead of {mnt,d}put() Bharata B Rao
2007-10-22 7:00 ` [PATCH 08/13] Introduce path_get() Bharata B Rao
2007-10-22 7:01 ` [PATCH 09/13] Use struct path in fs_struct Bharata B Rao
2007-10-22 7:02 ` Bharata B Rao [this message]
2007-10-22 7:02 ` [PATCH 11/13] Make __d_path() to take a struct path argument Bharata B Rao
2007-10-22 7:03 ` [PATCH 12/13] Use struct path argument in proc_get_link() Bharata B Rao
2007-10-22 7:04 ` [PATCH 13/13] Rename {__}d_path() to {__}print_path() and fix comments Bharata B Rao
2007-10-22 10:14 ` Christoph Hellwig
2007-10-22 22:56 ` Andrew Morton
2007-10-22 13:57 ` [PATCH 00/13] Use struct path in struct nameidata Christoph Hellwig
2007-10-22 22:56 ` Andrew Morton
2007-10-23 8:39 ` Jan Blunck
2007-10-23 2:33 ` Bharata B Rao
2007-10-23 8:43 ` Jan Blunck
2007-10-24 3:31 ` Bharata B Rao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071022070202.GK6489@in.ibm.com \
--to=bharata@linux.vnet.ibm.com \
--cc=agruen@suse.de \
--cc=akpm@linux-foundation.org \
--cc=hch@lst.de \
--cc=jblunck@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.