From 565a1631030e51661bf4bb5938244a9ff8972e1d Mon Sep 17 00:00:00 2001 From: Erez_Zadok Date: Wed, 11 Jul 2007 21:57:00 -0400 Subject: [PATCH] support cramfs mounts Somewhat complicated: we have to build the regular directory and file hierarchy using ext2, then generate a cramfs image and loopback mount it, and all inside the tests themselves. So support for cramfs (and similar special file systems) has to be built into the scaffold lower-level routines. Also: in the havechattr test, if "touch" on the branch failed, assume that there's no chatter support (or that it can't be used, e.g., in a readonly file system). Finally, don't show stderr messages in havechattr. --- scaffold | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/scaffold b/scaffold index a0e1318..4237282 100644 --- a/scaffold +++ b/scaffold @@ -22,17 +22,17 @@ function havechattr { 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 } @@ -125,6 +125,44 @@ function create_hierarchy { 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-$$ @@ -134,6 +172,11 @@ function check_hierarchy { } 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 @@ -165,6 +208,12 @@ function mount_union { 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)) -- 2.43.0