if [ ! -d $1 ] ; then
return 1
fi
- touch $1/$FILE
- if ! chattr +i $1/$FILE >/dev/null 2>&1 ; then
+ touch $1/$FILE 2> /dev/null || return 1
+ if ! chattr +i $1/$FILE > /dev/null 2>&1 ; then
rm -f $1/$FILE
return 1
fi
if (echo "Hello World" > $1/$FILE) >/dev/null 2>&1 ; then
- chattr -i $1/$FILE >/dev/null 2>&1
+ chattr -i $1/$FILE > /dev/null 2>&1
rm -f $1/$FILE
return 1
fi
- chattr -i $1/$FILE
+ chattr -i $1/$FILE > /dev/null 2>&1
rm -f $1/$FILE
return 0
}
done
}
+function runcmd
+{
+ $@
+ sleep ${delay:-0.5}
+ ret=$?
+ if test $ret -ne 0 ; then exit $ret ; fi
+}
+
+# mount helper for compressed rom/ram file systems such as cramfs and
+# squashfs.
+export CRAMFS_BRANCHES
+function cramit {
+ CRAMFS_BRANCHES=""
+ fs=$1
+ shift
+ for n in "$@" ; do
+ case "$n" in
+ *=ro )
+ dir=`echo $n | sed 's/=ro//g'`
+ i=`echo $n | tr -dc '[0-9]'`
+ dev=$(eval echo \$DEV$i)
+ echo -n "${fs}@${dev} "
+ tmpimg=/tmp/$fs.img.$i
+ runcmd mkfs -t $fs /n/lower/b$i $tmpimg
+ runcmd mount -t $fs -o loop $tmpimg /n/lower/b$i
+ CRAMFS_BRANCHES="$CRAMFS_BRANCHES $i"
+ ;;
+ esac
+ done
+}
+
+# cleanup for compressed rom/ram file systems such as cramfs and squashfs.
+function uncramit {
+ for i in $CRAMFS_BRANCHES ; do
+ runcmd umount /n/lower/b$i
+ done
+}
+
function check_hierarchy {
( find $1 -type d -printf 'd %p\n' ; find $1 -type f -printf 'f %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-$$
}
function mount_union {
+ # support compressed ram/rom file systems
+ if test -n "$SPECIAL_FS" ; then
+ cramit $SPECIAL_FS $*
+ fi
+
if [ "$MOUNTS" -gt 0 ] ; then
echo "There is already an outstanding mount!" 1>&2
exit 1
function unmount_union {
umount $MOUNTPOINT
+
+ # support compressed ram/rom file systems
+ if test -n "$CRAMFS_BRANCHES" ; then
+ uncramit
+ fi
+
ERR=$?
if [ "$?" -eq "0" ] ; then
MOUNTS=$((MOUNTS - 1))