Ensure No Unnecessary Errors During Code Update

This commit fixes the problem of partitions that have
either been deleted or had their name changed. The partitions
are only preserved if they exist in both the running and
read only directories, otherwise, they are skipped and the
error is not triggered.

Tested:
Performed code update and verified that there were no errors
called.

Signed-off-by: Zami Seck <zimzam17@gmail.com>
Change-Id: I11288c4120247b443d4ddd61db34f723abf041c1
diff --git a/mmc/obmc-flash-bios b/mmc/obmc-flash-bios
index 88ad6d1..988d9df 100644
--- a/mmc/obmc-flash-bios
+++ b/mmc/obmc-flash-bios
@@ -66,25 +66,27 @@
         if [ -L "${running_dir}/${prsv}" ]; then
           # Preserve the symlink target file
           prsv="$(readlink "${running_dir}/${prsv}")"
-          runsize="$(stat -c '%s' "${running_dir}/${prsv}")"
-          rosize="$(stat -c '%s' "${ro_dir}/${prsv}")"
-          if [ "$runsize" != "$rosize" ]; then
-              # Partition size may have changed or became corrupted
-              # So it will not be copied to the preserved directory
-              # Log PEL to indicate such
-              busctl call xyz.openbmc_project.Logging \
-              /xyz/openbmc_project/logging \
-              xyz.openbmc_project.Logging.Create Create "ssa{ss}" \
-              xyz.openbmc_project.Software.Version.Error.HostFile \
-              xyz.openbmc_project.Logging.Entry.Level.Error 3 "FILE_NAME" \
-              "${prsv}" "CURRENT_FILE_SIZE" "${runsize}" "EXPECTED_FILE_SIZE" \
-              "${rosize}"
-              # Initiate dump
-              busctl call xyz.openbmc_project.Dump.Manager \
-              /xyz/openbmc_project/dump/bmc xyz.openbmc_project.Dump.Create \
-              CreateDump "a{sv}" 0
-          else
-              cp -p ${running_dir}/"${prsv}" ${prsv_dir}
+          if [ -f "${running_dir}/${prsv}" ] && [ -f "${ro_dir}/${prsv}" ]; then
+            runsize="$(stat -c '%s' "${running_dir}/${prsv}")"
+            rosize="$(stat -c '%s' "${ro_dir}/${prsv}")"
+            if [ "$runsize" != "$rosize" ]; then
+                # Partition size may have changed or became corrupted
+                # So it will not be copied to the preserved directory
+                # Log PEL to indicate such
+                busctl call xyz.openbmc_project.Logging \
+                /xyz/openbmc_project/logging \
+                xyz.openbmc_project.Logging.Create Create "ssa{ss}" \
+                xyz.openbmc_project.Software.Version.Error.HostFile \
+                xyz.openbmc_project.Logging.Entry.Level.Error 3 "FILE_NAME" \
+                "${prsv}" "CURRENT_FILE_SIZE" "${runsize}" "EXPECTED_FILE_SIZE" \
+                "${rosize}"
+                # Initiate dump
+                busctl call xyz.openbmc_project.Dump.Manager \
+                /xyz/openbmc_project/dump/bmc xyz.openbmc_project.Dump.Create \
+                CreateDump "a{sv}" 0
+            else
+                cp -p ${running_dir}/"${prsv}" ${prsv_dir}
+            fi
           fi
         fi
       done