From: Miklos Szeredi <miklos@szeredi.hu>
To: viro@zeniv.linux.org.uk
Cc: akpm@linux-foundation.org, dave@linux.vnet.ibm.com,
ezk@cs.sunysb.edu, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [patch 07/10] vfs: add path_rename()
Date: Wed, 02 Apr 2008 22:12:54 +0200 [thread overview]
Message-ID: <20080402201330.689695350@szeredi.hu> (raw)
In-Reply-To: <20080402201247.358430231@szeredi.hu>
[-- Attachment #1: path_rename.patch --]
[-- Type: text/plain, Size: 6153 bytes --]
From: Miklos Szeredi <mszeredi@suse.cz>
Introduce path_rename(). Make vfs_rename() static.
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
fs/ecryptfs/inode.c | 13 +++++++------
fs/namei.c | 27 +++++++++++++++++++--------
fs/nfsd/vfs.c | 17 +++++------------
include/linux/fs.h | 2 +-
4 files changed, 32 insertions(+), 27 deletions(-)
Index: vfs-2.6/fs/ecryptfs/inode.c
===================================================================
--- vfs-2.6.orig/fs/ecryptfs/inode.c 2008-04-02 21:36:43.000000000 +0200
+++ vfs-2.6/fs/ecryptfs/inode.c 2008-04-02 21:37:52.000000000 +0200
@@ -559,25 +559,26 @@ ecryptfs_rename(struct inode *old_dir, s
int rc;
struct dentry *lower_old_dentry;
struct dentry *lower_new_dentry;
- struct dentry *lower_old_dir_dentry;
+ struct path lower_old_dir;
struct dentry *lower_new_dir_dentry;
lower_old_dentry = ecryptfs_dentry_to_lower(old_dentry);
lower_new_dentry = ecryptfs_dentry_to_lower(new_dentry);
dget(lower_old_dentry);
dget(lower_new_dentry);
- lower_old_dir_dentry = dget_parent(lower_old_dentry);
+ lower_old_dir.mnt = ecryptfs_dentry_to_lower_mnt(old_dentry);
+ lower_old_dir.dentry = dget_parent(lower_old_dentry);
lower_new_dir_dentry = dget_parent(lower_new_dentry);
- lock_rename(lower_old_dir_dentry, lower_new_dir_dentry);
- rc = vfs_rename(lower_old_dir_dentry->d_inode, lower_old_dentry,
+ lock_rename(lower_old_dir.dentry, lower_new_dir_dentry);
+ rc = path_rename(&lower_old_dir, lower_old_dentry,
lower_new_dir_dentry->d_inode, lower_new_dentry);
if (rc)
goto out_lock;
fsstack_copy_attr_all(new_dir, lower_new_dir_dentry->d_inode, NULL);
if (new_dir != old_dir)
- fsstack_copy_attr_all(old_dir, lower_old_dir_dentry->d_inode, NULL);
+ fsstack_copy_attr_all(old_dir, lower_old_dir.dentry->d_inode, NULL);
out_lock:
- unlock_rename(lower_old_dir_dentry, lower_new_dir_dentry);
+ unlock_rename(lower_old_dir.dentry, lower_new_dir_dentry);
dput(lower_new_dentry->d_parent);
dput(lower_old_dentry->d_parent);
dput(lower_new_dentry);
Index: vfs-2.6/fs/namei.c
===================================================================
--- vfs-2.6.orig/fs/namei.c 2008-04-02 21:36:43.000000000 +0200
+++ vfs-2.6/fs/namei.c 2008-04-02 21:38:45.000000000 +0200
@@ -2723,8 +2723,8 @@ static int vfs_rename_other(struct inode
return error;
}
-int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
- struct inode *new_dir, struct dentry *new_dentry)
+static int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
+ struct inode *new_dir, struct dentry *new_dentry)
{
int error;
int is_dir = S_ISDIR(old_dentry->d_inode->i_mode);
@@ -2766,6 +2766,22 @@ int vfs_rename(struct inode *old_dir, st
return error;
}
+int path_rename(struct path *old_dir_path, struct dentry *old_dentry,
+ struct inode *new_dir, struct dentry *new_dentry)
+{
+ int error = mnt_want_write(old_dir_path->mnt);
+
+ if (!error) {
+ struct inode *old_dir = old_dir_path->dentry->d_inode;
+
+ error = vfs_rename(old_dir, old_dentry, new_dir, new_dentry);
+ mnt_drop_write(old_dir_path->mnt);
+ }
+
+ return error;
+}
+EXPORT_SYMBOL(path_rename);
+
static int do_rename(int olddfd, const char *oldname,
int newdfd, const char *newname)
{
@@ -2827,12 +2843,8 @@ static int do_rename(int olddfd, const c
if (new_dentry == trap)
goto exit5;
- error = mnt_want_write(oldnd.path.mnt);
- if (error)
- goto exit5;
- error = vfs_rename(old_dir->d_inode, old_dentry,
+ error = path_rename(&oldnd.path, old_dentry,
new_dir->d_inode, new_dentry);
- mnt_drop_write(oldnd.path.mnt);
exit5:
dput(new_dentry);
exit4:
@@ -3023,7 +3035,6 @@ EXPORT_SYMBOL(unlock_rename);
EXPORT_SYMBOL(vfs_follow_link);
EXPORT_SYMBOL(generic_permission);
EXPORT_SYMBOL(vfs_readlink);
-EXPORT_SYMBOL(vfs_rename);
EXPORT_SYMBOL(vfs_rmdir);
EXPORT_SYMBOL(dentry_unhash);
EXPORT_SYMBOL(generic_readlink);
Index: vfs-2.6/fs/nfsd/vfs.c
===================================================================
--- vfs-2.6.orig/fs/nfsd/vfs.c 2008-04-02 21:36:43.000000000 +0200
+++ vfs-2.6/fs/nfsd/vfs.c 2008-04-02 21:37:52.000000000 +0200
@@ -1633,8 +1633,9 @@ __be32
nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
struct svc_fh *tfhp, char *tname, int tlen)
{
+ struct path old_dir_path;
struct dentry *fdentry, *tdentry, *odentry, *ndentry, *trap;
- struct inode *fdir, *tdir;
+ struct inode *tdir;
__be32 err;
int host_err;
@@ -1646,7 +1647,6 @@ nfsd_rename(struct svc_rqst *rqstp, stru
goto out;
fdentry = ffhp->fh_dentry;
- fdir = fdentry->d_inode;
tdentry = tfhp->fh_dentry;
tdir = tdentry->d_inode;
@@ -1693,22 +1693,15 @@ nfsd_rename(struct svc_rqst *rqstp, stru
goto out_dput_new;
}
- host_err = -EXDEV;
- if (ffhp->fh_export->ex_path.mnt != tfhp->fh_export->ex_path.mnt)
- goto out_dput_new;
- host_err = mnt_want_write(ffhp->fh_export->ex_path.mnt);
- if (host_err)
- goto out_dput_new;
-
- host_err = vfs_rename(fdir, odentry, tdir, ndentry);
+ old_dir_path.mnt = ffhp->fh_export->ex_path.mnt;
+ old_dir_path.dentry = fdentry;
+ host_err = path_rename(&old_dir_path, odentry, tdir, ndentry);
if (!host_err && EX_ISSYNC(tfhp->fh_export)) {
host_err = nfsd_sync_dir(tdentry);
if (!host_err)
host_err = nfsd_sync_dir(fdentry);
}
- mnt_drop_write(ffhp->fh_export->ex_path.mnt);
-
out_dput_new:
dput(ndentry);
out_dput_old:
Index: vfs-2.6/include/linux/fs.h
===================================================================
--- vfs-2.6.orig/include/linux/fs.h 2008-04-02 21:36:43.000000000 +0200
+++ vfs-2.6/include/linux/fs.h 2008-04-02 21:37:52.000000000 +0200
@@ -1132,7 +1132,7 @@ extern int path_link(struct dentry *, st
extern int vfs_rmdir(struct inode *, struct dentry *);
extern int path_rmdir(struct path *, struct dentry *);
extern int path_unlink(struct path *, struct dentry *);
-extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
+extern int path_rename(struct path *, struct dentry *, struct inode *, struct dentry *);
/*
* VFS dentry helper functions.
--
next prev parent reply other threads:[~2008-04-02 20:16 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-02 20:12 [patch 00/10] vfs: add helpers to check r/o bind mounts Miklos Szeredi
2008-04-02 20:12 ` [patch 01/10] vfs: add path_create() and path_mknod() Miklos Szeredi
2008-04-02 20:54 ` Al Viro
2008-04-02 21:11 ` Miklos Szeredi
2008-04-02 21:48 ` Al Viro
2008-04-02 22:21 ` Trond Myklebust
2008-04-02 22:36 ` Al Viro
2008-04-02 23:19 ` Trond Myklebust
2008-04-02 23:40 ` Al Viro
2008-04-02 23:47 ` Al Viro
2008-04-03 0:42 ` Trond Myklebust
2008-04-03 0:47 ` Erez Zadok
2008-04-03 1:00 ` Al Viro
2008-04-03 1:37 ` Erez Zadok
2008-04-03 1:46 ` Al Viro
2008-04-03 2:21 ` Erez Zadok
2008-04-03 2:32 ` Al Viro
2008-04-03 23:24 ` Erez Zadok
2008-04-04 11:04 ` Miklos Szeredi
2008-04-03 0:58 ` Al Viro
2008-04-03 7:32 ` Miklos Szeredi
2008-04-03 22:32 ` Erez Zadok
2008-04-03 12:33 ` Stephen Smalley
2008-04-02 21:00 ` Dave Hansen
2008-04-02 21:19 ` Dave Hansen
2008-04-02 20:12 ` [patch 02/10] vfs: add path_mkdir() Miklos Szeredi
2008-04-02 22:15 ` Erez Zadok
2008-04-02 20:12 ` [patch 03/10] vfs: add path_rmdir() Miklos Szeredi
2008-04-02 20:12 ` [patch 04/10] vfs: add path_unlink() Miklos Szeredi
2008-04-02 20:12 ` [patch 05/10] vfs: add path_symlink() Miklos Szeredi
2008-04-02 20:12 ` [patch 06/10] vfs: add path_link() Miklos Szeredi
2008-04-02 20:12 ` Miklos Szeredi [this message]
2008-04-04 17:56 ` [patch 07/10] vfs: add path_rename() Erez Zadok
2008-04-04 18:04 ` Miklos Szeredi
2008-04-02 20:12 ` [patch 08/10] vfs: add path_setattr() Miklos Szeredi
2008-04-02 20:12 ` [patch 09/10] vfs: add path_setxattr() Miklos Szeredi
2008-04-02 20:12 ` [patch 10/10] vfs: add path_removexattr() Miklos Szeredi
2008-04-02 21:22 ` [patch 00/10] vfs: add helpers to check r/o bind mounts Erez Zadok
2008-04-09 0:53 ` [PATCH] Unionfs: use the new path_* VFS helpers Erez Zadok
2008-04-10 11:10 ` Miklos Szeredi
2008-04-10 12:02 ` [PATCH] Call LSM functions outside VFS helper functions Tetsuo Handa
2008-04-10 12:17 ` Matthew Wilcox
2008-04-10 12:56 ` Miklos Szeredi
2008-05-05 10:16 [patch 00/10] vfs: add helpers to check r/o bind mounts v3 Miklos Szeredi
2008-05-05 10:16 ` [patch 07/10] vfs: add path_rename() Miklos Szeredi
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=20080402201330.689695350@szeredi.hu \
--to=miklos@szeredi.hu \
--cc=akpm@linux-foundation.org \
--cc=dave@linux.vnet.ibm.com \
--cc=ezk@cs.sunysb.edu \
--cc=linux-fsdevel@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®