bcm53xx: sysupgrade: check if new kernel fits partition size
authorRafał Miłecki <zajec5@gmail.com>
Tue, 21 Apr 2015 11:21:34 +0000 (11:21 +0000)
committerRafał Miłecki <zajec5@gmail.com>
Tue, 21 Apr 2015 11:21:34 +0000 (11:21 +0000)
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
SVN-Revision: 45547

target/linux/bcm53xx/base-files/lib/upgrade/platform.sh

index e53c2513d275d25b5b12493df9b55fc7b39d2737..88629549dc906171839d7aee2ce922f24e8e0c6c 100644 (file)
@@ -152,12 +152,17 @@ platform_pre_upgrade() {
                echo "Unable to find \"linux\" partition size"
                exit 1
        }
-       linux_length=$((0x$linux_length + 28))
+       linux_length=$((0x$linux_length))
+       local kernel_length=$(wc -c $dir/kernel | cut -d ' ' -f 1)
+       [ $kernel_length -gt $linux_length ] && {
+               echo "New kernel doesn't fit \"linux\" partition."
+               return
+       }
        rm -f /tmp/null.bin
        rm -f /tmp/kernel.trx
        touch /tmp/null.bin
        otrx create /tmp/kernel.trx \
-               -f $dir/kernel -b $linux_length \
+               -f $dir/kernel -b $(($linux_length + 28)) \
                -f /tmp/null.bin
 
        # Prepare UBI image (drop unwanted extra blocks)