mmc: Copy only LID files during update
This is one step closer in replacing the PNOR partition files with LID
files:
- During an update, only copy LID files to the read-write directory. The
update-bios-attr-table service will create symlinks from PNOR
partition files to LID files.
- Use the pnor.toc from the read-only directory to get the list of
preserved partitions, since there won't be a pnor.toc file in the
read-write directory anymore. A future commit will read the PLDM file
table to determine which LID files to preserve.
- Preserve the symlink target (LID file) instead of the symlink name
(partition file name), otherwise the symlink gets broken if we copy a
file that was a symlink.
Tested: Verified after code update that all the partition files were
symlinks to a LID file, and a subsequent update preserved the LID files
that correspond to the preserved partitions.
Change-Id: I3fbe3de5a910d85c299ed7e5a535198283bd3f9a
diff --git a/mmc/obmc-flash-bios b/mmc/obmc-flash-bios
index 8bd8ca7..60490b2 100644
--- a/mmc/obmc-flash-bios
+++ b/mmc/obmc-flash-bios
@@ -38,18 +38,22 @@
# A line in the pnor.toc looks like this:
# partition05=SECBOOT,0x00381000,0x003a5000,00,ECC,PRESERVED
rm -f ${prsv_dir}/*
- if [ -f ${running_dir}/pnor.toc ]; then
- prsvs=$(grep PRESERVED ${running_dir}/pnor.toc)
+ if [ -f ${ro_dir}/pnor.toc ]; then
+ prsvs=$(grep PRESERVED ${ro_dir}/pnor.toc)
for prsv in ${prsvs}; do
prsv=${prsv##partition*=}
prsv=$(echo "${prsv}" | cut -d "," -f 1)
- cp -p ${running_dir}/"${prsv}" ${prsv_dir}
+ if [ -L "${running_dir}/${prsv}" ]; then
+ # Preserve the symlink target file
+ prsv="$(readlink "${running_dir}/${prsv}")"
+ cp -p ${running_dir}/"${prsv}" ${prsv_dir}
+ fi
done
fi
- # Copy contents of running image to running dir
+ # Copy lid contents of running image to running dir
rm -f ${running_dir}/*
- cp -p ${ro_dir}/* ${running_dir}/
+ cp -p ${ro_dir}/*.lid ${running_dir}/
# Restore the preserved partitions. Ignore error, there may be none.
cp -p ${prsv_dir}/* ${running_dir}/ 2>/dev/null || true