mmc: Add staging directory

Add a staging directory for PLDM to use as a temporary
holding space during inband update where the host would
send individual image files and PLDM needs to reconstruct
the code update tarball before calling the BMC updater
to do an update.

Clear the directory after a successful update. This cleanup
will eventually be handled by PLDM.

Tested: New directory and symlink created.

Change-Id: I9a2eacb0f57696e799e983625c2a32efbe122e89
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/vpnor/obmc-vpnor-util b/vpnor/obmc-vpnor-util
index 30854bf..a2a6586 100644
--- a/vpnor/obmc-vpnor-util
+++ b/vpnor/obmc-vpnor-util
@@ -49,8 +49,10 @@
   MMC_RO_PATH="${MMC_BASE_PATH}/running-ro"
   MMC_RUNNING_PATH="${MMC_BASE_PATH}/running"
   MMC_ALTERNATE_PATH="${MMC_BASE_PATH}/alternate"
+  MMC_STAGING_PATH="${MMC_BASE_PATH}/staging"
   HOSTFW_RUNNING_PATH="${HOSTFW_ACTIVE_PATH}/running"
   HOSTFW_ALTERNATE_PATH="${HOSTFW_ACTIVE_PATH}/alternate"
+  HOSTFW_STAGING_PATH="${HOSTFW_ACTIVE_PATH}/staging"
 
   # Get a list of all active PNOR versions
   data="$(ls -d ${PNOR_RO_PREFIX}* 2>/dev/null)"
@@ -96,6 +98,10 @@
           rm -f ${HOSTFW_ALTERNATE_PATH}
           ln -sfv ${MMC_ALTERNATE_PATH} ${HOSTFW_ALTERNATE_PATH}
       fi
+      if [[ $(readlink -f "${HOSTFW_STAGING_PATH}") != ${MMC_STAGING_PATH} ]]; then
+          rm -f ${HOSTFW_STAGING_PATH}
+          ln -sfv ${MMC_STAGING_PATH} ${HOSTFW_STAGING_PATH}
+      fi
   fi
 
   if [ ! -d "${PNOR_ACTIVE_PATH}" ]; then