hard-link-1.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/sh
  2. # move a directory containing hard-linked files and
  3. # make sure the links are preserved
  4. # Copyright (C) 1998-2018 Free Software Foundation, Inc.
  5. # This program is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  15. . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
  16. print_ver_ mv
  17. cleanup_() { rm -rf "$other_partition_tmpdir"; }
  18. . "$abs_srcdir/tests/other-fs-tmpdir"
  19. dir=hlink
  20. mkdir $dir || framework_failure_
  21. > $dir/a || framework_failure_
  22. ln $dir/a $dir/b || framework_failure_
  23. mv $dir "$other_partition_tmpdir" || fail=1
  24. # Display inode numbers, one per line.
  25. ls -1i "$other_partition_tmpdir/$dir" > out || fail=1
  26. # Make sure the inode numbers are the same.
  27. a=$(sed -n 's/ a$//p' out)
  28. b=$(sed -n 's/ b$//p' out)
  29. test "$a" = "$b" || fail=1
  30. Exit $fail