All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] renameat2 syscall: add infrastructure
@ 2014-04-11 15:51 Miklos Szeredi
  2014-04-11 15:51 ` [PATCH 2/4] renameat2 syscall: check plain rename Miklos Szeredi
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Miklos Szeredi @ 2014-04-11 15:51 UTC (permalink / raw)
  To: xfs; +Cc: Miklos Szeredi

From: Miklos Szeredi <mszeredi@suse.cz>

The renameat2() syscall was merged into 3.15-rc (merge commit: 7df934526c0b).

This adds the shared infrastructure for the actual test scripts.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
 .gitignore       |   1 +
 common/renameat2 | 129 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 configure.ac     |   2 +
 src/Makefile     |   3 +-
 src/renameat2.c  | 102 +++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 236 insertions(+), 1 deletion(-)
 create mode 100644 common/renameat2
 create mode 100644 src/renameat2.c

diff --git a/.gitignore b/.gitignore
index e8c5012..66e6ee8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -106,6 +106,7 @@
 /src/aio-dio-regress/aio-io-setup-with-nonwritable-context-pointer
 /src/aio-dio-regress/aiodio_sparse2
 /src/cloner
+/src/renameat2
 
 # dmapi/ binaries
 /dmapi/src/common/cmd/read_invis
diff --git a/common/renameat2 b/common/renameat2
new file mode 100644
index 0000000..a335169
--- /dev/null
+++ b/common/renameat2
@@ -0,0 +1,129 @@
+######
+#
+# renameat2 helpers
+#
+#-----------------------------------------------------------------------
+# 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
+#-----------------------------------------------------------------------
+#
+
+#
+# Setup source or dest
+#
+_setup_one()
+{
+	local path=$1
+	local type=$2
+
+	case $type in
+		none)	;;
+		regu)	echo foo > $path;;
+		symb)	ln -s foo $path;;
+		dire)	mkdir $path;;
+		tree)	mkdir $path; echo foo > $path/bar;;
+	esac
+}
+
+#
+# Cleanup source or dest
+#
+_cleanup_one()
+{
+	local path=$1
+
+	if test -d $path; then
+		rm -f $path/bar
+		rmdir $path
+	else
+		rm -f $path
+	fi
+}
+
+#
+# Check type of source or destination
+#
+_showtype_one()
+{
+	local path=$1
+
+	if test -e $path -o -h $path; then
+		if test -d $path -a -e $path/bar; then
+			echo -n "tree"
+		else
+			echo -n `stat -c %F $path | cut -b-4`
+		fi
+	else
+		echo -n "none"
+	fi
+}
+
+#
+# This runs renameat2 on all combinations of source and dest
+#
+_rename_tests_source_dest()
+{
+	local source=$1
+	local dest=$2
+	local options=$3
+
+	for stype in none regu symb dire tree; do
+		for dtype in none regu symb dire tree; do
+			echo -n "$options $stype/$dtype -> "
+			_setup_one $source $stype
+			_setup_one $dest $dtype
+			src/renameat2 $source $dest $flags
+			if test $? == 0; then
+				_showtype_one $source
+				echo -n "/"
+				_showtype_one $dest
+				echo "."
+			fi
+			_cleanup_one $source
+			_cleanup_one $dest
+		done
+	done
+}
+
+#
+# This runs _rename_tests_source_dest() for both same-directory and
+# cross-directory renames
+#
+_rename_tests()
+{
+	local testdir=$1
+	local flags=$2
+
+	#same directory renames
+	_rename_tests_source_dest $testdir/src $testdir/dst     "samedir "
+
+	#cross directory renames
+	mkdir $testdir/x $testdir/y
+	_rename_tests_source_dest $testdir/x/src $testdir/y/dst "crossdir"
+	rmdir $testdir/x $testdir/y
+}
+
+#
+# This checks whether the renameat2 syscall is supported
+#
+_requires_renameat2()
+{
+	if test ! -x src/renameat2; then
+		_notrun "renameat2 binary not found"
+	fi
+	if ! src/renameat2 -t; then
+		_notrun "kernel doesn't support renameat2 syscall"
+	fi
+}
diff --git a/configure.ac b/configure.ac
index 2f95c4c..43e6029 100644
--- a/configure.ac
+++ b/configure.ac
@@ -76,6 +76,8 @@ in
 		;;
 esac
 
+AC_CHECK_FUNCS([renameat2])
+
 AC_CONFIG_HEADER(include/config.h)
 AC_CONFIG_FILES([include/builddefs])
 AC_OUTPUT
diff --git a/src/Makefile b/src/Makefile
index 2dbc696..d754048 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -18,7 +18,8 @@ LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \
 	locktest unwritten_mmap bulkstat_unlink_test t_stripealign \
 	bulkstat_unlink_test_modified t_dir_offset t_futimens t_immutable \
 	stale_handle pwrite_mmap_blocked t_dir_offset2 seek_sanity_test \
-	seek_copy_test t_readdir_1 t_readdir_2 fsync-tester nsexec cloner
+	seek_copy_test t_readdir_1 t_readdir_2 fsync-tester nsexec cloner \
+	renameat2
 
 SUBDIRS =
 
diff --git a/src/renameat2.c b/src/renameat2.c
new file mode 100644
index 0000000..5145959
--- /dev/null
+++ b/src/renameat2.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2014, Miklos Szeredi <mszeredi@suse.cz>
+ * This file is published under GPL2+.
+ *
+ * This is a trivial wrapper around the renameat2 syscall.
+ */
+
+#include "global.h"
+
+#ifndef HAVE_RENAMEAT2
+#include <sys/syscall.h>
+
+#if !defined(SYS_renameat2) && defined(__x86_64__)
+#define SYS_renameat2 316
+#endif
+
+static int renameat2(int dfd1, const char *path1,
+		     int dfd2, const char *path2,
+		     unsigned int flags)
+{
+#ifdef SYS_renameat2
+	return syscall(SYS_renameat2, dfd1, path1, dfd2, path2, flags);
+#else
+	errno = ENOSYS;
+	return -1;
+#endif
+}
+#endif
+
+#ifndef RENAME_NOREPLACE
+#define RENAME_NOREPLACE	(1 << 0)	/* Don't overwrite target */
+#endif
+#ifndef RENAME_EXCHANGE
+#define RENAME_EXCHANGE		(1 << 1)	/* Exchange source and dest */
+#endif
+#ifndef RENAME_WHITEOUT
+#define RENAME_WHITEOUT		(1 << 2)	/* Whiteout source */
+#endif
+
+int main(int argc, char *argv[])
+{
+	int ret;
+	int c;
+	const char *path1 = NULL;
+	const char *path2 = NULL;
+	unsigned int flags = 0;
+	int test = 0;
+
+	for (c = 1; c < argc; c++) {
+		if (argv[c][0] == '-') {
+			switch (argv[c][1]) {
+			case 't':
+				test = 1;
+				break;
+			case 'n':
+				flags |= RENAME_NOREPLACE;
+				break;
+			case 'x':
+				flags |= RENAME_EXCHANGE;
+				break;
+			case 'w':
+				flags |= RENAME_WHITEOUT;
+				break;
+			default:
+				goto usage;
+			}
+		} else if (!path1) {
+			path1 = argv[c];
+		} else if (!path2) {
+			path2 = argv[c];
+		} else {
+			goto usage;
+		}
+	}
+
+	if (!test && (!path1 || !path2))
+		goto usage;
+
+	ret = renameat2(AT_FDCWD, path1, AT_FDCWD, path2, flags);
+	if (ret == -1) {
+		if (test) {
+			if (errno == ENOSYS || errno == EINVAL)
+				return 1;
+			else
+				return 0;
+		}
+		perror("");
+		return 1;
+	}
+
+	return 0;
+
+usage:
+	fprintf(stderr,
+		"usage: %s [-t] [-n|-x|-w] path1 path2\n"
+		"  -t  test\n"
+		"  -n  noreplace\n"
+		"  -x  exchange\n"
+		"  -w  whiteout\n", argv[0]);
+
+	return 1;
+}
-- 
1.8.1.4

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/4] renameat2 syscall: check plain rename
  2014-04-11 15:51 [PATCH 1/4] renameat2 syscall: add infrastructure Miklos Szeredi
@ 2014-04-11 15:51 ` Miklos Szeredi
  2014-04-14  2:30   ` Dave Chinner
  2014-04-11 15:51 ` [PATCH 3/4] renameat2 syscall: check noreplace rename Miklos Szeredi
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Miklos Szeredi @ 2014-04-11 15:51 UTC (permalink / raw)
  To: xfs; +Cc: Miklos Szeredi

From: Miklos Szeredi <mszeredi@suse.cz>

Check with zero flags.  This is what rename(2) and renameat(2) now call, so
this actually tests the behavior of these syscalls as well.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
 tests/generic/323     | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/323.out | 51 +++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/group   |  1 +
 3 files changed, 109 insertions(+)
 create mode 100755 tests/generic/323
 create mode 100644 tests/generic/323.out

diff --git a/tests/generic/323 b/tests/generic/323
new file mode 100755
index 0000000..84772bb
--- /dev/null
+++ b/tests/generic/323
@@ -0,0 +1,57 @@
+#! /bin/bash
+# FS QA Test No. generic/323
+#
+# Check renameat2 syscall without flags
+#
+#-----------------------------------------------------------------------
+# 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
+
+_requires_renameat2
+
+# real QA test starts here
+
+rename_dir=$TEST_DIR/$$
+mkdir -p $rename_dir
+_rename_tests $rename_dir
+rmdir $rename_dir
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/323.out b/tests/generic/323.out
new file mode 100644
index 0000000..bb85b9a
--- /dev/null
+++ b/tests/generic/323.out
@@ -0,0 +1,51 @@
+QA output created by 323
+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 -> none/regu.
+samedir  regu/regu -> none/regu.
+samedir  regu/symb -> none/regu.
+samedir  regu/dire -> Is a directory
+samedir  regu/tree -> Is a directory
+samedir  symb/none -> none/symb.
+samedir  symb/regu -> none/symb.
+samedir  symb/symb -> none/symb.
+samedir  symb/dire -> Is a directory
+samedir  symb/tree -> Is a directory
+samedir  dire/none -> none/dire.
+samedir  dire/regu -> Not a directory
+samedir  dire/symb -> Not a directory
+samedir  dire/dire -> none/dire.
+samedir  dire/tree -> Directory not empty
+samedir  tree/none -> none/tree.
+samedir  tree/regu -> Not a directory
+samedir  tree/symb -> Not a directory
+samedir  tree/dire -> none/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 -> none/regu.
+crossdir regu/regu -> none/regu.
+crossdir regu/symb -> none/regu.
+crossdir regu/dire -> Is a directory
+crossdir regu/tree -> Is a directory
+crossdir symb/none -> none/symb.
+crossdir symb/regu -> none/symb.
+crossdir symb/symb -> none/symb.
+crossdir symb/dire -> Is a directory
+crossdir symb/tree -> Is a directory
+crossdir dire/none -> none/dire.
+crossdir dire/regu -> Not a directory
+crossdir dire/symb -> Not a directory
+crossdir dire/dire -> none/dire.
+crossdir dire/tree -> Directory not empty
+crossdir tree/none -> none/tree.
+crossdir tree/regu -> Not a directory
+crossdir tree/symb -> Not a directory
+crossdir tree/dire -> none/tree.
+crossdir tree/tree -> Directory not empty
diff --git a/tests/generic/group b/tests/generic/group
index 1c1693d..26e584b 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -136,3 +136,4 @@
 320 auto rw
 321 auto quick metadata log
 322 auto quick metadata log
+323 auto quick
-- 
1.8.1.4

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/4] renameat2 syscall: check noreplace rename
  2014-04-11 15:51 [PATCH 1/4] renameat2 syscall: add infrastructure Miklos Szeredi
  2014-04-11 15:51 ` [PATCH 2/4] renameat2 syscall: check plain rename Miklos Szeredi
@ 2014-04-11 15:51 ` Miklos Szeredi
  2014-04-11 15:51 ` [PATCH 4/4] renameat2 syscall: check cross rename Miklos Szeredi
  2014-04-11 23:23 ` [PATCH 1/4] renameat2 syscall: add infrastructure Dave Chinner
  3 siblings, 0 replies; 8+ messages in thread
From: Miklos Szeredi @ 2014-04-11 15:51 UTC (permalink / raw)
  To: xfs; +Cc: Miklos Szeredi

From: Miklos Szeredi <mszeredi@suse.cz>

Check with RENAME_NOREPLACE flag.  This flag indicates that the rename must
fail if the target of the rename exists.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
 tests/generic/324     | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/324.out | 51 ++++++++++++++++++++++++++++++++++++++++
 tests/generic/group   |  1 +
 3 files changed, 116 insertions(+)
 create mode 100755 tests/generic/324
 create mode 100644 tests/generic/324.out

diff --git a/tests/generic/324 b/tests/generic/324
new file mode 100755
index 0000000..7b45ca8
--- /dev/null
+++ b/tests/generic/324
@@ -0,0 +1,64 @@
+#! /bin/bash
+# FS QA Test No. generic/324
+#
+# Check renameat2 syscall with RENAME_NOREPLACE 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
+
+_requires_renameat2
+
+rename_dir=$TEST_DIR/$$
+mkdir $rename_dir
+touch $rename_dir/foo
+if ! src/renameat2 -t -n $rename_dir/foo $rename_dir/bar; then
+    rm -f $rename_dir/foo $rename_dir/bar; rmdir $rename_dir
+    _notrun "fs doesn't support RENAME_NOREPLACE"
+fi
+rm -f $rename_dir/foo $rename_dir/bar
+
+# real QA test starts here
+
+_rename_tests $rename_dir -n
+rmdir $rename_dir
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/324.out b/tests/generic/324.out
new file mode 100644
index 0000000..fff5547
--- /dev/null
+++ b/tests/generic/324.out
@@ -0,0 +1,51 @@
+QA output created by 324
+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 -> none/regu.
+samedir  regu/regu -> File exists
+samedir  regu/symb -> File exists
+samedir  regu/dire -> File exists
+samedir  regu/tree -> File exists
+samedir  symb/none -> none/symb.
+samedir  symb/regu -> File exists
+samedir  symb/symb -> File exists
+samedir  symb/dire -> File exists
+samedir  symb/tree -> File exists
+samedir  dire/none -> none/dire.
+samedir  dire/regu -> File exists
+samedir  dire/symb -> File exists
+samedir  dire/dire -> File exists
+samedir  dire/tree -> File exists
+samedir  tree/none -> none/tree.
+samedir  tree/regu -> File exists
+samedir  tree/symb -> File exists
+samedir  tree/dire -> File exists
+samedir  tree/tree -> File exists
+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 -> none/regu.
+crossdir regu/regu -> File exists
+crossdir regu/symb -> File exists
+crossdir regu/dire -> File exists
+crossdir regu/tree -> File exists
+crossdir symb/none -> none/symb.
+crossdir symb/regu -> File exists
+crossdir symb/symb -> File exists
+crossdir symb/dire -> File exists
+crossdir symb/tree -> File exists
+crossdir dire/none -> none/dire.
+crossdir dire/regu -> File exists
+crossdir dire/symb -> File exists
+crossdir dire/dire -> File exists
+crossdir dire/tree -> File exists
+crossdir tree/none -> none/tree.
+crossdir tree/regu -> File exists
+crossdir tree/symb -> File exists
+crossdir tree/dire -> File exists
+crossdir tree/tree -> File exists
diff --git a/tests/generic/group b/tests/generic/group
index 26e584b..37697d8 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -137,3 +137,4 @@
 321 auto quick metadata log
 322 auto quick metadata log
 323 auto quick
+324 auto quick
-- 
1.8.1.4

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/4] renameat2 syscall: check cross rename
  2014-04-11 15:51 [PATCH 1/4] renameat2 syscall: add infrastructure Miklos Szeredi
  2014-04-11 15:51 ` [PATCH 2/4] renameat2 syscall: check plain rename Miklos Szeredi
  2014-04-11 15:51 ` [PATCH 3/4] renameat2 syscall: check noreplace rename Miklos Szeredi
@ 2014-04-11 15:51 ` Miklos Szeredi
  2014-04-11 23:23 ` [PATCH 1/4] renameat2 syscall: add infrastructure Dave Chinner
  3 siblings, 0 replies; 8+ messages in thread
From: Miklos Szeredi @ 2014-04-11 15:51 UTC (permalink / raw)
  To: xfs; +Cc: Miklos Szeredi

From: Miklos Szeredi <mszeredi@suse.cz>

Check with RENAME_EXCHANGE flag.  This flag indicates that the source and
destination files are to be exchanged.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
 tests/generic/325     | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/325.out | 51 ++++++++++++++++++++++++++++++++++++++++
 tests/generic/group   |  1 +
 3 files changed, 116 insertions(+)
 create mode 100755 tests/generic/325
 create mode 100644 tests/generic/325.out

diff --git a/tests/generic/325 b/tests/generic/325
new file mode 100755
index 0000000..6776e10
--- /dev/null
+++ b/tests/generic/325
@@ -0,0 +1,64 @@
+#! /bin/bash
+# FS QA Test No. generic/325
+#
+# Check renameat2 syscall with RENAME_EXCHANGE 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
+
+_requires_renameat2
+
+rename_dir=$TEST_DIR/$$
+mkdir $rename_dir
+touch $rename_dir/foo $rename_dir/bar
+if ! src/renameat2 -t -x $rename_dir/foo $rename_dir/bar; then
+    rm -f $rename_dir/foo $rename_dir/bar; rmdir $rename_dir
+    _notrun "fs doesn't support RENAME_EXCHANGE"
+fi
+rm -f $rename_dir/foo $rename_dir/bar
+
+# real QA test starts here
+
+_rename_tests $rename_dir -x
+rmdir $rename_dir
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/325.out b/tests/generic/325.out
new file mode 100644
index 0000000..f73d7c1
--- /dev/null
+++ b/tests/generic/325.out
@@ -0,0 +1,51 @@
+QA output created by 325
+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 -> No such file or directory
+samedir  regu/regu -> regu/regu.
+samedir  regu/symb -> symb/regu.
+samedir  regu/dire -> dire/regu.
+samedir  regu/tree -> tree/regu.
+samedir  symb/none -> No such file or directory
+samedir  symb/regu -> regu/symb.
+samedir  symb/symb -> symb/symb.
+samedir  symb/dire -> dire/symb.
+samedir  symb/tree -> tree/symb.
+samedir  dire/none -> No such file or directory
+samedir  dire/regu -> regu/dire.
+samedir  dire/symb -> symb/dire.
+samedir  dire/dire -> dire/dire.
+samedir  dire/tree -> tree/dire.
+samedir  tree/none -> No such file or directory
+samedir  tree/regu -> regu/tree.
+samedir  tree/symb -> symb/tree.
+samedir  tree/dire -> dire/tree.
+samedir  tree/tree -> tree/tree.
+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 -> No such file or directory
+crossdir regu/regu -> regu/regu.
+crossdir regu/symb -> symb/regu.
+crossdir regu/dire -> dire/regu.
+crossdir regu/tree -> tree/regu.
+crossdir symb/none -> No such file or directory
+crossdir symb/regu -> regu/symb.
+crossdir symb/symb -> symb/symb.
+crossdir symb/dire -> dire/symb.
+crossdir symb/tree -> tree/symb.
+crossdir dire/none -> No such file or directory
+crossdir dire/regu -> regu/dire.
+crossdir dire/symb -> symb/dire.
+crossdir dire/dire -> dire/dire.
+crossdir dire/tree -> tree/dire.
+crossdir tree/none -> No such file or directory
+crossdir tree/regu -> regu/tree.
+crossdir tree/symb -> symb/tree.
+crossdir tree/dire -> dire/tree.
+crossdir tree/tree -> tree/tree.
diff --git a/tests/generic/group b/tests/generic/group
index 37697d8..8ea9b10 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -138,3 +138,4 @@
 322 auto quick metadata log
 323 auto quick
 324 auto quick
+325 auto quick
-- 
1.8.1.4

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/4] renameat2 syscall: add infrastructure
  2014-04-11 15:51 [PATCH 1/4] renameat2 syscall: add infrastructure Miklos Szeredi
                   ` (2 preceding siblings ...)
  2014-04-11 15:51 ` [PATCH 4/4] renameat2 syscall: check cross rename Miklos Szeredi
@ 2014-04-11 23:23 ` Dave Chinner
  3 siblings, 0 replies; 8+ messages in thread
From: Dave Chinner @ 2014-04-11 23:23 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: Miklos Szeredi, xfs

On Fri, Apr 11, 2014 at 05:51:54PM +0200, Miklos Szeredi wrote:
> From: Miklos Szeredi <mszeredi@suse.cz>
> 
> The renameat2() syscall was merged into 3.15-rc (merge commit: 7df934526c0b).
> 
> This adds the shared infrastructure for the actual test scripts.
> 
> Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>

Hi Miklos, all 4 patches look good now, so I'll pull them in with
the next round of xfstests updates. I'll let ou know if there are
any other problems I find. Thanks!

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/4] renameat2 syscall: check plain rename
  2014-04-11 15:51 ` [PATCH 2/4] renameat2 syscall: check plain rename Miklos Szeredi
@ 2014-04-14  2:30   ` Dave Chinner
  2014-04-16 14:18     ` Christoph Hellwig
  0 siblings, 1 reply; 8+ messages in thread
From: Dave Chinner @ 2014-04-14  2:30 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: Miklos Szeredi, xfs

On Fri, Apr 11, 2014 at 05:51:55PM +0200, Miklos Szeredi wrote:
> From: Miklos Szeredi <mszeredi@suse.cz>
> 
> Check with zero flags.  This is what rename(2) and renameat(2) now call, so
> this actually tests the behavior of these syscalls as well.
> 
> Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>

Miklos, this test fails on XFS with the following diff:

$ diff -u tests/generic/023.out /home/dave/src/xfstests-dev/results//generic/023.out.bad
--- tests/generic/023.out       2014-04-14 10:44:22.000000000 +1000
+++ /home/dave/src/xfstests-dev/results//generic/023.out.bad    2014-04-14 12:00:23.000000000 +1000
@@ -18,12 +18,12 @@
 samedir  dire/regu -> Not a directory
 samedir  dire/symb -> Not a directory
 samedir  dire/dire -> none/dire.
-samedir  dire/tree -> Directory not empty
+samedir  dire/tree -> File exists
 samedir  tree/none -> none/tree.
 samedir  tree/regu -> Not a directory
 samedir  tree/symb -> Not a directory
 samedir  tree/dire -> none/tree.
-samedir  tree/tree -> Directory not empty
+samedir  tree/tree -> File exists
 crossdir none/none -> No such file or directory
 crossdir none/regu -> No such file or directory
 crossdir none/symb -> No such file or directory
@@ -43,9 +43,9 @@
 crossdir dire/regu -> Not a directory
 crossdir dire/symb -> Not a directory
 crossdir dire/dire -> none/dire.
-crossdir dire/tree -> Directory not empty
+crossdir dire/tree -> File exists
 crossdir tree/none -> none/tree.
 crossdir tree/regu -> Not a directory
 crossdir tree/symb -> Not a directory
 crossdir tree/dire -> none/tree.
-crossdir tree/tree -> Directory not empty
+crossdir tree/tree -> File exists

IOWs, XFS is returning EEXIST rather than ENOTEMPTY for several of
these rename tests. The rename man page says this about the errors:

       ENOTEMPTY or EEXIST
              newpath is a nonempty directory, that is, contains
	      entries other than "." and "..".

Which implies that both errors are valid and so the test should pass
in either case. Can you send a patch to handle these
different-but-valid error returns?

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/4] renameat2 syscall: check plain rename
  2014-04-14  2:30   ` Dave Chinner
@ 2014-04-16 14:18     ` Christoph Hellwig
  2014-04-16 23:03       ` Dave Chinner
  0 siblings, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2014-04-16 14:18 UTC (permalink / raw)
  To: Dave Chinner; +Cc: xfs, Miklos Szeredi, Miklos Szeredi

On Mon, Apr 14, 2014 at 12:30:20PM +1000, Dave Chinner wrote:
> IOWs, XFS is returning EEXIST rather than ENOTEMPTY for several of
> these rename tests. The rename man page says this about the errors:
> 
>        ENOTEMPTY or EEXIST
>               newpath is a nonempty directory, that is, contains
> 	      entries other than "." and "..".
> 
> Which implies that both errors are valid and so the test should pass
> in either case. Can you send a patch to handle these
> different-but-valid error returns?

I would much prefer if all Linux filesystems behaved uniformly here.

While EEXIST sounds much more logical to me in this case I suspect most
other filesystems have copy & pasted from ext2, and we should switch to
ENOTEMPTY as well.

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/4] renameat2 syscall: check plain rename
  2014-04-16 14:18     ` Christoph Hellwig
@ 2014-04-16 23:03       ` Dave Chinner
  0 siblings, 0 replies; 8+ messages in thread
From: Dave Chinner @ 2014-04-16 23:03 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs, Miklos Szeredi, Miklos Szeredi

On Wed, Apr 16, 2014 at 07:18:25AM -0700, Christoph Hellwig wrote:
> On Mon, Apr 14, 2014 at 12:30:20PM +1000, Dave Chinner wrote:
> > IOWs, XFS is returning EEXIST rather than ENOTEMPTY for several of
> > these rename tests. The rename man page says this about the errors:
> > 
> >        ENOTEMPTY or EEXIST
> >               newpath is a nonempty directory, that is, contains
> > 	      entries other than "." and "..".
> > 
> > Which implies that both errors are valid and so the test should pass
> > in either case. Can you send a patch to handle these
> > different-but-valid error returns?
> 
> I would much prefer if all Linux filesystems behaved uniformly here.
> 
> While EEXIST sounds much more logical to me in this case I suspect most
> other filesystems have copy & pasted from ext2, and we should switch to
> ENOTEMPTY as well.

Send patches, please.

But from an xfstests perspective, we still have to support kernels
and filesystems that return EEXIST for this function, as it is
valid for them to do so....

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-04-16 23:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-11 15:51 [PATCH 1/4] renameat2 syscall: add infrastructure Miklos Szeredi
2014-04-11 15:51 ` [PATCH 2/4] renameat2 syscall: check plain rename Miklos Szeredi
2014-04-14  2:30   ` Dave Chinner
2014-04-16 14:18     ` Christoph Hellwig
2014-04-16 23:03       ` Dave Chinner
2014-04-11 15:51 ` [PATCH 3/4] renameat2 syscall: check noreplace rename Miklos Szeredi
2014-04-11 15:51 ` [PATCH 4/4] renameat2 syscall: check cross rename Miklos Szeredi
2014-04-11 23:23 ` [PATCH 1/4] renameat2 syscall: add infrastructure Dave Chinner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.