overlay: Lift add implementation to overlay_add()
Isolate the functionality to improve readability
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I1f0abdd33291aa14f53c0220fb5c714b181acb97
diff --git a/overlay/overlay b/overlay/overlay
index 2400b9f..f01f8b4 100755
--- a/overlay/overlay
+++ b/overlay/overlay
@@ -14,6 +14,13 @@
cut -d= -f2
}
+overlay_add() {
+ o_lowerdir="$1"
+ o_upperdir=$(mktemp -d)
+ o_workdir=$(mktemp -d)
+ mount -t overlay -o lowerdir="${o_lowerdir}",upperdir=${o_upperdir},workdir=${o_workdir} overlay "${o_lowerdir}"
+}
+
if [ $# -lt 2 ]
then
cat $0
@@ -22,10 +29,7 @@
case $1 in
add)
- o_lowerdir="$2"
- o_upperdir=$(mktemp -d)
- o_workdir=$(mktemp -d)
- mount -t overlay -o lowerdir="${o_lowerdir}",upperdir=${o_upperdir},workdir=${o_workdir} overlay "${o_lowerdir}"
+ overlay_add $2
;;
remove)
o_lowerdir="$2"