1174294Sobrien#!/bin/sh 2174294Sobrien# Script to test the attribute cache behavior of the local OS client. 3174294Sobrien# If this script fails, it means that Amd cannot turn off the attrcache 4174294Sobrien# reliably on this host, and Amd therefore may not run reliably. See 5174294Sobrien# the README.attrcache file distributed with this am-utils. 6174294Sobrien# -Erez Zadok, September 29, 2005 7174294Sobrien 8174294Sobrien# set PATH (must install am-utils first) 9174294Sobrienprefix=@prefix@ 10174294Sobrienexec_prefix=@exec_prefix@ 11174294SobrienPATH=@sbindir@:@bindir@:/usr/ucb:/usr/bin:/bin:${PATH} 12174294Sobrienexport PATH 13174294Sobrien 14174294Sobrien# test if amd is running 15174294Sobrienamq -p > /dev/null 2>&1 16174294Sobrienif test $? = 0 17174294Sobrienthen 18174294Sobrien echo "### Amd already running... please shutdown Amd first" 19174294Sobrien exit 1 20174294Sobrienfi 21174294Sobrien 22174294Sobrienmapfile="/tmp/amd.testmap.$$" 23174294Sobrienlogfile="/var/log/amd" 24174294Sobriendelay=1 25174294Sobriena=/a 26174294Sobrien 27174294SobrienCreateMap1 () { 28174294Sobrien echo "### Creating correct map" 29174294Sobrien cat - >$mapfile <<EOF 30174294Sobriena type:=link;fs:=/tmp/a 31174294SobrienEOF 32174294Sobrien} 33174294Sobrien 34174294SobrienCreateMap2 () { 35174294Sobrien echo "### Creating weird map" 36174294Sobrien cat - >$mapfile <<EOF 37174294Sobriena type:=link;fs:=/tmp/b 38174294SobrienEOF 39174294Sobrien} 40174294Sobrien 41174294SobrienStopAMD () { 42174294Sobrien ctl-amd stop 43174294Sobrien# do not delete files we may need to use to debug Amd 44174294Sobrien# rm -f /tmp/a /tmp/b $mapfile $logfile 45174294Sobrien} 46174294Sobrien 47174294Sobrientouch /tmp/a 48174294Sobrientouch /tmp/b 49174294Sobrien 50174294SobrienCreateMap1 51174294Sobrienecho amd -x all -D all -r -l $logfile $a $mapfile -cache:=mapdefault,sync 52174294Sobrienamd -x all -D all -r -l $logfile $a $mapfile -cache:=mapdefault,sync 53174294Sobriensleep 3 # give amd chance to start properly 54174294Sobrienamq 55174294Sobrieninode_a=`ls -lLi /tmp/a | awk '{print $1}'` 56174294Sobrieninode_b=`ls -lLi /tmp/b | awk '{print $1}'` 57174294Sobrienls -lLi $a/a 58174294Sobrienls -lLi $a/b 59174294Sobrienls -l $mapfile 60174294Sobrien 61174294Sobrien# how many times to try until we call it a success... 62174294Sobrienmaxtry=10 63174294Sobrienwhile test $maxtry -gt 0 64174294Sobriendo 65174294Sobrien echo "$maxtry tries left ..." 66174294Sobrien let maxtry=maxtry-1 67174294Sobrien amq 68174294Sobrien CreateMap1 69174294Sobrien sleep $delay 70174294Sobrien 71174294Sobrien ls -l $mapfile 72174294Sobrien echo "### looking at a... should get a" 73174294Sobrien ino=`ls -lLi $a/a | awk '{print $1}'` 74174294Sobrien if test -z "$ino" 75174294Sobrien then 76174294Sobrien ls -li $a/a 77174294Sobrien amq 78174294Sobrien amq -m 79174294Sobrien stat $a 80174294Sobrien echo "a link does not exist!" 81174294Sobrien StopAMD 82174294Sobrien exit 1 83174294Sobrien fi 84174294Sobrien if test $ino -ne $inode_a 85174294Sobrien then 86174294Sobrien ls -li $a/a 87174294Sobrien amq 88174294Sobrien amq -m 89174294Sobrien stat $a 90174294Sobrien echo "a link does not point to A!" 91174294Sobrien StopAMD 92174294Sobrien exit 1 93174294Sobrien fi 94174294Sobrien 95174294Sobrien# Here is the main trick we try: force amd to flush one entry, then 96174294Sobrien# change the amd map on disk, and then see if the kernel will have 97174294Sobrien# flushed the attribute cache; if it did, then Amd will see the 98174294Sobrien# correctly changed map entry. 99174294Sobrien 100174294Sobrien amq -u $a/a 101174294Sobrien sleep $delay 102174294Sobrien stat $a 103174294Sobrien 104174294Sobrien CreateMap2 105174294Sobrien sleep $delay 106174294Sobrien 107174294Sobrien ls -l $mapfile 108174294Sobrien echo "### looking at a... should get b" 109174294Sobrien ino=`ls -lLi $a/a | awk '{print $1}'` 110174294Sobrien if test -z "$ino" 111174294Sobrien then 112174294Sobrien ls -li $a/a 113174294Sobrien amq 114174294Sobrien amq -m 115174294Sobrien stat $a 116174294Sobrien echo "a link does not exist!" 117174294Sobrien StopAMD 118174294Sobrien exit 1 119174294Sobrien fi 120174294Sobrien if test $ino -ne $inode_b 121174294Sobrien then 122174294Sobrien ls -li $a/a 123174294Sobrien amq 124174294Sobrien amq -m 125174294Sobrien stat $a 126174294Sobrien echo "a link does not point to B!" 127174294Sobrien StopAMD 128174294Sobrien exit 1 129174294Sobrien fi 130174294Sobrien 131174294Sobrien amq -u $a/a 132174294Sobrien sleep $delay 133174294Sobrien stat $a 134174294Sobriendone 135174294SobrienStopAMD 136