summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/filesystems/Locking6
-rw-r--r--Documentation/filesystems/directory-locking2
-rw-r--r--Documentation/filesystems/vfs.txt9
-rw-r--r--fs/cachefiles/namei.c3
-rw-r--r--fs/namei.c15
-rw-r--r--include/linux/fs.h2
-rw-r--r--security/tomoyo/realpath.c4
7 files changed, 10 insertions, 31 deletions
diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking
index d30fb2cb5066..da320bc08b9e 100644
--- a/Documentation/filesystems/Locking
+++ b/Documentation/filesystems/Locking
@@ -50,8 +50,6 @@ prototypes:
50 int (*mkdir) (struct inode *,struct dentry *,umode_t); 50 int (*mkdir) (struct inode *,struct dentry *,umode_t);
51 int (*rmdir) (struct inode *,struct dentry *); 51 int (*rmdir) (struct inode *,struct dentry *);
52 int (*mknod) (struct inode *,struct dentry *,umode_t,dev_t); 52 int (*mknod) (struct inode *,struct dentry *,umode_t,dev_t);
53 int (*rename) (struct inode *, struct dentry *,
54 struct inode *, struct dentry *);
55 int (*rename2) (struct inode *, struct dentry *, 53 int (*rename2) (struct inode *, struct dentry *,
56 struct inode *, struct dentry *, unsigned int); 54 struct inode *, struct dentry *, unsigned int);
57 int (*readlink) (struct dentry *, char __user *,int); 55 int (*readlink) (struct dentry *, char __user *,int);
@@ -83,7 +81,6 @@ symlink: yes
83mkdir: yes 81mkdir: yes
84unlink: yes (both) 82unlink: yes (both)
85rmdir: yes (both) (see below) 83rmdir: yes (both) (see below)
86rename: yes (all) (see below)
87rename2: yes (all) (see below) 84rename2: yes (all) (see below)
88readlink: no 85readlink: no
89get_link: no 86get_link: no
@@ -102,8 +99,7 @@ tmpfile: no
102 99
103 Additionally, ->rmdir(), ->unlink() and ->rename() have ->i_mutex on 100 Additionally, ->rmdir(), ->unlink() and ->rename() have ->i_mutex on
104victim. 101victim.
105 cross-directory ->rename() and rename2() has (per-superblock) 102 cross-directory ->rename2() has (per-superblock) ->s_vfs_rename_sem.
106->s_vfs_rename_sem.
107 103
108See Documentation/filesystems/directory-locking for more detailed discussion 104See Documentation/filesystems/directory-locking for more detailed discussion
109of the locking scheme for directory operations. 105of the locking scheme for directory operations.
diff --git a/Documentation/filesystems/directory-locking b/Documentation/filesystems/directory-locking
index c314badbcfc6..4e32cb961e5b 100644
--- a/Documentation/filesystems/directory-locking
+++ b/Documentation/filesystems/directory-locking
@@ -19,7 +19,7 @@ locks victim and calls the method. Locks are exclusive.
19 19
204) rename() that is _not_ cross-directory. Locking rules: caller locks 204) rename() that is _not_ cross-directory. Locking rules: caller locks
21the parent and finds source and target. In case of exchange (with 21the parent and finds source and target. In case of exchange (with
22RENAME_EXCHANGE in rename2() flags argument) lock both. In any case, 22RENAME_EXCHANGE in flags argument) lock both. In any case,
23if the target already exists, lock it. If the source is a non-directory, 23if the target already exists, lock it. If the source is a non-directory,
24lock it. If we need to lock both, lock them in inode pointer order. 24lock it. If we need to lock both, lock them in inode pointer order.
25Then call the method. All locks are exclusive. 25Then call the method. All locks are exclusive.
diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt
index 9ace359d6cc5..c641e0c37a07 100644
--- a/Documentation/filesystems/vfs.txt
+++ b/Documentation/filesystems/vfs.txt
@@ -345,8 +345,6 @@ struct inode_operations {
345 int (*mkdir) (struct inode *,struct dentry *,umode_t); 345 int (*mkdir) (struct inode *,struct dentry *,umode_t);
346 int (*rmdir) (struct inode *,struct dentry *); 346 int (*rmdir) (struct inode *,struct dentry *);
347 int (*mknod) (struct inode *,struct dentry *,umode_t,dev_t); 347 int (*mknod) (struct inode *,struct dentry *,umode_t,dev_t);
348 int (*rename) (struct inode *, struct dentry *,
349 struct inode *, struct dentry *);
350 int (*rename2) (struct inode *, struct dentry *, 348 int (*rename2) (struct inode *, struct dentry *,
351 struct inode *, struct dentry *, unsigned int); 349 struct inode *, struct dentry *, unsigned int);
352 int (*readlink) (struct dentry *, char __user *,int); 350 int (*readlink) (struct dentry *, char __user *,int);
@@ -416,11 +414,8 @@ otherwise noted.
416 rename: called by the rename(2) system call to rename the object to 414 rename: called by the rename(2) system call to rename the object to
417 have the parent and name given by the second inode and dentry. 415 have the parent and name given by the second inode and dentry.
418 416
419 rename2: this has an additional flags argument compared to rename. 417 The filesystem must return -EINVAL for any unsupported or
420 If no flags are supported by the filesystem then this method 418 unknown flags. Currently the following flags are implemented:
421 need not be implemented. If some flags are supported then the
422 filesystem must return -EINVAL for any unsupported or unknown
423 flags. Currently the following flags are implemented:
424 (1) RENAME_NOREPLACE: this flag indicates that if the target 419 (1) RENAME_NOREPLACE: this flag indicates that if the target
425 of the rename exists the rename should fail with -EEXIST 420 of the rename exists the rename should fail with -EEXIST
426 instead of replacing the target. The VFS already checks for 421 instead of replacing the target. The VFS already checks for
diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
index 3f7c2cd41f8f..02e1507812de 100644
--- a/fs/cachefiles/namei.c
+++ b/fs/cachefiles/namei.c
@@ -804,8 +804,7 @@ struct dentry *cachefiles_get_directory(struct cachefiles_cache *cache,
804 !d_backing_inode(subdir)->i_op->lookup || 804 !d_backing_inode(subdir)->i_op->lookup ||
805 !d_backing_inode(subdir)->i_op->mkdir || 805 !d_backing_inode(subdir)->i_op->mkdir ||
806 !d_backing_inode(subdir)->i_op->create || 806 !d_backing_inode(subdir)->i_op->create ||
807 (!d_backing_inode(subdir)->i_op->rename && 807 !d_backing_inode(subdir)->i_op->rename2 ||
808 !d_backing_inode(subdir)->i_op->rename2) ||
809 !d_backing_inode(subdir)->i_op->rmdir || 808 !d_backing_inode(subdir)->i_op->rmdir ||
810 !d_backing_inode(subdir)->i_op->unlink) 809 !d_backing_inode(subdir)->i_op->unlink)
811 goto check_error; 810 goto check_error;
diff --git a/fs/namei.c b/fs/namei.c
index adb04146df09..02803bd6cbad 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -4369,12 +4369,9 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
4369 if (error) 4369 if (error)
4370 return error; 4370 return error;
4371 4371
4372 if (!old_dir->i_op->rename && !old_dir->i_op->rename2) 4372 if (!old_dir->i_op->rename2)
4373 return -EPERM; 4373 return -EPERM;
4374 4374
4375 if (flags && !old_dir->i_op->rename2)
4376 return -EINVAL;
4377
4378 /* 4375 /*
4379 * If we are going to change the parent - check write permissions, 4376 * If we are going to change the parent - check write permissions,
4380 * we'll need to flip '..'. 4377 * we'll need to flip '..'.
@@ -4428,14 +4425,8 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
4428 if (error) 4425 if (error)
4429 goto out; 4426 goto out;
4430 } 4427 }
4431 if (!old_dir->i_op->rename2) { 4428 error = old_dir->i_op->rename2(old_dir, old_dentry,
4432 error = old_dir->i_op->rename(old_dir, old_dentry, 4429 new_dir, new_dentry, flags);
4433 new_dir, new_dentry);
4434 } else {
4435 WARN_ON(old_dir->i_op->rename != NULL);
4436 error = old_dir->i_op->rename2(old_dir, old_dentry,
4437 new_dir, new_dentry, flags);
4438 }
4439 if (error) 4430 if (error)
4440 goto out; 4431 goto out;
4441 4432
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 2bd67545fdf8..6b14ceba4f20 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1732,8 +1732,6 @@ struct inode_operations {
1732 int (*mkdir) (struct inode *,struct dentry *,umode_t); 1732 int (*mkdir) (struct inode *,struct dentry *,umode_t);
1733 int (*rmdir) (struct inode *,struct dentry *); 1733 int (*rmdir) (struct inode *,struct dentry *);
1734 int (*mknod) (struct inode *,struct dentry *,umode_t,dev_t); 1734 int (*mknod) (struct inode *,struct dentry *,umode_t,dev_t);
1735 int (*rename) (struct inode *, struct dentry *,
1736 struct inode *, struct dentry *);
1737 int (*rename2) (struct inode *, struct dentry *, 1735 int (*rename2) (struct inode *, struct dentry *,
1738 struct inode *, struct dentry *, unsigned int); 1736 struct inode *, struct dentry *, unsigned int);
1739 int (*setattr) (struct dentry *, struct iattr *); 1737 int (*setattr) (struct dentry *, struct iattr *);
diff --git a/security/tomoyo/realpath.c b/security/tomoyo/realpath.c
index 5077f1968841..38bcdbc06bb2 100644
--- a/security/tomoyo/realpath.c
+++ b/security/tomoyo/realpath.c
@@ -173,7 +173,7 @@ static char *tomoyo_get_local_path(struct dentry *dentry, char * const buffer,
173 * Use filesystem name if filesystem does not support rename() 173 * Use filesystem name if filesystem does not support rename()
174 * operation. 174 * operation.
175 */ 175 */
176 if (!inode->i_op->rename && !inode->i_op->rename2) 176 if (!inode->i_op->rename2)
177 goto prepend_filesystem_name; 177 goto prepend_filesystem_name;
178 } 178 }
179 /* Prepend device name. */ 179 /* Prepend device name. */
@@ -283,7 +283,7 @@ char *tomoyo_realpath_from_path(const struct path *path)
283 * or dentry without vfsmount. 283 * or dentry without vfsmount.
284 */ 284 */
285 if (!path->mnt || 285 if (!path->mnt ||
286 (!inode->i_op->rename && !inode->i_op->rename2)) 286 (!inode->i_op->rename2))
287 pos = tomoyo_get_local_path(path->dentry, buf, 287 pos = tomoyo_get_local_path(path->dentry, buf,
288 buf_len - 1); 288 buf_len - 1);
289 /* Get absolute name for the rest. */ 289 /* Get absolute name for the rest. */