Last leg of infrastructure patches.
authorRachita Kothiyal <rachita@vm2.fsl.cs.sunysb.edu>
Mon, 15 Oct 2007 19:06:54 +0000 (15:06 -0400)
committerRachita Kothiyal <rachita@vm2.fsl.cs.sunysb.edu>
Mon, 15 Oct 2007 19:06:54 +0000 (15:06 -0400)
1)Removed POPULATE_ODF
2)Made check hierarchy ODF whiteout aware
3)t-lookup.sh is now ready

scaffold
t-lookup.sh

index 321673f606bb39fe141bdcbb681f5d570d922561..21645119212287c380891468c89d364ac694bf94 100644 (file)
--- a/scaffold
+++ b/scaffold
@@ -39,17 +39,15 @@ function havechattr {
 }
 
 function create_hierarchy {
-       if [ "$POPULATE_ODF" -eq "0" ]; then
-               havechattr $LOWER_DIR0 && chattr -R -i $LOWER_DIR0
-               havechattr $LOWER_DIR1 && chattr -R -i $LOWER_DIR1
-               havechattr $LOWER_DIR2 && chattr -R -i $LOWER_DIR2
-               havechattr $LOWER_DIR3 && chattr -R -i $LOWER_DIR3
-
-               # delete all files, dirs, and hidden files below mount points
-               # (we cannot delete the mounted mountpoints themselves (EBUSY)
-               rm -fr $TOP_LOWER_DIR/b[0-3]/[a-zA-Z0-9_]*
-               rm -fr $TOP_LOWER_DIR/b[0-3]/.[a-zA-Z0-9_]*
-       fi
+       havechattr $LOWER_DIR0 && chattr -R -i $LOWER_DIR0
+       havechattr $LOWER_DIR1 && chattr -R -i $LOWER_DIR1
+       havechattr $LOWER_DIR2 && chattr -R -i $LOWER_DIR2
+       havechattr $LOWER_DIR3 && chattr -R -i $LOWER_DIR3
+
+       # delete all files, dirs, and hidden files below mount points
+       # (we cannot delete the mounted mountpoints themselves (EBUSY)
+       rm -fr $TOP_LOWER_DIR/b[0-3]/[a-zA-Z0-9_]*
+       rm -fr $TOP_LOWER_DIR/b[0-3]/.[a-zA-Z0-9_]*
 
         while read LINE
         do
@@ -118,11 +116,7 @@ function create_hierarchy {
                        if [ ! -z "$SOURCE" ] ; then
                                echo "Source file." > $NAME || exit $?
                        else
-                               if [ $POPULATE_ODF -eq 1 ]; then
-                                       touch $NAME || exit $?
-                               else
-                                       echo $NAME > $NAME || exit $?
-                               fi
+                               echo $NAME > $NAME || exit $?
                        fi
                 elif [ ! -z "$SYMLINK" ] ; then
                        ln -s "linktext:$NAME" $NAME
@@ -197,18 +191,46 @@ function uncramit {
 }
 
 function check_hierarchy {
+       for i in $*; do
         (
-           find $1 -type d -printf 'd %p\n'
-           find $1 -type f -links 1 -printf 'f %p\n'
-           find $1 -type f -links +1 -printf 'w %p\n'
-           find $1 -type b -printf 'b %p\n'
-           find $1 -type c -printf 'c %p\n'
-           find $1 -type l -printf 'l %p\n'
-       ) | sort > /tmp/check-$$
-
-        grep -v '^$' | sort | diff -u - /tmp/check-$$
+           if [ "$i" == $ODF_DIR ]; then
+                   find $i/ns/ -type f -samefile $ODF_DIR/whiteout | sed "s:$i/ns/:w $i/ns/ :g"  
+                   break
+           fi
+           find $i -type d -printf 'd %p\n'
+           find $i -type f -not -name ".wh.*" -printf 'f %p\n'
+           if [ $ODF -eq 0 ]; then
+                   find $i -type f -name ".wh.*" | sed "s:$i:w $i :g" | sed "s:\.wh\.::g"
+           fi
+           find $i -type b -printf 'b %p\n'
+           find $i -type c -printf 'c %p\n'
+           find $i -type l -printf 'l %p\n'
+       ) | sort >> /tmp/check-$$
+       done
+
+       # Test cases expect this
+       echo "d $TOP_LOWER_DIR" >> /tmp/check-$$
+       sort /tmp/check-$$ > /tmp/check-$$-tmp
+       mv /tmp/check-$$-tmp /tmp/check-$$
+
+       grep -v '^$' > /tmp/expected-$$
+       while read line ; do
+               first=`echo $line | cut -d" " -f 1`
+               if [ "$first" == "w" ]; then
+                       echo $line | sed "s: [a-zA-Z0-9\/\_\-]* : $ODF_DIR/ns/ :g" >> /tmp/expected-$$-tmp
+               else
+                       echo $line >> /tmp/expected-$$-tmp
+               fi
+        done < /tmp/expected-$$
+
+       sort /tmp/expected-$$-tmp > /tmp/expected-$$
+       rm /tmp/expected-$$-tmp
+
+       diff -u /tmp/expected-$$ /tmp/check-$$
+
         ERR=$?
         rm -f /tmp/check-$$
+        rm -f /tmp/expected-$$
         return $ERR
 }
 
index 8ae1b3099833f16b5411be98abcf86c414df0520..7e202794ebf63a18e0d8aa47c7f476cae83235af 100755 (executable)
@@ -44,21 +44,11 @@ FILES
 }
 
 
-if [ $ODF -eq 1 ]; then
-       POPULATE_ODF=0
-       setup_odf
-       fill_odf
-       ./progs/make_sb 3 $LOWER_DIR0 6 $LOWER_DIR1 6 $LOWER_DIR2 6 $LOWER_DIR3 6
-fi
+init_odf $TOP_LOWER_DIR/b?
 
 ( files ; beforefiles ) | create_hierarchy
 
-if [ $ODF -eq 1 ]; then
-       mount_union "odf=$ODF_DIR"
-       ls -lR $MOUNTPOINT >/dev/null
-else
-       mount_union "" $TOP_LOWER_DIR/b?
-fi
+mount_union "" $TOP_LOWER_DIR/b?
 
 checktype $MOUNTPOINT/a 'f'
 checktype $MOUNTPOINT/b 'd'
@@ -66,12 +56,8 @@ checktype $MOUNTPOINT/c '-'
 
 unmount_union
 
-if [ $ODF -eq 1 ]; then
-       files | check_hierarchy $TOP_LOWER_DIR
-       odf_afterfiles | check_hierarchy $ODF_DIR/ns
-       discard_odf
-else
-       ( files ; beforefiles ) | check_hierarchy $TOP_LOWER_DIR
-fi
+( files ; beforefiles ) | check_hierarchy $TOP_LOWER_DIR/b? $ODF_DIR
+
+discard_odf
 
 complete_test