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 12TST_NEEDS_CMDS="mkisofs" 13TST_NEEDS_TMPDIR=1 14TST_TESTFUNC=do_test 15. tst_test.sh 16 17MAX_DEPTH=3 18MAX_DIRS=4 19 20gen_fs_tree() 21{ 22 local cur_path="$1" 23 local cur_depth="$2" 24 local new_path 25 26 [ "$cur_depth" -gt "$MAX_DEPTH" ] && return 27 28 for i in $(seq 1 $MAX_DIRS); do 29 new_path="$cur_path/subdir_$i" 30 mkdir -p "$new_path" 31 ROD_SILENT dd if=/dev/urandom of="$new_path/file" bs=1024 count=100 32 gen_fs_tree "$new_path" $((cur_depth + 1)) 33 done 34} 35 36do_test() { 37 local mnt_point="$PWD/mnt" 38 local make_file_sys_dir="$PWD/files" 39 40 mkdir -p -m 777 $mnt_point 41 mkdir -p $make_file_sys_dir 42 43 # Generated directories and files 44 mkdir -p $make_file_sys_dir 45 gen_fs_tree "$make_file_sys_dir" 1 46 47 # Make ISO9660 file system with different options. 48 # Mount the ISO9660 file system with different mount options. 49 for mkisofs_opt in \ 50 " " \ 51 "-J" \ 52 "-hfs -D" \ 53 " -R " \ 54 "-R -J" \ 55 "-f -l -D -J -allow-leading-dots -R" \ 56 "-allow-lowercase -allow-multidot -iso-level 3 -f -l -D -J -allow-leading-dots -R" 57 do 58 rm -f isofs.iso 59 EXPECT_PASS mkisofs -o isofs.iso -quiet $mkisofs_opt $make_file_sys_dir 2\> /dev/null \ 60 || continue 61 62 for mount_opt in \ 63 "loop" \ 64 "loop,norock" \ 65 "loop,nojoliet" \ 66 "loop,block=512,unhide" \ 67 "loop,block=1024,cruft" \ 68 "loop,block=2048,nocompress" \ 69 "loop,check=strict,map=off,gid=bin,uid=bin" \ 70 "loop,check=strict,map=acorn,gid=bin,uid=bin" \ 71 "loop,check=relaxed,map=normal" \ 72 "loop,block=512,unhide,session=2" 73 do 74 mount -t iso9660 -o $mount_opt isofs.iso $mnt_point 75 if [ $? -ne 0 ]; then 76 tst_res TFAIL "mount -t iso9660 -o $mount_opt isofs.iso $mnt_point" 77 continue 78 fi 79 80 ls -lR $mnt_point > /dev/null || tst_res TFAIL "ls -lR $mnt_point" 81 umount $mnt_point || tst_brk TFAIL "umount $mnt_point" 82 83 tst_res TPASS "mount/umount with \"$mount_opt\" options" 84 done 85 done 86} 87 88tst_run 89