obmc-initfs: use varables for paths and mount arguments
Create variables for all mount parameters and paths related to
the read-only and read-write mounts, including fs type, full
device name, and options. Reorder mount arguments to always
place options last.
Also add variables for update save directory and real init.
This allows easy testing of a file systems by changing a few
parameters including making the rofs an image in ram.
Signed-off-by: Milton Miller <miltonm@us.ibm.com>
diff --git a/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh b/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
index f83b1ad..32e83e6 100755
--- a/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
+++ b/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh
@@ -35,30 +35,35 @@
echo $m
}
-rofs=$(findmtd rofs)
rwfs=$(findmtd rwfs)
-rofst=squahsfs
+rwdev=/dev/mtdblock${rwfs#mtd}
rwfst=ext4
+rwopts=rw
+rorwopts=ro${rwopts#rw}
+
+rwdir=rw
+upper=$rwdir/cow
+save=save/${upper##*/}
if test -n "$rwfs" && test -s whitelist
then
- mkdir -p rw
- mount /dev/mtdblock${rwfs#mtd} rw -oro -t $rwfst
+ mkdir -p $rwdir
+ mount $rwdev $rwdir -t $rwfst -o $rorwopts
while read f
do
- if ! test -e rw/cow/$f
+ if ! test -e $upper/$f
then
continue
fi
- d="save/cow/$f"
+ d="$save/$f"
mkdir -p "${d%/*}"
- cp -rp rw/cow/$f "${d%/*}/"
+ cp -rp $upper/$f "${d%/*}/"
done < whitelist
- umount rw
+ umount $rwdir
fi
image=/run/initramfs/image-
@@ -67,7 +72,7 @@
m=$(findmtd ${f#$image})
if test -z "$m"
then
- echo 1>&2 "Unable to find mtd partiton for $f"
+ echo 1>&2 "Unable to find mtd partiton for ${f##*/}."
exec /bin/sh
fi
done
@@ -80,12 +85,11 @@
flashcp -v $f /dev/$m
done
-
-if test -d save/cow
+if test -d $save
then
- mount /dev/mtdblock${rwfs#mtd} rw -o rw -t $rwfst
- cp -rp save/cow/. rw/cow/
- umount rw
+ mount $rwdev $rwdir -t $rwfst -o $rwopts
+ cp -rp $save/. $upper/
+ umount $rwdir
fi
# Execute the command systemd told us to ...