diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-04-04 17:03:05 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-04-04 17:03:05 -0400 |
| commit | 7df934526c0b3775613502dcd19ab6d2da8cce1e (patch) | |
| tree | 01e6a4ea20c676228f4acefc6ae776d2e52072db /Documentation/filesystems | |
| parent | 3c83e61e67256e0bb08c46cc2db43b58fd617251 (diff) | |
| parent | bd42998a6bcb9b1708dac9ca9876e3d304c16f3d (diff) | |
Merge branch 'cross-rename' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs
Pull renameat2 system call from Miklos Szeredi:
"This adds a new syscall, renameat2(), which is the same as renameat()
but with a flags argument.
The purpose of extending rename is to add cross-rename, a symmetric
variant of rename, which exchanges the two files. This allows
interesting things, which were not possible before, for example
atomically replacing a directory tree with a symlink, etc... This
also allows overlayfs and friends to operate on whiteouts atomically.
Andy Lutomirski also suggested a "noreplace" flag, which disables the
overwriting behavior of rename.
These two flags, RENAME_EXCHANGE and RENAME_NOREPLACE are only
implemented for ext4 as an example and for testing"
* 'cross-rename' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs:
ext4: add cross rename support
ext4: rename: split out helper functions
ext4: rename: move EMLINK check up
ext4: rename: create ext4_renament structure for local vars
vfs: add cross-rename
vfs: lock_two_nondirectories: allow directory args
security: add flags to rename hooks
vfs: add RENAME_NOREPLACE flag
vfs: add renameat2 syscall
vfs: rename: use common code for dir and non-dir
vfs: rename: move d_move() up
vfs: add d_is_dir()
Diffstat (limited to 'Documentation/filesystems')
| -rw-r--r-- | Documentation/filesystems/Locking | 6 | ||||
| -rw-r--r-- | Documentation/filesystems/vfs.txt | 16 |
2 files changed, 21 insertions, 1 deletions
diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking index 5b0c083d7c0e..f424e0e5b46b 100644 --- a/Documentation/filesystems/Locking +++ b/Documentation/filesystems/Locking | |||
| @@ -47,6 +47,8 @@ prototypes: | |||
| 47 | int (*mknod) (struct inode *,struct dentry *,umode_t,dev_t); | 47 | int (*mknod) (struct inode *,struct dentry *,umode_t,dev_t); |
| 48 | int (*rename) (struct inode *, struct dentry *, | 48 | int (*rename) (struct inode *, struct dentry *, |
| 49 | struct inode *, struct dentry *); | 49 | struct inode *, struct dentry *); |
| 50 | int (*rename2) (struct inode *, struct dentry *, | ||
| 51 | struct inode *, struct dentry *, unsigned int); | ||
| 50 | int (*readlink) (struct dentry *, char __user *,int); | 52 | int (*readlink) (struct dentry *, char __user *,int); |
| 51 | void * (*follow_link) (struct dentry *, struct nameidata *); | 53 | void * (*follow_link) (struct dentry *, struct nameidata *); |
| 52 | void (*put_link) (struct dentry *, struct nameidata *, void *); | 54 | void (*put_link) (struct dentry *, struct nameidata *, void *); |
| @@ -78,6 +80,7 @@ mkdir: yes | |||
| 78 | unlink: yes (both) | 80 | unlink: yes (both) |
| 79 | rmdir: yes (both) (see below) | 81 | rmdir: yes (both) (see below) |
| 80 | rename: yes (all) (see below) | 82 | rename: yes (all) (see below) |
| 83 | rename2: yes (all) (see below) | ||
| 81 | readlink: no | 84 | readlink: no |
| 82 | follow_link: no | 85 | follow_link: no |
| 83 | put_link: no | 86 | put_link: no |
| @@ -96,7 +99,8 @@ tmpfile: no | |||
| 96 | 99 | ||
| 97 | Additionally, ->rmdir(), ->unlink() and ->rename() have ->i_mutex on | 100 | Additionally, ->rmdir(), ->unlink() and ->rename() have ->i_mutex on |
| 98 | victim. | 101 | victim. |
| 99 | cross-directory ->rename() has (per-superblock) ->s_vfs_rename_sem. | 102 | cross-directory ->rename() and rename2() has (per-superblock) |
| 103 | ->s_vfs_rename_sem. | ||
| 100 | 104 | ||
| 101 | See Documentation/filesystems/directory-locking for more detailed discussion | 105 | See Documentation/filesystems/directory-locking for more detailed discussion |
| 102 | of the locking scheme for directory operations. | 106 | of the locking scheme for directory operations. |
diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt index c53784c119c8..94eb86287bcb 100644 --- a/Documentation/filesystems/vfs.txt +++ b/Documentation/filesystems/vfs.txt | |||
| @@ -347,6 +347,8 @@ struct inode_operations { | |||
| 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 *, | 348 | int (*rename) (struct inode *, struct dentry *, |
| 349 | struct inode *, struct dentry *); | 349 | struct inode *, struct dentry *); |
| 350 | int (*rename2) (struct inode *, struct dentry *, | ||
| 351 | struct inode *, struct dentry *, unsigned int); | ||
| 350 | int (*readlink) (struct dentry *, char __user *,int); | 352 | int (*readlink) (struct dentry *, char __user *,int); |
| 351 | void * (*follow_link) (struct dentry *, struct nameidata *); | 353 | void * (*follow_link) (struct dentry *, struct nameidata *); |
| 352 | void (*put_link) (struct dentry *, struct nameidata *, void *); | 354 | void (*put_link) (struct dentry *, struct nameidata *, void *); |
| @@ -414,6 +416,20 @@ otherwise noted. | |||
| 414 | rename: called by the rename(2) system call to rename the object to | 416 | rename: called by the rename(2) system call to rename the object to |
| 415 | have the parent and name given by the second inode and dentry. | 417 | have the parent and name given by the second inode and dentry. |
| 416 | 418 | ||
| 419 | rename2: this has an additional flags argument compared to rename. | ||
| 420 | If no flags are supported by the filesystem then this method | ||
| 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 | ||
| 425 | of the rename exists the rename should fail with -EEXIST | ||
| 426 | instead of replacing the target. The VFS already checks for | ||
| 427 | existence, so for local filesystems the RENAME_NOREPLACE | ||
| 428 | implementation is equivalent to plain rename. | ||
| 429 | (2) RENAME_EXCHANGE: exchange source and target. Both must | ||
| 430 | exist; this is checked by the VFS. Unlike plain rename, | ||
| 431 | source and target may be of different type. | ||
| 432 | |||
| 417 | readlink: called by the readlink(2) system call. Only required if | 433 | readlink: called by the readlink(2) system call. Only required if |
| 418 | you want to support reading symbolic links | 434 | you want to support reading symbolic links |
| 419 | 435 | ||
