Make discard_odf a no-op for non odf
authorRachita Kothiyal <rachita@dewey.fsl.cs.sunysb.edu>
Sun, 14 Oct 2007 18:25:09 +0000 (14:25 -0400)
committerRachita Kothiyal <rachita@dewey.fsl.cs.sunysb.edu>
Sun, 14 Oct 2007 18:25:09 +0000 (14:25 -0400)
scaffold

index c43afe7a09c5f5584e99704e24a85e54b19237d8..321673f606bb39fe141bdcbb681f5d570d922561 100644 (file)
--- a/scaffold
+++ b/scaffold
@@ -212,8 +212,12 @@ function check_hierarchy {
         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
@@ -272,26 +276,31 @@ function mount_union {
                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
 
@@ -302,6 +311,9 @@ function mount_union {
 
 function discard_odf
 {
+       if [ $ODF -eq 0 ]; then
+               return
+       fi
        runcmd umount $ODF_DIR
        runcmd losetup -d $ODF_DEV