}
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
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
}
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
}
}
-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'
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