3 # Test that we can write into a bind mount with the copy_if_rename_fails flag.
4 # This requires that EXDEV or EBUSY is returned from rename(2) to activate the
5 # code path, so set up a bind mount on Linux.
7 if [ "$UID" != 0 -o "$(uname -s)" != "Linux" ]; then
8 echo "Test can only be run as root on Linux to create bind mounts"
12 ROOT=$abs_top_builddir/build/test-put-mount
13 LENSES=$abs_top_srcdir/lenses
16 TARGET=$ROOT/other/real_hosts
19 mkdir -p $(dirname $HOSTS)
20 mkdir -p $(dirname $TARGET)
22 echo 127.0.0.1 localhost > $TARGET
25 mount --bind $TARGET $HOSTS
31 HOSTS_SUM=$(sum $HOSTS)
33 augtool --nostdinc -I $LENSES -r $ROOT <<EOF
34 set /augeas/save/copy_if_rename_fails 1
35 set /files/etc/hosts/1/alias myhost
40 if [ ! "x${HOSTS_SUM}" != "x$(sum $HOSTS)" ]; then
41 echo "/etc/hosts hasn't changed"
45 if [ ! "x${HOSTS_SUM}" != "x$(sum $TARGET)" ]; then
46 echo "/other/real_hosts hasn't changed"
50 if ! grep myhost $TARGET >/dev/null; then
51 echo "/other/real_hosts does not contain the modification"