1#!/bin/sh 2 3# expected sha1sum of the FS image 4expect=98bcafa04cb1eb75b7add6c95eb587c37f5050e0 5 6set -e 7 8# ownership matters for the proto file. 9# the run script runs us with user "bin" (3), group "bin" (7). 10if [ "`id -u`" != 3 -o "`id -g`" != 7 ] 11then 12 echo "test script should be run with uid 3, gid 7." 13 exit 1 14fi 15 16echo -n "mfs test " 17 18testdir=fstest 19protofile=proto 20fsimage=fsimage 21rm -rf $testdir $protofile $fsimage 22 23if [ -d $testdir ] 24then 25 echo "dir?" 26 exit 1 27fi 28 29mkdir -p $testdir $testdir/contents $testdir/modes 30 31if [ ! -d $testdir ] 32then 33 echo "no dir?" 34 exit 1 35fi 36 37# Make some small & big & bigger files 38 39prevf=$testdir/contents/file 40echo "Test contents 123" >$prevf 41for double in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 42do fn=$testdir/contents/fn.$double 43 cat $prevf $prevf >$fn 44 prevf=$fn 45done 46 47# Make some files with various modes & mtimes 48 49for many in 0 1 2 3 4 5 6 7 8 9 50do for m1 in 0 1 2 3 4 5 6 7 51 do for m2 in 0 1 2 3 4 5 6 7 52 do for m3 in 0 1 2 3 4 5 6 7 53 do 54 mode=${m1}${m2}${m3} 55 fn=$testdir/modes/m${mode}${many} 56 echo "$many $m1 $m2 $m3 $mode" > $fn 57 chmod $mode $fn 58 done 59 done 60 done 61done 62 63# Make an MFS filesystem image out of it 64 65BS=4096 66BLOCKS=15000 67INODES=6000 68dd if=/dev/zero seek=$BLOCKS of=$fsimage count=1 bs=$BS >/dev/null 2>&1 69 70# -s keeps modes 71/usr/sbin/mkproto -s -b $BLOCKS -i $INODES $testdir >$protofile 72 73/sbin/mkfs.mfs -T 1 -b $BLOCKS -i $INODES $fsimage $protofile >/dev/null 2>&1 74sum="`sha1 $fsimage | awk '{ print $4 }'`" 75 76rm -rf $testdir $protofile $fsimage 77 78if [ $sum != $expect ] 79then 80 echo sum $sum is not expected $expect 81 exit 1 82fi 83 84echo ok 85 86exit 0 87 88