Changeset 32465


Ignore:
Timestamp:
2012-06-20T00:36:53+02:00 (6 years ago)
Author:
acinonyx
Message:

[x86] Fix sysupgrade for squashfs, jffs2 and ext4 images

  • use 'fsync' with 'dd' for image writing
  • save config to boot partition
Location:
trunk/target/linux/x86/base-files/lib
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/target/linux/x86/base-files/lib/upgrade/platform.sh

    r20703 r32465  
    11USE_REFRESH=1 
     2 
     3x86_get_rootfs() { 
     4        local rootfsdev 
     5        local rootfstype 
     6         
     7        rootfstype="$(awk 'BEGIN { RS=" "; FS="="; } ($1 == "rootfstype") { print $2 }' < /proc/cmdline)" 
     8        case "$rootfstype" in 
     9                squashfs|jffs2) 
     10                        rootfsdev="$(awk 'BEGIN { RS=" "; FS="="; } ($1 == "block2mtd.block2mtd") { print substr($2,1,index($2, ",")-1) }' < /proc/cmdline)";; 
     11                ext4) 
     12                        rootfsdev="$(awk 'BEGIN { RS=" "; FS="="; } ($1 == "root") { print $2 }' < /proc/cmdline)";; 
     13        esac 
     14                 
     15        echo "$rootfstype:$rootfsdev" 
     16} 
    217 
    318platform_check_image() { 
     
    1328} 
    1429 
    15 platform_do_upgrade() { 
    16         local ROOTFS 
    17         sync 
    18         grep -q -e "jffs2" -e "squashfs" /proc/cmdline \ 
    19                 && ROOTFS="$(awk 'BEGIN { RS=" "; FS="="; } ($1 == "block2mtd.block2mtd") { print substr($2,1,index($2, ",")-1) }' < /proc/cmdline)" \ 
    20                 || ROOTFS="$(awk 'BEGIN { RS=" "; FS="="; } ($1 == "root") { print $2 }' < /proc/cmdline)" 
    21         [ -b ${ROOTFS%[0-9]} ] && get_image "$1" > ${ROOTFS%[0-9]} 
     30platform_refresh_partitions() { 
     31        return 0 
    2232} 
    2333 
    24 x86_prepare_ext2() { 
    25         # if we're running from ext2, we need to make sure that we have a mtd  
    26         # partition that points to the active rootfs partition. 
    27         # however this only matters if we actually need to preserve the config files 
    28         [ "$SAVE_CONFIG" -eq 1 ] || return 0 
    29         grep rootfs /proc/mtd >/dev/null || { 
    30                 echo /dev/hda2,65536,rootfs > /sys/module/block2mtd/parameters/block2mtd 
    31         } 
     34platform_copy_config() { 
     35        local rootfs="$(x86_get_rootfs)" 
     36        local rootfsdev="${rootfs##*:}" 
     37         
     38        mount -t ext4 -o rw,noatime "${rootfsdev%[0-9]}1" /mnt 
     39        cp -af "$CONF_TAR" /mnt/ 
     40        umount /mnt 
    3241} 
    33 append sysupgrade_pre_upgrade x86_prepare_ext2 
     42 
     43platform_do_upgrade() { 
     44        local rootfs="$(x86_get_rootfs)" 
     45        local rootfsdev="${rootfs##*:}" 
     46 
     47        sync 
     48        [ -b ${rootfsdev%[0-9]} ] && get_image "$@" | dd of=${rootfsdev%[0-9]} bs=4096 conv=fsync 
     49        sleep 1 
     50} 
Note: See TracChangeset for help on using the changeset viewer.