2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014 Miklos Szeredi. All Rights Reserved.
16 regu) echo foo > $path;;
17 symb) ln -s foo $path;;
19 tree) mkdir $path; echo foo > $path/bar;;
24 # Cleanup source or dest
30 if test -d $path; then
39 # Check type of source or destination
45 if test -e $path -o -h $path; then
46 if test -d $path -a -e $path/bar; then
49 echo -n `stat -c %F $path | cut -b-4`
57 # This runs renameat2 on all combinations of source and dest
59 _rename_tests_source_dest()
66 for stype in none regu symb dire tree; do
67 for dtype in none regu symb dire tree; do
68 echo -n "$options $stype/$dtype -> "
69 _setup_one $source $stype
70 _setup_one $dest $dtype
71 $here/src/renameat2 $source $dest $flags
85 # This runs _rename_tests_source_dest() for both same-directory and
86 # cross-directory renames
93 #same directory renames
94 _rename_tests_source_dest $testdir/src $testdir/dst "samedir " $flags
96 #cross directory renames
97 mkdir $testdir/x $testdir/y
98 _rename_tests_source_dest $testdir/x/src $testdir/y/dst "crossdir" $flags
99 rmdir $testdir/x $testdir/y
103 # This checks whether the renameat2 syscall is supported
108 local rename_dir=`mktemp -d -p $TEST_DIR`
111 if test ! -x $here/src/renameat2; then
112 _notrun "renameat2 binary not found"
115 touch $rename_dir/foo
118 cmd="-n $rename_dir/foo $rename_dir/bar"
121 touch $rename_dir/bar
122 cmd="-x $rename_dir/foo $rename_dir/bar"
125 touch $rename_dir/bar
126 cmd="-w $rename_dir/foo $rename_dir/bar"
133 _fail "_require_renameat2: only support noreplace,exchange,whiteout rename flags"
136 if ! $here/src/renameat2 -t $cmd; then
138 _notrun "kernel doesn't support renameat2 syscall"