openpower-software-manager: Move ubimount.service logic to script
The service files that manage the pnor ubi volumes and mount points are
starting to get too much logic in them. Move the logic to a shell script.
Change-Id: I57d6ff7ffb32d24704ceec77afd1d07622bc6de8
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios
index cab5f86..2b83947 100644
--- a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios
+++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios
@@ -80,6 +80,29 @@
fi
}
+mount_ubi() {
+ pnormtd="$(findmtd pnor)"
+ pnor="${pnormtd#mtd}"
+ ubidev="/dev/ubi${pnor}"
+ mountdir="/media/${name}"
+
+ if [ ! -d "${mountdir}" ]; then
+ mkdir "${mountdir}"
+ fi
+
+ # Create a dynamic ubi volume of initial arbitrary size 1MB,
+ # the volume will grow dynamically as needed
+ vol="$(findubi "${name}")"
+ if [ -z "${vol}" ]; then
+ ubimkvol "${ubidev}" -N "${name}" -s 1MiB
+ fi
+
+ if ! is_mounted "${name}"; then
+ mountdev="ubi${pnor}:${name}"
+ mount -t ubifs "${mountdev}" "${mountdir}"
+ fi
+}
+
case "$1" in
ubiattach)
attach_ubi
@@ -89,6 +112,10 @@
version="$3"
mount_squashfs
;;
+ ubimount)
+ name="$2"
+ mount_ubi
+ ;;
*)
echo "Invalid argument"
exit 1
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-ubimount@.service b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-ubimount@.service
index a2147ea..ee63282 100644
--- a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-ubimount@.service
+++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-ubimount@.service
@@ -6,18 +6,5 @@
[Service]
Type=oneshot
RemainAfterExit=no
-ExecStart=/bin/sh -c 'rw=pnor-rw-%i; \
- if [ ! -d "/media/$rw" ]; then \
- mkdir /media/$rw; fi; \
- if [ ! -d "/media/pnor-prsv" ]; then \
- mkdir /media/pnor-prsv; fi; \
- rw_ubi=`ubinfo -d 0 -a | grep $rw`; \
- if [ -z "$rw_ubi" ]; then \
- {sbindir}/ubimkvol /dev/ubi0 -N $rw -s 1MiB; fi; \
- prsv_ubi=`ubinfo -d 0 -a | grep pnor-prsv`; \
- if [ -z "$prsv_ubi" ]; then \
- {sbindir}/ubimkvol /dev/ubi0 -N pnor-prsv -s 1MiB; fi; \
- if ! grep -q $rw /proc/mounts; then \
- mount -t ubifs ubi0:$rw /media/$rw; fi; \
- if ! grep -q pnor-prsv /proc/mounts; then \
- mount -t ubifs ubi0:pnor-prsv /media/pnor-prsv; fi;'
+ExecStart={sbindir}/obmc-flash-bios ubimount pnor-rw-%i
+ExecStart={sbindir}/obmc-flash-bios ubimount pnor-prsv