Home | History | Annotate | Download | only in iso9660
      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 (at] us.ibm.com)
     20 # and Michael Reed (mreed10 (at] 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 
     27 TCID=isofs
     28 TST_TOTAL=77
     29 . test.sh
     30 
     31 NO_CLEANUP=""
     32 
     33 usage()
     34 {
     35 	echo "USAGE: $0 <optional> -n -h"
     36 	exit
     37 }
     38 
     39 cleanup()
     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 
     48 max_depth=3
     49 max_dirs=4
     50 
     51 gen_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 
     71 while 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
     85 done
     86 
     87 tst_require_root
     88 
     89 tst_tmpdir
     90 TST_CLEANUP=cleanup
     91 
     92 MNT_POINT="$PWD/mnt"
     93 MAKE_FILE_SYS_DIR="$PWD/files"
     94 
     95 mkdir -p -m 777 $MNT_POINT
     96 mkdir -p $MAKE_FILE_SYS_DIR
     97 
     98 # Generated directories and files
     99 mkdir -p $MAKE_FILE_SYS_DIR
    100 gen_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 
    105 tst_test_cmds mkisofs
    106 
    107 for mkisofs_opt in \
    108 	" " \
    109 	"-J" \
    110 	"-hfs -D" \
    111 	" -R " \
    112 	"-R -J" \
    113 	"-f -l -D -J -allow-leading-dots -R" \
    114 	"-allow-lowercase -allow-multidot -iso-level 3 -f -l -D -J -allow-leading-dots -R"
    115 do
    116 	rm -f isofs.iso
    117 	mkisofs -o isofs.iso -quiet $mkisofs_opt $MAKE_FILE_SYS_DIR 2> /dev/null
    118 	if [ $? -eq 0 ]; then
    119 		tst_resm TPASS \
    120 			"mkisofs -o isofs.iso -quiet $mkisofs_opt $MAKE_FILE_SYS_DIR"
    121 	else
    122 		tst_resm TFAIL \
    123 			tst_resm TFAIL "mkisofs -o isofs.iso -quiet $mkisofs_opt $MAKE_FILE_SYS_DIR"
    124 		continue
    125 	fi
    126 
    127 	for mount_opt in \
    128 		"loop" \
    129 		"loop,norock" \
    130 		"loop,nojoliet" \
    131 		"loop,block=512,unhide" \
    132 		"loop,block=1024,cruft" \
    133 		"loop,block=2048,nocompress" \
    134 		"loop,check=strict,map=off,gid=bin,uid=bin" \
    135 		"loop,check=strict,map=acorn,gid=bin,uid=bin" \
    136 		"loop,check=relaxed,map=normal" \
    137 		"loop,block=512,unhide,session=2"
    138 		# "loop,sbsector=32"
    139 	do
    140 		mount -t iso9660 -o $mount_opt isofs.iso $MNT_POINT
    141 		if [ $? -ne 0 ]; then
    142 			tst_resm TFAIL \
    143 				"mount -t iso9660 -o $mount_opt isofs.iso $MNT_POINT"
    144 			continue
    145 		fi
    146 
    147 		ls -lR $MNT_POINT > /dev/null
    148 		if [ $? -ne 0 ]; then
    149 			tst_resm TFAIL "ls -lR $MNT_POINT"
    150 		fi
    151 
    152 		umount $MNT_POINT
    153 		if [ $? -ne 0 ]; then
    154 			tst_brkm TFAIL "umount $MNT_POINT"
    155 		fi
    156 
    157 		tst_resm TPASS "mount/umount with \"$mount_opt\" options"
    158 	done
    159 done
    160 
    161 tst_exit
    162