1#!/bin/sh 2# 3# Copyright (c) International Business Machines Corp., 2003 4# 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 2 of the License, or 8# (at your option) any later version. 9# 10# This program is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# GNU General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License along 16# with this program; if not, write to the Free Software Foundation, Inc., 17# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18# 19# Written by Prakash Narayana (prakashn@us.ibm.com) 20# and Michael Reed (mreed10@us.ibm.com) 21# 22# A script that will test isofs on Linux system. 23# It makes ISO9660 file system with different options and also 24# mounts the ISO9660 file system with different mount options. 25# 26 27TCID=isofs 28TST_TOTAL=77 29. test.sh 30 31NO_CLEANUP="" 32 33usage() 34{ 35 echo "USAGE: $0 <optional> -n -h" 36 exit 37} 38 39cleanup() 40{ 41 if [ "$NO_CLEANUP" = "no" ]; then 42 tst_resm TINFO "Temporary directory $PWD was not removed" 43 else 44 tst_rmdir 45 fi 46} 47 48max_depth=3 49max_dirs=4 50 51gen_fs_tree() 52{ 53 local cur_path="$1" 54 local cur_depth="$2" 55 56 if [ "$cur_depth" -gt "$max_depth" ]; then 57 return 58 fi 59 60 for i in $(seq 1 $max_dirs); do 61 local new_path="$cur_path/subdir_$i" 62 63 mkdir -p "$new_path" 64 65 dd if=/dev/urandom of="$new_path/file" bs=1024 count=100 >/dev/null 2>&1 66 67 gen_fs_tree "$new_path" $((cur_depth + 1)) 68 done 69} 70 71while getopts :hnd: arg; do 72 case $arg in 73 h) 74 echo "" 75 echo "n - The directories created will not be removed" 76 echo "h - Help options" 77 echo "" 78 usage 79 echo "" 80 ;; 81 n) 82 NO_CLEANUP="no" 83 ;; 84 esac 85done 86 87tst_require_root 88 89tst_tmpdir 90TST_CLEANUP=cleanup 91 92MNT_POINT="$PWD/mnt" 93MAKE_FILE_SYS_DIR="$PWD/files" 94 95mkdir -p -m 777 $MNT_POINT 96mkdir -p $MAKE_FILE_SYS_DIR 97 98# Generated directories and files 99mkdir -p $MAKE_FILE_SYS_DIR 100gen_fs_tree "$MAKE_FILE_SYS_DIR" 1 101 102# Make ISO9660 file system with different options. 103# Mount the ISO9660 file system with different mount options. 104 105for mkisofs_opt in \ 106 " " \ 107 "-J" \ 108 "-hfs -D" \ 109 " -R " \ 110 "-R -J" \ 111 "-f -l -D -J -L -R" \ 112 "-allow-lowercase -allow-multidot -iso-level 3 -f -l -D -J -L -R" 113do 114 rm -f isofs.iso 115 mkisofs -o isofs.iso -quiet $mkisofs_opt $MAKE_FILE_SYS_DIR 2> /dev/null 116 if [ $? -eq 0 ]; then 117 tst_resm TPASS \ 118 "mkisofs -o isofs.iso -quiet $mkisofs_opt $MAKE_FILE_SYS_DIR" 119 else 120 tst_resm TFAIL \ 121 tst_resm TFAIL "mkisofs -o isofs.iso -quiet $mkisofs_opt $MAKE_FILE_SYS_DIR" 122 continue 123 fi 124 125 for mount_opt in \ 126 "loop" \ 127 "loop,norock" \ 128 "loop,nojoliet" \ 129 "loop,block=512,unhide" \ 130 "loop,block=1024,cruft" \ 131 "loop,block=2048,nocompress" \ 132 "loop,check=strict,map=off,gid=bin,uid=bin" \ 133 "loop,check=strict,map=acorn,gid=bin,uid=bin" \ 134 "loop,check=relaxed,map=normal" \ 135 "loop,block=512,unhide,session=2" 136 # "loop,sbsector=32" 137 do 138 mount -t iso9660 -o $mount_opt isofs.iso $MNT_POINT 139 if [ $? -ne 0 ]; then 140 tst_resm TFAIL \ 141 "mount -t iso9660 -o $mount_opt isofs.iso $MNT_POINT" 142 continue 143 fi 144 145 ls -lR $MNT_POINT > /dev/null 146 if [ $? -ne 0 ]; then 147 tst_resm TFAIL "ls -lR $MNT_POINT" 148 fi 149 150 umount $MNT_POINT 151 if [ $? -ne 0 ]; then 152 tst_brkm TFAIL "umount $MNT_POINT" 153 fi 154 155 tst_resm TPASS "mount/umount with \"$mount_opt\" options" 156 done 157done 158 159tst_exit 160