diff options
author | Milton Miller <miltonm@us.ibm.com> | 2016-05-23 18:22:11 -0500 |
---|---|---|
committer | Milton Miller <miltonm@us.ibm.com> | 2016-06-30 14:46:43 -0500 |
commit | bfb33b53d01b3e3db2e2b52b2bff622367c08804 (patch) | |
tree | 32d132392b2c11004230d6988f216a48e7bf068b /meta-phosphor | |
parent | aa42dfda27582483ccf907720d4bb2e386b6d761 (diff) | |
download | talos-openbmc-bfb33b53d01b3e3db2e2b52b2bff622367c08804.tar.gz talos-openbmc-bfb33b53d01b3e3db2e2b52b2bff622367c08804.zip |
initfs: update: add check for image size vs mtd size
The flashcp command will check the file size vs the partition size,
so add a check when looking at images.
Use stat -L -c "%s" to get the file size, and compare it to the mtd
size from the sysfs size attribute.
If this check is suppressed the enforcement is left to flashcp.
Signed-off-by: Milton Miller <miltonm@us.ibm.com>
Diffstat (limited to 'meta-phosphor')
-rwxr-xr-x | meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh index 9d3c81276..fa46635a5 100755 --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh @@ -52,6 +52,14 @@ childmtds() { done } +toobig() { + if test $(stat -L -c "%s" "$1") -gt $(cat /sys/class/mtd/"$2"/size) + then + return 0 + fi + return 1 +} + findmtd() { m=$(grep -xl "$1" /sys/class/mtd/*/name) m=${m%/name} @@ -89,6 +97,7 @@ doclean= dosave=y dorestore=y toram= +checksize=y checkmount=y whitelist=/run/initramfs/whitelist @@ -118,6 +127,9 @@ do --no-flash) doflash= shift ;; + --ignore-size) + checksize= + shift ;; --ignore-mount) checkmount= doflash= @@ -165,6 +177,11 @@ do echoerr "Unable to find mtd partiton for ${f##*/}." exit 1 fi + if test -n "$checksize" && toobig "$f" "$m" + then + echoerr "Image ${f##*/} too big for $m." + exit 1 + fi for s in $m $(childmtds $m) do if test -n "$checkmount" && mtdismounted $s |