mridge | 06925cd | 2003-07-08 18:05:01 +0000 | [diff] [blame] | 1 | #!/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 |
mreed10 | 8d0bf1f | 2005-08-02 18:28:42 +0000 | [diff] [blame] | 23 | # USAGE : isofs.sh <optional> -n (no clean up) |
mridge | 06925cd | 2003-07-08 18:05:01 +0000 | [diff] [blame] | 24 | # |
| 25 | # DESCRIPTION : A script that will test isofs on Linux system. |
mreed10 | 8d0bf1f | 2005-08-02 18:28:42 +0000 | [diff] [blame] | 26 | # It makes ISO9660 file system with different options and also |
| 27 | # mounts the ISO9660 file system with different mount options. |
| 28 | # |
mridge | 06925cd | 2003-07-08 18:05:01 +0000 | [diff] [blame] | 29 | # REQUIREMENTS: |
| 30 | # |
| 31 | # HISTORY : |
| 32 | # 06/27/2003 Prakash Narayana (prakashn@us.ibm.com) |
mreed10 | 8d0bf1f | 2005-08-02 18:28:42 +0000 | [diff] [blame] | 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 |
mridge | 06925cd | 2003-07-08 18:05:01 +0000 | [diff] [blame] | 41 | # |
| 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 | |
mridge | 06925cd | 2003-07-08 18:05:01 +0000 | [diff] [blame] | 53 | USAGE="$0" |
mreed10 | 8d0bf1f | 2005-08-02 18:28:42 +0000 | [diff] [blame] | 54 | NO_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 |
mridge | 06925cd | 2003-07-08 18:05:01 +0000 | [diff] [blame] | 88 | |
| 89 | |
| 90 | ############################################################## |
| 91 | # |
| 92 | # Make sure that uid=root is running this script. |
| 93 | # Validate the command line arguments. |
| 94 | # |
| 95 | ############################################################## |
| 96 | |
| 97 | if [ $UID != 0 ] |
| 98 | then |
| 99 | echo "FAILED: Must have root access to execute this script" |
| 100 | exit 1 |
| 101 | fi |
| 102 | |
mreed10 | 8d0bf1f | 2005-08-02 18:28:42 +0000 | [diff] [blame] | 103 | |
| 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 | |
mridge | 06925cd | 2003-07-08 18:05:01 +0000 | [diff] [blame] | 118 | |
| 119 | |
| 120 | # Make ISO9660 file system with different options. |
| 121 | # Mount the ISO9660 file system with different mount options. |
| 122 | |
| 123 | for mkisofs_opt in \ |
| 124 | " " \ |
| 125 | "-J" \ |
mridge | a64d322 | 2004-02-06 16:00:20 +0000 | [diff] [blame] | 126 | "-hfs -D" \ |
mridge | 06925cd | 2003-07-08 18:05:01 +0000 | [diff] [blame] | 127 | " -R " \ |
| 128 | "-R -J" \ |
| 129 | "-f -l -D -J -L -R" \ |
robbiew | c967b02 | 2003-10-10 20:20:09 +0000 | [diff] [blame] | 130 | "-allow-lowercase -allow-multidot -iso-level 3 -f -l -D -J -L -R" |
mridge | 06925cd | 2003-07-08 18:05:01 +0000 | [diff] [blame] | 131 | do |
mreed10 | 8d0bf1f | 2005-08-02 18:28:42 +0000 | [diff] [blame] | 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 |
mridge | 06925cd | 2003-07-08 18:05:01 +0000 | [diff] [blame] | 134 | if [ $? != 0 ] |
| 135 | then |
| 136 | rm -rf isofs.iso $MNT_POINT |
mreed10 | 8d0bf1f | 2005-08-02 18:28:42 +0000 | [diff] [blame] | 137 | echo "FAILED: mkisofs -o isofs.iso $mkisofs_opt $MAKE_FILE_SYS_DIR failed" |
mridge | 06925cd | 2003-07-08 18:05:01 +0000 | [diff] [blame] | 138 | 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" \ |
mridge | 06925cd | 2003-07-08 18:05:01 +0000 | [diff] [blame] | 150 | "loop,block=512,unhide,session=2" |
| 151 | # "loop,sbsector=32" |
| 152 | do |
mridge | a64d322 | 2004-02-06 16:00:20 +0000 | [diff] [blame] | 153 | echo "Running mount -o $mount_opt isofs.iso $MNT_POINT Command" |
mridge | 06925cd | 2003-07-08 18:05:01 +0000 | [diff] [blame] | 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 |
| 160 | fi |
mridge | a64d322 | 2004-02-06 16:00:20 +0000 | [diff] [blame] | 161 | echo "Running ls -lR $MNT_POINT Command" |
| 162 | ls -lR $MNT_POINT |
mridge | 06925cd | 2003-07-08 18:05:01 +0000 | [diff] [blame] | 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 |
| 169 | |
| 170 | ####################################################### |
| 171 | # |
| 172 | # Just before exit, perform the cleanup. |
| 173 | # |
| 174 | ####################################################### |
| 175 | |
mreed10 | 8d0bf1f | 2005-08-02 18:28:42 +0000 | [diff] [blame] | 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 |
| 182 | fi |
| 183 | |
| 184 | |
mridge | 06925cd | 2003-07-08 18:05:01 +0000 | [diff] [blame] | 185 | echo "PASSED: $0 passed!" |
| 186 | exit 0 |