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