Imported Upstream version 20091031
[ltp-debian.git] / testscripts / isofs.sh
blob0162f88bbfaaeda2ea4f700ce81e556f68b968ad
1 #!/bin/bash
4 ##############################################################
6 # Copyright (c) International Business Machines Corp., 2003
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
16 # the GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 # FILE : isofs.sh
23 # USAGE : isofs.sh <optional> -n (no clean up)
25 # DESCRIPTION : A script that will test isofs on Linux system.
26 # It makes ISO9660 file system with different options and also
27 # mounts the ISO9660 file system with different mount options.
29 # REQUIREMENTS:
31 # HISTORY :
32 # 06/27/2003 Prakash Narayana (prakashn@us.ibm.com)
33 # 07/28/2005 Michael Reed (mreed10@us.ibm.com)
34 # - Changed the directory where the filesytems were being created
35 # from /etc to copying /etc to /tmp/for_isofs_test/etc and
36 # creating the file systems there
37 # - Added the -n option to not remove the directories created for
38 # debugging purposes
39 # - Added -d option to specify a different directory to copy to /tmp
40 # to make the file system
42 # CODE COVERAGE: 40.5% - fs/isofs (Total Coverage)
44 # 23.7% - fs/isofs/dir.c
45 # 46.0% - fs/isofs/inode.c
46 # 22.9% - fs/isofs/joliet.c
47 # 50.0% - fs/isofs/namei.c
48 # 38.5% - fs/isofs/rock.c
49 # 10.7% - fs/isofs/util.c
51 ##############################################################
53 USAGE="$0"
54 NO_CLEANUP=""
56 usage()
58 echo "USAGE: $USAGE <optional> -n -h -d [directory name]"
59 exit
62 #Initialize directory variables
63 MNT_POINT="/tmp/isofs_$$"
64 COPY_DIR="/etc/"
65 TEMP_DIR="/tmp/for_isofs_test"
66 MAKE_FILE_SYS_DIR=$TEMP_DIR$COPY_DIR
68 while getopts :hnd: arg
69 do case $arg in
71 COPY_DIR=$OPTARG
72 MAKE_FILE_SYS_DIR="/tmp/for_isofs_test"$COPY_DIR
75 echo ""
76 echo "n - The directories created will not be removed"
77 echo "d - Specify a directory to copy into /tmp"
78 echo "h - Help options"
79 echo ""
80 usage
81 echo ""
84 NO_CLEANUP="no"
86 esac
87 done
90 ##############################################################
92 # Make sure that uid=root is running this script.
93 # Validate the command line arguments.
95 ##############################################################
97 if [ $UID != 0 ]
98 then
99 echo "FAILED: Must have root access to execute this script"
100 exit 1
104 mkdir -p -m 777 $MNT_POINT
105 mkdir -p $MAKE_FILE_SYS_DIR
108 if [ -e "$COPY_DIR" ]; then
109 cp -rf $COPY_DIR* $MAKE_FILE_SYS_DIR
110 else
111 echo "$COPY_DIR not found"
112 echo "use the -d option to copy a different directory into"
113 echo "/tmp to makethe ISO9660 file system with different"
114 echo "options"
115 usage
120 # Make ISO9660 file system with different options.
121 # Mount the ISO9660 file system with different mount options.
123 for mkisofs_opt in \
124 " " \
125 "-J" \
126 "-hfs -D" \
127 " -R " \
128 "-R -J" \
129 "-f -l -D -J -L -R" \
130 "-allow-lowercase -allow-multidot -iso-level 3 -f -l -D -J -L -R"
132 echo "Running mkisofs -o isofs.iso -quiet $mkisofs_opt $MAKE_FILE_SYS_DIR Command"
133 mkisofs -o isofs.iso -quiet $mkisofs_opt $MAKE_FILE_SYS_DIR
134 if [ $? != 0 ]
135 then
136 rm -rf isofs.iso $MNT_POINT
137 echo "FAILED: mkisofs -o isofs.iso $mkisofs_opt $MAKE_FILE_SYS_DIR failed"
138 exit 1
140 for mount_opt in \
141 "loop" \
142 "loop,norock" \
143 "loop,nojoliet" \
144 "loop,block=512,unhide" \
145 "loop,block=1024,cruft" \
146 "loop,block=2048,nocompress" \
147 "loop,check=strict,map=off,gid=bin,uid=bin" \
148 "loop,check=strict,map=acorn,gid=bin,uid=bin" \
149 "loop,check=relaxed,map=normal" \
150 "loop,block=512,unhide,session=2"
151 # "loop,sbsector=32"
153 echo "Running mount -o $mount_opt isofs.iso $MNT_POINT Command"
154 mount -t iso9660 -o $mount_opt isofs.iso $MNT_POINT
155 if [ $? != 0 ]
156 then
157 rm -rf isofs.iso $MNT_POINT
158 echo "FAILED: mount -t iso9660 -o $mount_opt isofs.iso $MNT_POINT failed"
159 exit 1
161 echo "Running ls -lR $MNT_POINT Command"
162 ls -lR $MNT_POINT
163 exportfs -i -o no_root_squash,rw *:$MNT_POINT
164 exportfs -u :$MNT_POINT
165 umount $MNT_POINT
166 done
167 rm -rf isofs.iso
168 done
170 #######################################################
172 # Just before exit, perform the cleanup.
174 #######################################################
176 if [ "$NO_CLEANUP" == "no" ]; then
177 echo "$MAKE_FILE_SYS_DIR and $MNT_POINT were not removed"
178 echo "These directories will have to be removed manually"
179 else
180 rm -rf $TEMP_DIR
181 rm -rf $MNT_POINT
185 echo "PASSED: $0 passed!"
186 exit 0