]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
vfs: add RENAME_WHITEOUT
authorMiklos Szeredi <mszeredi@suse.cz>
Thu, 23 Oct 2014 22:14:37 +0000 (00:14 +0200)
committerMiklos Szeredi <mszeredi@suse.cz>
Thu, 23 Oct 2014 22:14:37 +0000 (00:14 +0200)
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>
fs/namei.c
include/uapi/linux/fs.h

index d20191c0ebf5693a9fc172e9888f71a77f2b6a02..42df664e95e54a2148093c14fe1f1ce43b909f33 100644 (file)
@@ -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)) {
index ca1a11bb4443a7f09c3e4b9228c48a346eadce1c..3735fa0a67840ba1882fd42b343c01550a540944 100644 (file)
@@ -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;