From 59761f32c548fe67dc61c7dda927c4abfdb1eea2 Mon Sep 17 00:00:00 2001 From: Milton Miller Date: Thu, 9 Jun 2016 10:32:21 -0500 Subject: image_types_uboot: Don't truncate when assembling flash The generate_flash_image step was creating a file then using dd to fill in the pieces, but missed adding the conv=notrunc flag, so each step was shortening the file to its output. Add the forgotten conversion flag to each dd command. Signed-off-by: Milton Miller --- meta-phosphor/classes/obmc-phosphor-image_types_uboot.bbclass | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'meta-phosphor') diff --git a/meta-phosphor/classes/obmc-phosphor-image_types_uboot.bbclass b/meta-phosphor/classes/obmc-phosphor-image_types_uboot.bbclass index adb86e06d..67a389fbc 100644 --- a/meta-phosphor/classes/obmc-phosphor-image_types_uboot.bbclass +++ b/meta-phosphor/classes/obmc-phosphor-image_types_uboot.bbclass @@ -76,11 +76,11 @@ do_generate_flash() { dst="${ddir}/${FLASH_IMAGE_NAME}" rm -rf $dst mk_nor_image ${dst} ${FLASH_SIZE} - dd if=${ddir}/${uboot} of=${dst} bs=1k seek=${FLASH_UBOOT_OFFSET} - dd if=${ddir}/${kernel} of=${dst} bs=1k seek=${FLASH_KERNEL_OFFSET} - dd if=${ddir}/${uinitrd} of=${dst} bs=1k seek=${FLASH_INITRD_OFFSET} - dd if=${ddir}/${rootfs} of=${dst} bs=1k seek=${FLASH_ROFS_OFFSET} - dd if=${ddir}/${rwfs} of=${dst} bs=1k seek=${FLASH_RWFS_OFFSET} + dd if=${ddir}/${uboot} of=${dst} bs=1k conv=notrunc seek=${FLASH_UBOOT_OFFSET} + dd if=${ddir}/${kernel} of=${dst} bs=1k conv=notrunc seek=${FLASH_KERNEL_OFFSET} + dd if=${ddir}/${uinitrd} of=${dst} bs=1k conv=notrunc seek=${FLASH_INITRD_OFFSET} + dd if=${ddir}/${rootfs} of=${dst} bs=1k conv=notrunc seek=${FLASH_ROFS_OFFSET} + dd if=${ddir}/${rwfs} of=${dst} bs=1k conv=notrunc seek=${FLASH_RWFS_OFFSET} dstlink="${ddir}/${FLASH_IMAGE_LINK}" rm -rf $dstlink ln -sf ${FLASH_IMAGE_NAME} $dstlink -- cgit v1.2.1 From 01d37561a6ef969bfc0ce46f566954e8c8371dcf Mon Sep 17 00:00:00 2001 From: Milton Miller Date: Mon, 6 Jun 2016 18:17:44 -0500 Subject: initfs: Fix recipe, remove unnecessary class Because the recipe was named with trailing part init instead of initfs, the package didn't match the package name requiring PROVIDES, RPROVIDES and other bitbake workarounds. Fix the recipe name to match the package removing the overly verbose packaging. Signed-off-by: Milton Miller --- meta-phosphor/classes/obmc-phosphor-initfs.bbclass | 4 --- .../obmc-phosphor-initfs/obmc-phosphor-init.bb | 31 ---------------------- .../obmc-phosphor-initfs/obmc-phosphor-initfs.bb | 30 +++++++++++++++++++++ 3 files changed, 30 insertions(+), 35 deletions(-) delete mode 100644 meta-phosphor/classes/obmc-phosphor-initfs.bbclass delete mode 100644 meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/obmc-phosphor-init.bb create mode 100644 meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/obmc-phosphor-initfs.bb (limited to 'meta-phosphor') diff --git a/meta-phosphor/classes/obmc-phosphor-initfs.bbclass b/meta-phosphor/classes/obmc-phosphor-initfs.bbclass deleted file mode 100644 index de7923e82..000000000 --- a/meta-phosphor/classes/obmc-phosphor-initfs.bbclass +++ /dev/null @@ -1,4 +0,0 @@ -# Common code for recipes that implement Phosphor OpenBMC filesystem - -RPROVIDES_${PN} += "obmc-phosphor-initfs" -PROVIDES += "obmc-phosphor-initfs" diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/obmc-phosphor-init.bb b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/obmc-phosphor-init.bb deleted file mode 100644 index 3fa88c9e6..000000000 --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/obmc-phosphor-init.bb +++ /dev/null @@ -1,31 +0,0 @@ -SUMMARY = "Phosphor OpenBMC pre-init scripts" -DESCRIPTION = "Phosphor OpenBMC filesytem mount reference implementation." -PR = "r1" - -inherit obmc-phosphor-license -inherit obmc-phosphor-initfs - -S = "${WORKDIR}" -SRC_URI += "file://obmc-init.sh" -SRC_URI += "file://obmc-shutdown.sh" -SRC_URI += "file://obmc-update.sh" -SRC_URI += "file://whitelist" - -do_install() { - for f in init-download-url init-options - do - if test -e $f - then - install -m 0755 ${WORKDIR}/$f ${D}/$f - fi - done - install -m 0755 ${WORKDIR}/obmc-init.sh ${D}/init - install -m 0755 ${WORKDIR}/obmc-shutdown.sh ${D}/shutdown - install -m 0755 ${WORKDIR}/obmc-update.sh ${D}/update - install -m 0644 ${WORKDIR}/whitelist ${D}/whitelist - install -d ${D}/dev - mknod -m 622 ${D}/dev/console c 5 1 -} - -FILES_${PN} += " /init /shutdown /update /whitelist /dev " -FILES_${PN} += " /init-options /init-download-url " diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/obmc-phosphor-initfs.bb b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/obmc-phosphor-initfs.bb new file mode 100644 index 000000000..f81e21dd1 --- /dev/null +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/obmc-phosphor-initfs.bb @@ -0,0 +1,30 @@ +SUMMARY = "Phosphor OpenBMC pre-init scripts" +DESCRIPTION = "Phosphor OpenBMC filesytem mount reference implementation." +PR = "r1" + +inherit obmc-phosphor-license + +S = "${WORKDIR}" +SRC_URI += "file://obmc-init.sh" +SRC_URI += "file://obmc-shutdown.sh" +SRC_URI += "file://obmc-update.sh" +SRC_URI += "file://whitelist" + +do_install() { + for f in init-download-url init-options + do + if test -e $f + then + install -m 0755 ${WORKDIR}/$f ${D}/$f + fi + done + install -m 0755 ${WORKDIR}/obmc-init.sh ${D}/init + install -m 0755 ${WORKDIR}/obmc-shutdown.sh ${D}/shutdown + install -m 0755 ${WORKDIR}/obmc-update.sh ${D}/update + install -m 0644 ${WORKDIR}/whitelist ${D}/whitelist + install -d ${D}/dev + mknod -m 622 ${D}/dev/console c 5 1 +} + +FILES_${PN} += " /init /shutdown /update /whitelist /dev " +FILES_${PN} += " /init-options /init-download-url " -- cgit v1.2.1 From 089d5dfca72a7a4ae435d0329aee3a8fc1520a6e Mon Sep 17 00:00:00 2001 From: Milton Miller Date: Mon, 23 May 2016 18:44:30 -0500 Subject: initfs: shutdown: comment on update success Print an error from the shutdown script when the update fails. Update is changing to return codes when its preconditions are not met, so be more verbose about its success to provide a means to debug flash updates not occurring. We could add a sulogin or sushell but its not clear what would be desired here. If so the message should include "rmdir /oldroot to get a PID 1 shell" like /takever works in init. Signed-off-by: Milton Miller --- .../recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'meta-phosphor') diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh index 8d5d0c983..8d5c6726c 100644 --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-shutdown.sh @@ -44,6 +44,14 @@ then if test -x $update then $update --clean-saved-files + remaining=$(ls $image*) + if test -n "$remaining" + then + echo 1>&2 "Flash update failed to flash these images:" + echo 1>&2 "$remaining" + else + echo "Flash update completed." + fi else echo 1>&2 "Flash update requested but $update program missing!" fi -- cgit v1.2.1 From e1cbebebac683f1dad53c5037fc3524af5c1b7d0 Mon Sep 17 00:00:00 2001 From: Milton Miller Date: Mon, 23 May 2016 16:00:19 -0500 Subject: initfs: update: Don't exec sh or sulogin on error just exit 1 When update was written it was exec'd from the shutdown script and hence took over pid 1. Since exiting in that environment was a panic situation, the script instead started a rescue shell with its output presumably on the console. The calling convention was updated to be a simple invocation in commit dbacf104885c ("obmc-initfs: run update as a sub-script") but the error handling was not updated. That error handling is now becoming a hindrance to use from additional environments so change it. Signed-off-by: Milton Miller --- .../obmc-phosphor-initfs/files/obmc-update.sh | 23 ++++++---------------- 1 file changed, 6 insertions(+), 17 deletions(-) (limited to 'meta-phosphor') 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 aa8fd8934..f8e551cfd 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 @@ -2,9 +2,6 @@ echo update: "$@" -export PS1=update-sh#\ -# exec /bin/sh - cd / if ! test -r /proc/mounts || ! test -f /proc/mounts then @@ -21,12 +18,12 @@ then mkdir -p /dev mount -t devtmpfs dev dev fi -while grep mtd /proc/mounts -do + +if grep mtd /proc/mounts +then echo 1>&2 "Error: A mtd device is mounted." - sulogin - # exec /bin/sh -done + exit 1 +fi findmtd() { m=$(grep -xl "$1" /sys/class/mtd/*/name) @@ -130,7 +127,7 @@ do if test -z "$m" then echo 1>&2 "Unable to find mtd partiton for ${f##*/}." - exec /bin/sh + exit 1 fi done @@ -173,11 +170,3 @@ then fi exit - -# NOT REACHED without edit -# NOT REACHED without edit - -echo "Flash completed. Inspect, cleanup and reboot -f to continue." - -export PS1=update-sh#\ -exec /bin/sh -- cgit v1.2.1 From a67cc44670cd5234f8f66db623b7ccbc8d3e976a Mon Sep 17 00:00:00 2001 From: Milton Miller Date: Mon, 23 May 2016 18:35:21 -0500 Subject: initfs: update: Do not cause an error if no files were saved If there were no files in the read-write overlay file system that were in the persistent file list, then the save directory will not be created and therefore not exist. Skip attempting copying the non-existent directory in that case to avoid the error message. Signed-off-by: Milton Miller --- .../common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'meta-phosphor') 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 f8e551cfd..f0ca989d2 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 @@ -144,7 +144,7 @@ do flashcp -v $f /dev/$m && rm $f done -if test "x$toram" = xy +if test -d $save -a "x$toram" = xy then mkdir -p $upper cp -rp $save/. $upper/ -- cgit v1.2.1 From d16a7b0bc725c5403a3156a10189b2c77931d968 Mon Sep 17 00:00:00 2001 From: Milton Miller Date: Wed, 15 Jun 2016 18:47:38 -0500 Subject: initfs: update: Consistently add ERROR: and print to stderr Make sure all error messages start with the tag ERROR and its printed to stderr by creating an echoerr function. Previously one case had the file descriptors backwards in the redirection. Signed-off-by: Milton Miller --- .../recipes-phosphor/obmc-phosphor-initfs/files/obmc-update.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'meta-phosphor') 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 f0ca989d2..e51dbf879 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 @@ -2,6 +2,10 @@ echo update: "$@" +echoerr() { + echo 1>&2 "ERROR: $@" +} + cd / if ! test -r /proc/mounts || ! test -f /proc/mounts then @@ -21,7 +25,7 @@ fi if grep mtd /proc/mounts then - echo 1>&2 "Error: A mtd device is mounted." + echoerr "A mtd device is mounted." exit 1 fi @@ -90,7 +94,7 @@ do toram=y shift ;; *) - echo 2>&1 "Unknown option $1" + echoerr "Unknown option $1" exit 1 ;; esac done @@ -126,7 +130,7 @@ do m=$(findmtd ${f#$image}) if test -z "$m" then - echo 1>&2 "Unable to find mtd partiton for ${f##*/}." + echoerr "Unable to find mtd partiton for ${f##*/}." exit 1 fi done -- cgit v1.2.1 From 4015b7a34bbb563975e5c8bde04dff911071a71d Mon Sep 17 00:00:00 2001 From: Milton Miller Date: Mon, 23 May 2016 17:41:34 -0500 Subject: initfs: update: add option to perform checks but skip actual update Provide a way to check if update is likely to succeed without attempting actual updates. This will check the image names correspond to mtd partition names, and will be enhanced with additional checking for file size and individual partition mounts. This is not called --dry-run because it will still do file save and restore if those are enabled. Signed-off-by: Milton Miller --- .../obmc-phosphor-initfs/files/obmc-update.sh | 31 +++++++++++++--------- 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'meta-phosphor') 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 e51dbf879..9f5bede43 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 @@ -61,6 +61,7 @@ upper=$rwdir/cow save=/run/save/${upper##*/} mounted= +doflash=y doclean= dosave=y dorestore=y @@ -90,6 +91,9 @@ do --restore-files) dorestore=y shift ;; + --no-flash) + doflash= + shift ;; --copy-files) toram=y shift ;; @@ -135,18 +139,21 @@ do fi done -for f in $image* -do - if test ! -s $f - then - echo "Skipping empty update of ${f#$image}." - rm $f - continue - fi - m=$(findmtd ${f#$image}) - echo "Updating ${f#$image}..." - flashcp -v $f /dev/$m && rm $f -done +if test -n "$doflash" +then + for f in $image* + do + if test ! -s $f + then + echo "Skipping empty update of ${f#$image}." + rm $f + continue + fi + m=$(findmtd ${f#$image}) + echo "Updating ${f#$image}..." + flashcp -v $f /dev/$m && rm $f + done +fi if test -d $save -a "x$toram" = xy then -- cgit v1.2.1 From 810dc707814e454807cd4ea6b52583b4d49b041c Mon Sep 17 00:00:00 2001 From: Milton Miller Date: Mon, 23 May 2016 19:17:55 -0500 Subject: initfs: update: check individual mtd partitions for mounts Instead of checking for any mtd device, only check mtd devices that are to be updated. Include child mtd devices when looking for mounted filesystems. If this check is suppressed flash updates are suppressed. Suppressing the check may be useful to verify a update could succeed at shutdown. Signed-off-by: Milton Miller --- .../obmc-phosphor-initfs/files/obmc-update.sh | 46 +++++++++++++++++++--- 1 file changed, 41 insertions(+), 5 deletions(-) (limited to 'meta-phosphor') 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 9f5bede43..9d3c81276 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 @@ -23,11 +23,34 @@ then mount -t devtmpfs dev dev fi -if grep mtd /proc/mounts -then - echoerr "A mtd device is mounted." - exit 1 -fi +# mtd number N with mtd name Name can be mounted via mtdN, or mtd:Name +# (with a mtd aware fs) or by /dev/mtdblockN (with a mtd or block fs). +mtdismounted() { + m=${1##mtd} + if grep -s "mtdblock$m " /proc/mounts || grep -s "mtd$m " /proc/mounts + then + return 0 + fi + n=$(cat /sys/class/mtd/mtd$m/name) + if test -n "$n" && grep -s "mtd:$n " /proc/mounts + then + return 0 + fi + return 1 +} + +# Detect child partitions when the whole flash is to be updated. +# Ignore mtdNro and mtdblockN names in the class subsystem directory. +childmtds() { + for m in /sys/class/mtd/$1/mtd* + do + m=${m##*/} + if test "${m%ro}" = "${m#mtdblock}" + then + echo $m + fi + done +} findmtd() { m=$(grep -xl "$1" /sys/class/mtd/*/name) @@ -66,6 +89,7 @@ doclean= dosave=y dorestore=y toram= +checkmount=y whitelist=/run/initramfs/whitelist image=/run/initramfs/image- @@ -94,6 +118,10 @@ do --no-flash) doflash= shift ;; + --ignore-mount) + checkmount= + doflash= + shift ;; --copy-files) toram=y shift ;; @@ -137,6 +165,14 @@ do echoerr "Unable to find mtd partiton for ${f##*/}." exit 1 fi + for s in $m $(childmtds $m) + do + if test -n "$checkmount" && mtdismounted $s + then + echoerr "Device $s is mounted, ${f##*/} is busy." + exit 1 + fi + done done if test -n "$doflash" -- cgit v1.2.1 From 1944aac808846675f75f1460128066aed5c0aab6 Mon Sep 17 00:00:00 2001 From: Milton Miller Date: Mon, 23 May 2016 18:22:11 -0500 Subject: 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 --- .../obmc-phosphor-initfs/files/obmc-update.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'meta-phosphor') 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 -- cgit v1.2.1 From 30137fa2a0122bf504369d1b90ac019df5685357 Mon Sep 17 00:00:00 2001 From: Milton Miller Date: Wed, 15 Jun 2016 16:02:23 -0500 Subject: initfs: update: add --help message Now that update is intended for use at runtime and not just by the init and shutdown scripts, add a short help message listing the options so people don't have to understand how to read shell. Signed-off-by: Milton Miller --- .../obmc-phosphor-initfs/files/obmc-update.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'meta-phosphor') 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 fa46635a5..268c6ad0e 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 @@ -106,6 +106,24 @@ image=/run/initramfs/image- while test "$1" != "${1#-}" do case "$1" in + --help) + cat < Date: Wed, 25 May 2016 18:52:04 -0500 Subject: initfs: init: add file for base options Allow an initrd image to include options for init while still allowing additional options to come from the kernel command line and/or u-boot environment variables. This will allow building a netboot image that can specify to run from RAM while allowing the command line to initiate debug or skip copying files from the read-write overlay file system. Signed-off-by: Milton Miller --- .../recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'meta-phosphor') diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh index c37b3d53d..70af93d99 100644 --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh @@ -184,6 +184,7 @@ fsckbase=/sbin/fsck. fsck=$fsckbase$rwfst fsckopts=-a optfile=/run/initramfs/init-options +optbase=/run/initramfs/init-options-base urlfile=/run/initramfs/init-download-url update=/run/initramfs/update @@ -192,9 +193,16 @@ then cp /${optfile##*/} $optfile fi +if test -e /${optbase##*/} +then + cp /${optbase##*/} $optbase +else + touch $optbase +fi + if test ! -f $optfile then - cat /proc/cmdline > $optfile + cat /proc/cmdline $optbase > $optfile get_fw_env_var openbmcinit >> $optfile get_fw_env_var openbmconce >> $optfile fi -- cgit v1.2.1 From f19c04babfe30b2f511a1e234867af73b1d16603 Mon Sep 17 00:00:00 2001 From: Milton Miller Date: Tue, 14 Jun 2016 14:42:05 -0500 Subject: image-types_uboot: Package a self contained netboot image Create a cpio containing the base read-only image, and create a single combined initramfs image consisting of the image-rofs and the existing initramfs. There has been a desire to have a self contained netboot image present for developer testing and experimentation. The init script already supports having the rofs layer sourced from a file packaged into the initramfs, and will use it if found. While this image will not fit in the current flash layout in the initrd space, it will load over the network. This method leaves the squashfs compressed in RAM, decompreses is invoked as needed at runtime, trading boot time and memory space for runtime decompress on demand. This will also give similar file access overheads and performance to reading the data from flash. Because the rofs is already compressed with xz compression, don't try to compress this cpio (the cpio packaging adds about 40 bytes of ascii before and after, plus some alignment padding). Because the kernel requires uncompressed cpios to appear on a 4-byte boundary with 0 byte fill between archives, place this cpio first in the combined image. Signed-off-by: Milton Miller --- meta-phosphor/classes/obmc-phosphor-image_types_uboot.bbclass | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'meta-phosphor') diff --git a/meta-phosphor/classes/obmc-phosphor-image_types_uboot.bbclass b/meta-phosphor/classes/obmc-phosphor-image_types_uboot.bbclass index 67a389fbc..dd990bc5e 100644 --- a/meta-phosphor/classes/obmc-phosphor-image_types_uboot.bbclass +++ b/meta-phosphor/classes/obmc-phosphor-image_types_uboot.bbclass @@ -51,6 +51,8 @@ do_generate_flash() { uinitrd="${initrd}.u-boot" rootfs="${IMAGE_LINK_NAME}.${IMAGE_BASETYPE}" rwfs="rwfs.${OVERLAY_BASETYPE}" + rofsimg=rofs.${IMAGE_BASETYPE}.cpio + netimg=initramfs-netboot.cpio if [ ! -f $ddir/$kernel ]; then bbfatal "Kernel file ${ddir}/${kernel} does not exist" @@ -94,4 +96,12 @@ do_generate_flash() { tar -h -cvf ${ddir}/${MACHINE}-${DATETIME}.all.tar -C ${ddir} image-bmc tar -h -cvf ${ddir}/${MACHINE}-${DATETIME}.tar -C ${ddir} image-u-boot image-kernel image-initramfs image-rofs image-rwfs + + # Package the root image (rofs layer) with the initramfs for net booting. + # Uses the symlink above to get the desired name in the cpio + ( cd $ddir && echo image-rofs | cpio -oHnewc -L > ${rofsimg} ) + # Prepend the rofs cpio -- being uncompressed it must be 4-byte aligned + cat ${ddir}/${rofsimg} ${ddir}/${initrd} > ${ddir}/${netimg} + oe_mkimage "${netimg}" "${INITRD_CTYPE}" + } -- cgit v1.2.1 From 4e87861f60679062eb13289c9fe39c0721f52e71 Mon Sep 17 00:00:00 2001 From: Milton Miller Date: Thu, 16 Jun 2016 16:44:12 -0500 Subject: initfs: update: handle no images to update Notify the user if image wildcard expansion fails instead of printing message about failing to find partition to flash. The update script errors with the message that it can't figure out what partition to flash for /run/initramfs/image-* if there are no images pending. Signed-off-by: Milton Miller --- .../obmc-phosphor-initfs/files/obmc-update.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'meta-phosphor') 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 268c6ad0e..97d4402ee 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 @@ -102,6 +102,7 @@ checkmount=y whitelist=/run/initramfs/whitelist image=/run/initramfs/image- +imglist= while test "$1" != "${1#-}" do @@ -187,7 +188,15 @@ then fi fi -for f in $image* +imglist=$(echo $image*) +if test "$imglist" = "$image*" -a ! -e "$imglist" +then + # shell didn't expand the wildcard, so no files exist + echo "No images found to update." + imglist= +fi + +for f in $imglist do m=$(findmtd ${f#$image}) if test -z "$m" @@ -212,7 +221,7 @@ done if test -n "$doflash" then - for f in $image* + for f in $imglist do if test ! -s $f then -- cgit v1.2.1 From adeceff641c5f084897f229c18b957da96d6f451 Mon Sep 17 00:00:00 2001 From: Milton Miller Date: Thu, 16 Jun 2016 16:58:21 -0500 Subject: initfs: update: Sanitize whitelist directory entries Repeatedly strip trailing "/" and "/." from whitelist entries and fail if an entry includes "/../", ends with "/..", or doesn't start with a "/". Also use the entries quoted to avoid any glob. It was noticed the save code was saving directories that ended in "/" into a subdirectory of the last component name. This was traced the the code creating the directory just stripping the last "/" and then copying to the directory. Choose to sanitize the entry where possible for ease of use verses a small performance penalty. Signed-off-by: Milton Miller --- .../obmc-phosphor-initfs/files/obmc-update.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'meta-phosphor') 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 97d4402ee..f0c41a74c 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 @@ -173,13 +173,24 @@ then while read f do - if ! test -e $upper/$f + # Entries shall start with /, no trailing /.. or embedded /../ + if test "/${f#/}" != "$f" -o "${f%/..}" != "${f#*/../}" + then + echo 1>&2 "WARNING: Skipping bad whitelist entry $f." + continue + fi + if ! test -e "$upper/$f" then continue fi d="$save/$f" + while test "${d%/}" != "${d%/.}" + do + d="${d%/.}" + d="${d%/}" + done mkdir -p "${d%/*}" - cp -rp $upper/$f "${d%/*}/" + cp -rp "$upper/$f" "${d%/*}/" done < $whitelist if test -n "$mounted" -- cgit v1.2.1 From a6e6d0ce143b8476281672f7e859f451fc525270 Mon Sep 17 00:00:00 2001 From: Milton Miller Date: Fri, 17 Jun 2016 15:47:13 -0500 Subject: initfs: whitelist: Sanitize obmc events whitelist entry Remove the trailing / so that the update script doesn't have to loop. It was determined the trailing slash confused the code that makes the save subdirectory. The update script was fixed but this removes the extra work needed. Signed-off-by: Milton Miller --- .../common/recipes-phosphor/obmc-phosphor-initfs/files/whitelist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'meta-phosphor') diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/whitelist b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/whitelist index 603cec7e4..c35a552c7 100644 --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/whitelist +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/whitelist @@ -6,4 +6,4 @@ /etc/group /etc/shadow /etc/gshadow -/var/lib/obmc/events/ +/var/lib/obmc/events -- cgit v1.2.1