]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
generic: Add rudimetary RENAME_WHITEOUT test
authorDave Chinner <dchinner@redhat.com>
Wed, 18 Mar 2015 03:55:21 +0000 (14:55 +1100)
committerDave Chinner <david@fromorbit.com>
Wed, 18 Mar 2015 03:55:21 +0000 (14:55 +1100)
There is no API documentation for RENAME_WHITEOUT. There is no
developer documentation for RENAME_WHITEOUT. There are not comments
in the overlayfs or ext4 implementation of RENAME_WHITEOUT.

Hence, this test simply tries to expose basic RENAME_WHITEOUT
behaviour from ext4 so we can reverse-engineer and verify
bug-for-bug renameat2(RENAME_WHITEOUT) ext4 compatibility.

Note: uses generic/078 just to keep out of the way of the 6-7 other
pending new tests.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
src/renameat2.c
tests/generic/078 [new file with mode: 0755]
tests/generic/078.out [new file with mode: 0644]
tests/generic/group

index 5ac093628d7178ab0f1bdcd7c09872d2f51b9ee5..c59ce65fc26024e41e57b2098fb52a2af7fdab47 100644 (file)
@@ -96,9 +96,9 @@ int main(int argc, char *argv[])
                 * Turn EEXIST into ENOTEMPTY.  E.g. XFS uses EEXIST, and that
                 * is also accepted by the standards.
                 *
-                * This applies only to plain rename (flags == 0).
+                * This applies only to plain rename and RENAME_WHITEOUT
                 */
-               if (!flags && errno == EEXIST)
+               if (errno == EEXIST && (!flags || (flags & RENAME_WHITEOUT)))
                        errno = ENOTEMPTY;
 
                perror("");
diff --git a/tests/generic/078 b/tests/generic/078
new file mode 100755 (executable)
index 0000000..92ece0c
--- /dev/null
@@ -0,0 +1,66 @@
+#! /bin/bash
+# FS QA Test No. generic/078
+#
+# Check renameat2 syscall with RENAME_WHITEOUT flag
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2014 Miklos Szeredi.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1       # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/renameat2
+
+_supported_fs generic
+_supported_os Linux
+
+_require_test
+_requires_renameat2
+_require_test_symlinks
+
+rename_dir=$TEST_DIR/$$
+mkdir $rename_dir
+touch $rename_dir/foo $rename_dir/bar
+if ! src/renameat2 -t -w $rename_dir/foo $rename_dir/bar; then
+    rm -f $rename_dir/foo $rename_dir/bar; rmdir $rename_dir
+    _notrun "fs doesn't support RENAME_WHITEOUT"
+fi
+rm -f $rename_dir/foo $rename_dir/bar
+
+# real QA test starts here
+
+_rename_tests $rename_dir -w
+rmdir $rename_dir
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/078.out b/tests/generic/078.out
new file mode 100644 (file)
index 0000000..5d5e3a0
--- /dev/null
@@ -0,0 +1,51 @@
+QA output created by 078
+samedir  none/none -> No such file or directory
+samedir  none/regu -> No such file or directory
+samedir  none/symb -> No such file or directory
+samedir  none/dire -> No such file or directory
+samedir  none/tree -> No such file or directory
+samedir  regu/none -> char/regu.
+samedir  regu/regu -> char/regu.
+samedir  regu/symb -> char/regu.
+samedir  regu/dire -> Is a directory
+samedir  regu/tree -> Is a directory
+samedir  symb/none -> char/symb.
+samedir  symb/regu -> char/symb.
+samedir  symb/symb -> char/symb.
+samedir  symb/dire -> Is a directory
+samedir  symb/tree -> Is a directory
+samedir  dire/none -> char/dire.
+samedir  dire/regu -> Not a directory
+samedir  dire/symb -> Not a directory
+samedir  dire/dire -> char/dire.
+samedir  dire/tree -> Directory not empty
+samedir  tree/none -> char/tree.
+samedir  tree/regu -> Not a directory
+samedir  tree/symb -> Not a directory
+samedir  tree/dire -> char/tree.
+samedir  tree/tree -> Directory not empty
+crossdir none/none -> No such file or directory
+crossdir none/regu -> No such file or directory
+crossdir none/symb -> No such file or directory
+crossdir none/dire -> No such file or directory
+crossdir none/tree -> No such file or directory
+crossdir regu/none -> char/regu.
+crossdir regu/regu -> char/regu.
+crossdir regu/symb -> char/regu.
+crossdir regu/dire -> Is a directory
+crossdir regu/tree -> Is a directory
+crossdir symb/none -> char/symb.
+crossdir symb/regu -> char/symb.
+crossdir symb/symb -> char/symb.
+crossdir symb/dire -> Is a directory
+crossdir symb/tree -> Is a directory
+crossdir dire/none -> char/dire.
+crossdir dire/regu -> Not a directory
+crossdir dire/symb -> Not a directory
+crossdir dire/dire -> char/dire.
+crossdir dire/tree -> Directory not empty
+crossdir tree/none -> char/tree.
+crossdir tree/regu -> Not a directory
+crossdir tree/symb -> Not a directory
+crossdir tree/dire -> char/tree.
+crossdir tree/tree -> Directory not empty
index e5db7729409fdf40444b43c4077a6dfccd825791..9b1464651f5cefae75ba0d13faaf5bac39a82613 100644 (file)
@@ -76,6 +76,7 @@
 075 rw udf auto quick
 076 metadata rw udf auto quick stress
 077 acl attr auto enospc
+078 auto quick metadata
 079 acl attr ioctl metadata auto quick
 083 rw auto enospc stress
 088 perms auto quick