Skip to content

Commit

Permalink
vfs: add RENAME_WHITEOUT
Browse files Browse the repository at this point in the history
This adds a new RENAME_WHITEOUT flag.  This flag makes rename() create a
whiteout of source.  The whiteout creation is atomic relative to the
rename.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
  • Loading branch information
Miklos Szeredi committed Oct 23, 2014
1 parent 787fb6b commit 0d7a855
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -4209,12 +4209,16 @@ SYSCALL_DEFINE5(renameat2, int, olddfd, const char __user *, oldname,
bool should_retry = false;
int error;

if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE))
if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE | RENAME_WHITEOUT))
return -EINVAL;

if ((flags & RENAME_NOREPLACE) && (flags & RENAME_EXCHANGE))
if ((flags & (RENAME_NOREPLACE | RENAME_WHITEOUT)) &&
(flags & RENAME_EXCHANGE))
return -EINVAL;

if ((flags & RENAME_WHITEOUT) && !capable(CAP_MKNOD))
return -EPERM;

retry:
from = user_path_parent(olddfd, oldname, &oldnd, lookup_flags);
if (IS_ERR(from)) {
Expand Down
1 change: 1 addition & 0 deletions include/uapi/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

#define RENAME_NOREPLACE (1 << 0) /* Don't overwrite target */
#define RENAME_EXCHANGE (1 << 1) /* Exchange source and dest */
#define RENAME_WHITEOUT (1 << 2) /* Whiteout source */

struct fstrim_range {
__u64 start;
Expand Down

0 comments on commit 0d7a855

Please sign in to comment.