blob: 0162f88bbfaaeda2ea4f700ce81e556f68b968ad [file] [log] [blame]
mridge06925cd2003-07-08 18:05:01 +00001#!/bin/bash
2
3
4##############################################################
5#
6# Copyright (c) International Business Machines Corp., 2003
7#
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.
12#
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.
17#
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
21#
22# FILE : isofs.sh
mreed108d0bf1f2005-08-02 18:28:42 +000023# USAGE : isofs.sh <optional> -n (no clean up)
mridge06925cd2003-07-08 18:05:01 +000024#
25# DESCRIPTION : A script that will test isofs on Linux system.
mreed108d0bf1f2005-08-02 18:28:42 +000026# It makes ISO9660 file system with different options and also
27# mounts the ISO9660 file system with different mount options.
28#
mridge06925cd2003-07-08 18:05:01 +000029# REQUIREMENTS:
30#
31# HISTORY :
32# 06/27/2003 Prakash Narayana (prakashn@us.ibm.com)
mreed108d0bf1f2005-08-02 18:28:42 +000033# 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
mridge06925cd2003-07-08 18:05:01 +000041#
42# CODE COVERAGE: 40.5% - fs/isofs (Total Coverage)
43#
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
50#
51##############################################################
52
mridge06925cd2003-07-08 18:05:01 +000053USAGE="$0"
mreed108d0bf1f2005-08-02 18:28:42 +000054NO_CLEANUP=""
55
56 usage()
57 {
58 echo "USAGE: $USAGE <optional> -n -h -d [directory name]"
59 exit
60 }
61
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
67
68 while getopts :hnd: arg
69 do case $arg in
70 d)
71 COPY_DIR=$OPTARG
72 MAKE_FILE_SYS_DIR="/tmp/for_isofs_test"$COPY_DIR
73 ;;
74 h)
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 ""
82 ;;
83 n)
84 NO_CLEANUP="no"
85 ;;
86 esac
87 done
mridge06925cd2003-07-08 18:05:01 +000088
89
90##############################################################
91#
92# Make sure that uid=root is running this script.
93# Validate the command line arguments.
94#
95##############################################################
96
97if [ $UID != 0 ]
98then
99 echo "FAILED: Must have root access to execute this script"
100 exit 1
101fi
102
mreed108d0bf1f2005-08-02 18:28:42 +0000103
104 mkdir -p -m 777 $MNT_POINT
105 mkdir -p $MAKE_FILE_SYS_DIR
106
107
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
116 fi
117
mridge06925cd2003-07-08 18:05:01 +0000118
119
120# Make ISO9660 file system with different options.
121# Mount the ISO9660 file system with different mount options.
122
123for mkisofs_opt in \
124 " " \
125 "-J" \
mridgea64d3222004-02-06 16:00:20 +0000126 "-hfs -D" \
mridge06925cd2003-07-08 18:05:01 +0000127 " -R " \
128 "-R -J" \
129 "-f -l -D -J -L -R" \
robbiewc967b022003-10-10 20:20:09 +0000130 "-allow-lowercase -allow-multidot -iso-level 3 -f -l -D -J -L -R"
mridge06925cd2003-07-08 18:05:01 +0000131do
mreed108d0bf1f2005-08-02 18:28:42 +0000132 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
mridge06925cd2003-07-08 18:05:01 +0000134 if [ $? != 0 ]
135 then
136 rm -rf isofs.iso $MNT_POINT
mreed108d0bf1f2005-08-02 18:28:42 +0000137 echo "FAILED: mkisofs -o isofs.iso $mkisofs_opt $MAKE_FILE_SYS_DIR failed"
mridge06925cd2003-07-08 18:05:01 +0000138 exit 1
139 fi
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" \
mridge06925cd2003-07-08 18:05:01 +0000150 "loop,block=512,unhide,session=2"
151 # "loop,sbsector=32"
152 do
mridgea64d3222004-02-06 16:00:20 +0000153 echo "Running mount -o $mount_opt isofs.iso $MNT_POINT Command"
mridge06925cd2003-07-08 18:05:01 +0000154 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
160 fi
mridgea64d3222004-02-06 16:00:20 +0000161 echo "Running ls -lR $MNT_POINT Command"
162 ls -lR $MNT_POINT
mridge06925cd2003-07-08 18:05:01 +0000163 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
168done
169
170#######################################################
171#
172# Just before exit, perform the cleanup.
173#
174#######################################################
175
mreed108d0bf1f2005-08-02 18:28:42 +0000176 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
182 fi
183
184
mridge06925cd2003-07-08 18:05:01 +0000185echo "PASSED: $0 passed!"
186exit 0