isofs.sh 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-2.0-or-later
  3. # Copyright (c) International Business Machines Corp., 2003
  4. # Written by Prakash Narayana (prakashn@us.ibm.com)
  5. # and Michael Reed (mreed10@us.ibm.com)
  6. # Copyright (c) Linux Test Project, 2016-2019
  7. #
  8. # Test isofs on Linux system.
  9. # It makes ISO9660 file system with different options and also
  10. # mounts ISO9660 file system with different mount options.
  11. TST_NEEDS_CMDS="mkisofs"
  12. TST_NEEDS_TMPDIR=1
  13. TST_TESTFUNC=do_test
  14. . tst_test.sh
  15. MAX_DEPTH=3
  16. MAX_DIRS=4
  17. gen_fs_tree()
  18. {
  19. local cur_path="$1"
  20. local cur_depth="$2"
  21. local new_path
  22. [ "$cur_depth" -gt "$MAX_DEPTH" ] && return
  23. for i in $(seq 1 $MAX_DIRS); do
  24. new_path="$cur_path/subdir_$i"
  25. mkdir -p "$new_path"
  26. ROD_SILENT dd if=/dev/urandom of="$new_path/file" bs=1024 count=100
  27. gen_fs_tree "$new_path" $((cur_depth + 1))
  28. done
  29. }
  30. do_test() {
  31. local mnt_point="$PWD/mnt"
  32. local make_file_sys_dir="$PWD/files"
  33. mkdir -p -m 777 $mnt_point
  34. mkdir -p $make_file_sys_dir
  35. # Generated directories and files
  36. mkdir -p $make_file_sys_dir
  37. gen_fs_tree "$make_file_sys_dir" 1
  38. # Make ISO9660 file system with different options.
  39. # Mount the ISO9660 file system with different mount options.
  40. for mkisofs_opt in \
  41. " " \
  42. "-J" \
  43. "-hfs -D" \
  44. " -R " \
  45. "-R -J" \
  46. "-f -l -D -J -allow-leading-dots -R" \
  47. "-allow-lowercase -allow-multidot -iso-level 3 -f -l -D -J -allow-leading-dots -R"
  48. do
  49. rm -f isofs.iso
  50. EXPECT_PASS mkisofs -o isofs.iso -quiet $mkisofs_opt $make_file_sys_dir 2\> /dev/null \
  51. || continue
  52. for mount_opt in \
  53. "loop" \
  54. "loop,norock" \
  55. "loop,nojoliet" \
  56. "loop,block=512,unhide" \
  57. "loop,block=1024,cruft" \
  58. "loop,block=2048,nocompress" \
  59. "loop,check=strict,map=off,gid=bin,uid=bin" \
  60. "loop,check=strict,map=acorn,gid=bin,uid=bin" \
  61. "loop,check=relaxed,map=normal" \
  62. "loop,block=512,unhide,session=2"
  63. do
  64. mount -t iso9660 -o $mount_opt isofs.iso $mnt_point
  65. if [ $? -ne 0 ]; then
  66. tst_res TFAIL "mount -t iso9660 -o $mount_opt isofs.iso $mnt_point"
  67. continue
  68. fi
  69. ls -lR $mnt_point > /dev/null || tst_res TFAIL "ls -lR $mnt_point"
  70. umount $mnt_point || tst_brk TFAIL "umount $mnt_point"
  71. tst_res TPASS "mount/umount with \"$mount_opt\" options"
  72. done
  73. done
  74. }
  75. tst_run