]> code.ossystems Code Review - openembedded-core.git/commitdiff
image_types.bbclass: Populate cpio /init as symlink
authorNathan Rossi <nathan.rossi@xilinx.com>
Tue, 9 Dec 2014 05:50:05 +0000 (15:50 +1000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 19 Dec 2014 17:54:13 +0000 (17:54 +0000)
For cpio/ramfs the kernel will first attempt to execute /init and will
emit the following error as the file is empty:

    Failed to execute /init (error -13)

If /sbin/init exists symlink to it so the kernel can immediately start
the correct init executable instead of an empty file.

Signed-off-by: Nathan Rossi <nathan.rossi@xilinx.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
meta/classes/image_types.bbclass

index 9aee7458bccd24a26f7d0b63e8395d07b5a6825f..1b8ceeebed70fd141084cdb2b650059276a79f35 100644 (file)
@@ -70,7 +70,11 @@ IMAGE_CMD_cpio () {
        (cd ${IMAGE_ROOTFS} && find . | cpio -o -H newc >${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.cpio)
        if [ ! -e ${IMAGE_ROOTFS}/init ]; then
                mkdir -p ${WORKDIR}/cpio_append
-               touch ${WORKDIR}/cpio_append/init
+               if [ -e ${IMAGE_ROOTFS}/sbin/init -o -L ${IMAGE_ROOTFS}/sbin/init ]; then
+                       ln -sf /sbin/init ${WORKDIR}/cpio_append/init
+               else
+                       touch ${WORKDIR}/cpio_append/init
+               fi
                (cd  ${WORKDIR}/cpio_append && echo ./init | cpio -oA -H newc -F ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.cpio)
        fi
 }