return $ERR
}
+# Initialize the ODF. Does the following:
+# Creates and mounts ODF_DEV
+# Populates ODF_DIR with the required dirs (fill_odf)
+# Creates the superblock(sb) for ODF using the branch config passed in
function init_odf {
- # Noop for Non ODF unionfs
+ # Do nothing for Non ODF unionfs
if [ $ODF -eq 0 ]; then
return
fi
exit 1
fi
- if [ -z "$1" ] ; then
- OPTION="dirs="
- else
- if [ -z "$2" ] ; then
- OPTION="$1"
- else
- OPTION="$1,dirs="
+ if [ $ODF -eq 1 ]; then
+ OPTION="odf=$ODF_DIR"
+ if [ ! -e $ODF_DIR/sb ]; then
+ OPTION=$OPTION",dirs="
fi
- fi
+ else
+ OPTION="dirs="
+ fi
+
+ if [ -n "$1" ]; then
+ OPTION=$1","$OPTION
+ fi
shift
- while [ "$#" -gt 0 ]
- do
- OPTION="$OPTION$1"
- if [ "$#" -ne "1" ] ; then
- OPTION="$OPTION"":"
- fi
- shift
- done
+ if [ $ODF -eq 0 ] || [ ! -e $ODF_DIR/sb ]; then
+ while [ "$#" -gt 0 ]
+ do
+ OPTION="$OPTION$1"
+ if [ "$#" -ne "1" ] ; then
+ OPTION="$OPTION"":"
+ fi
+ shift
+ done
+ fi
mount -t unionfs -o $OPTION none $MOUNTPOINT
function discard_odf
{
+ if [ $ODF -eq 0 ]; then
+ return
+ fi
runcmd umount $ODF_DIR
runcmd losetup -d $ODF_DEV