From patchwork Mon Jul 15 13:46:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clara Kowalsky X-Patchwork-Id: 3695 Return-Path: Received: from shymkent.ilbers.de ([unix socket]) by shymkent (Cyrus 2.5.10-Debian-2.5.10-3+deb9u2) with LMTPA; Mon, 15 Jul 2024 15:46:57 +0200 X-Sieve: CMU Sieve 2.4 Received: from mail-lf1-f64.google.com (mail-lf1-f64.google.com [209.85.167.64]) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8+deb9u1) with ESMTPS id 46FDkuq4007049 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 15 Jul 2024 15:46:57 +0200 Received: by mail-lf1-f64.google.com with SMTP id 2adb3069b0e04-52e969d33c4sf3243493e87.0 for ; Mon, 15 Jul 2024 06:46:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1721051211; cv=pass; d=google.com; s=arc-20160816; b=CL/TMRZD8RMnUG/NDb7UTbLEdIWBxEDB2M72o9ACyvS7mENIzbd0aUi3HuwyPDyDS5 0lF55rBgxmrUsgknsa0tlIL8D8FboZq8gfUIyT5i/MAz94CQi6ROPG+nFXU/oClJPPSS ORofNvfCMSyJ+PMifgOjUTl6Kq16txKkI8hD1BizVJPN+KC/UZWTdmfgS+Al6wPHJs6Q H0SxkqHnb8eRa4kGikNJ88iBXpncSAvIlh0HyXj+vsgBw+1yv9JDW36RshpJH0xUoI6o ck+mHhpihC+vl8I/8Rtr32ctvv7z7tDqO3QlqraVvgIRf5no1sE0yoHp4bZ+Si0pxj3t t1VQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:feedback-id:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=wb7/WJ2IOJCZXJzRsBmU7vlfixtnfwO18nn2sZfJ29c=; fh=XfQ6/eQQtpOw6tS+UFMLSKRVBwf3xft4Dn8TrwRE/rk=; b=fiP7Imj3aR6P5MdFeeovPknnOgrrkhKn4D/m2bOkMIUw8hovHyt+Dr7dFjHXbdxT4y SW1edarzBif0cD1Zum7nPB6J8WHJUJxCUgExk6V75/dmC/X3pa+fAoimwBmLnUztucPm WQIgP9qIApe6UAyjEwAfZgZ9ZMErdskE1X3axrV5Aj2QytAGA8Fyw13eBjE9vJL1EhF3 0N1h06ekjVrBQnvMwXBPfJ9sBs+CzJ3wDIICMXg4z8Ezk2Mxph1vNOzmunPWsdMzI/2c kezglSCrNrsTjA9UkE3l8BVbejoJbL1KUZzE0xIibbLWfzsjcshIRO7seAXfu1RUPLSt EOTA==; darn=isar-build.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm2 header.b=DEmvbpx7; spf=pass (google.com: domain of fm-1047747-202407151346473977d77ba88ceb3106-oivw_5@rts-flowmailer.siemens.com designates 185.136.64.226 as permitted sender) smtp.mailfrom=fm-1047747-202407151346473977d77ba88ceb3106-oiVW_5@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1721051211; x=1721656011; darn=isar-build.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:feedback-id :mime-version:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=wb7/WJ2IOJCZXJzRsBmU7vlfixtnfwO18nn2sZfJ29c=; b=O1eNmGwXE/fbQlZRXgUHQzYI0mfvfoNtdhiL34G/am4FzxIsRyuTl5QfpzCCX2rPRU W+WcyzUtJTtOgy4TAT1m41z2ZvppWBIFd/mbKNuuIeZp+U/tTawye69b4H9KeG07DB9b H89uUYoUYnMuAc2wNRJnMy/49x5aKN6l5Xkav5YUUHVSjcNohYhTUoyFJEtTH/aWk5J3 amF3PgiSDkjv5AeMQjXkFMj1KM9X/kPNdTiiJUxnpCtIASVPh6+2AGfb9tzitihMOJqJ 63i6tsEZbFZREkXjO5V2oBQyLfMz+tVKUv+Owv4+xHS8DIBtv3oSYScNJTp1FZDEy+6J 5a2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721051211; x=1721656011; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:feedback-id :mime-version:message-id:date:subject:cc:to:from:x-beenthere :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wb7/WJ2IOJCZXJzRsBmU7vlfixtnfwO18nn2sZfJ29c=; b=OAhJwgxovsjKv7RhfLSu6bI97EXVe8GDzywhX1+BukC+CLG11Lt8UeSzdGmKotUK3i mVtVYhAF/T2T52pEBGh3YEV6Fgk0H5lvKPAgoqbBwu5dGYYkQQ2XiNvALOxprVxZisZZ LCDc+1ncxGuhVPpkhX/gB4IM+Bh2Pfe0pyg/vD8GyBnWsmdvYgdcEvaKGC3dBddpFv9+ FYmrwFcpY5J7BVVvEoFutLrOIvH9i+r5V8JmgVL8YUSl14rqk6sxswe5GJoaZVwC+LzN SuFudiLD+46kaK2jrEYtq+YP1uGDHWyDh1097CdcE2O9rmhZzCcf9Ov75LDEiyD79kwZ 7tIA== X-Forwarded-Encrypted: i=2; AJvYcCXGVDw6q9TdTG46mLZTaKCvl8sTshZiHkW/UvfXX4SyNgCVcb1FFrfnm66Wn8+QZ0RgiMUshoi8hRraDktNPAMkQ2t+ehw= X-Gm-Message-State: AOJu0YyuvZ8c+XJRlIFagdXD5Vf9v4+1pTIoeZ3lORCF38bzRSyp9VYK ax8hn1oUh43vWvj5gpIn+j+bJif/HNRTYYD6Pi/8VxzUzqDJVM76 X-Google-Smtp-Source: AGHT+IF9+W6Zddyl9gU+oE+dbVMoTyQQVmO4xc7cxRWQ6l1dk/ui6p7eTbEJ6sOKkgYHdP920c81rw== X-Received: by 2002:a05:6512:1288:b0:52c:81ba:aeba with SMTP id 2adb3069b0e04-52ecb7fec88mr2543779e87.14.1721051210755; Mon, 15 Jul 2024 06:46:50 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:ac2:59c7:0:b0:52e:7151:b061 with SMTP id 2adb3069b0e04-52ec4503f87ls831688e87.1.-pod-prod-00-eu; Mon, 15 Jul 2024 06:46:48 -0700 (PDT) X-Received: by 2002:a05:6512:1082:b0:52c:b1ca:2e47 with SMTP id 2adb3069b0e04-52ecb6134a2mr3542177e87.7.1721051208593; Mon, 15 Jul 2024 06:46:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721051208; cv=none; d=google.com; s=arc-20160816; b=Dy8tWHjyif3lTRn/4cYEIqaN0URMaNogFqi5UoG/54385E2uLWwv0VWPRIPFWh5ZiT JhQTyGuGzjBfAAek8GRZP4Pa8e1TQkoTRIqLr1TCCgeEhzJQrt/Y0uaxghpF+JIJN/xE XdRMbmbWfDAYlP/61k3scQC86SI/4pM5kfYN9sPKaKPA/lT9SS316sJebiGbcp8s0Q6e 8y8UAy+m2k4t6yPhMqMsQ4YaDXygRfPr6RMK5KL+OZCZEjnng1dCdkemR53Z3DDS+nr4 Lf/nuWnl1CQjh4Ff2Un0rAcx847VWbB+Wo9VcXEFeIotKvIZmN3oc9iQSf9Egb32nPSy +jhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=feedback-id:content-transfer-encoding:mime-version:message-id:date :subject:cc:to:from:dkim-signature; bh=Jrqd2jgaIvnKextb4J7TISsN79hfdMBrghKkNCYOxew=; fh=a/whyPBaBHcGEIUHNzsYkldQWeziqq3pHW0lRWinC6c=; b=VxpnugP0/bBvdztIxnaX+JGoW+iZ80LdsXTAqXDLgNVAnb+HhjMbVlYOMa2ckd/N6E VUOx7RkvJaNiZjCoGx2vygcNre29h3fJVHYLdkjkukyvpH8VTuIESbs38fM6GqFpLkn3 t6d5PkjivVPuN8gKUxRuyxA06qQsAOeDaF0z25gMIbAdmmkHaLPJEiPlKOFu1TdO6bn2 gxR95OycBJOLffaxJF5rbG/AsGk8MHcHd+rGPj1qC9jI2TppnmZyKC3lqNe57i2sc2cq 7SnikWIDnuN9YQFnh7L7L31/nvwf7A7rV5jT2Ad2UY7yVbeg23i1MQwRHGrvT75RPPMP XvHQ==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm2 header.b=DEmvbpx7; spf=pass (google.com: domain of fm-1047747-202407151346473977d77ba88ceb3106-oivw_5@rts-flowmailer.siemens.com designates 185.136.64.226 as permitted sender) smtp.mailfrom=fm-1047747-202407151346473977d77ba88ceb3106-oiVW_5@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: from mta-64-226.siemens.flowmailer.net (mta-64-226.siemens.flowmailer.net. [185.136.64.226]) by gmr-mx.google.com with ESMTPS id 2adb3069b0e04-52ed2588b8csi67064e87.13.2024.07.15.06.46.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Jul 2024 06:46:48 -0700 (PDT) Received-SPF: pass (google.com: domain of fm-1047747-202407151346473977d77ba88ceb3106-oivw_5@rts-flowmailer.siemens.com designates 185.136.64.226 as permitted sender) client-ip=185.136.64.226; Received: by mta-64-226.siemens.flowmailer.net with ESMTPSA id 202407151346473977d77ba88ceb3106 for ; Mon, 15 Jul 2024 15:46:47 +0200 X-Patchwork-Original-From: "'Clara Kowalsky' via isar-users" From: Clara Kowalsky To: isar-users@googlegroups.com Cc: quirin.gylstorff@siemens.com, Clara Kowalsky Subject: [cip-dev] [isar-cip-core][PATCH v4] initramfs-overlay-hook: Check file system of INITRAMFS_OVERLAY_STORAGE_DEVICE Date: Mon, 15 Jul 2024 15:46:43 +0200 Message-Id: <20240715134643.901757-1-clara.kowalsky@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-1047747:519-21489:flowmailer X-Original-Sender: clara.kowalsky@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm2 header.b=DEmvbpx7; spf=pass (google.com: domain of fm-1047747-202407151346473977d77ba88ceb3106-oivw_5@rts-flowmailer.siemens.com designates 185.136.64.226 as permitted sender) smtp.mailfrom=fm-1047747-202407151346473977d77ba88ceb3106-oiVW_5@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com X-Original-From: Clara Kowalsky Reply-To: Clara Kowalsky Precedence: list Mailing-list: list isar-users@googlegroups.com; contact isar-users+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: isar-users@googlegroups.com X-Google-Group-Id: 914930254986 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , X-Spam-Status: No, score=-4.9 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2,RCVD_IN_RP_CERTIFIED,RCVD_IN_RP_RNBL,RCVD_IN_RP_SAFE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shymkent.ilbers.de X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= In case of ext*, this detects and fixes file system errors in the partition device before doing the partition mount. If the partition turns out to be broken, the factory state is recovered. Signed-off-by: Clara Kowalsky --- .../initramfs-overlay-hook/files/overlay.hook | 11 +++++++++-- .../files/overlay.script.tmpl | 11 ++++++++++- .../files/overlay_recovery_action.script | 14 ++++++++++++++ .../initramfs-overlay-hook_0.1.bb | 8 +++++++- 4 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 recipes-initramfs/initramfs-overlay-hook/files/overlay_recovery_action.script diff --git a/recipes-initramfs/initramfs-overlay-hook/files/overlay.hook b/recipes-initramfs/initramfs-overlay-hook/files/overlay.hook index 8b00ecf..6f634c5 100644 --- a/recipes-initramfs/initramfs-overlay-hook/files/overlay.hook +++ b/recipes-initramfs/initramfs-overlay-hook/files/overlay.hook @@ -22,6 +22,13 @@ esac . /usr/share/initramfs-tools/hook-functions +hook_error() { + echo "(ERROR): $1" >&2 + exit 1 +} + manual_add_modules overlay -copy_exec /usr/bin/mountpoint -copy_exec /usr/bin/awk +copy_exec /usr/bin/mountpoint || hook_error "/usr/bin/mountpoint not found" +copy_exec /usr/bin/awk || hook_error "/usr/bin/awk not found" +copy_exec /usr/sbin/e2fsck || hook_error "/usr/sbin/e2fsck not found" +copy_exec /usr/sbin/mke2fs || hook_error "/usr/sbin/mke2fs not found" diff --git a/recipes-initramfs/initramfs-overlay-hook/files/overlay.script.tmpl b/recipes-initramfs/initramfs-overlay-hook/files/overlay.script.tmpl index 42eb59c..deda034 100644 --- a/recipes-initramfs/initramfs-overlay-hook/files/overlay.script.tmpl +++ b/recipes-initramfs/initramfs-overlay-hook/files/overlay.script.tmpl @@ -31,12 +31,21 @@ ovl_partition_device="${INITRAMFS_OVERLAY_STORAGE_DEVICE}" ovl_storage_path="${INITRAMFS_OVERLAY_STORAGE_PATH}" ovl_lower_dirs="${INITRAMFS_OVERLAY_PATHS}" ovl_mount_option="${INITRAMFS_OVERLAY_MOUNT_OPTION}" +ovl_recovery_script="/scripts/${INITRAMFS_OVERLAY_RECOVERY_SCRIPT}" root_mount_storage=${rootmnt}${ovl_storage_path} storage_mount_point="$(echo "${ovl_storage_path}" | awk -F/ '{print FS$2}' )" +partition_fstype=$(get_fstype "${ovl_partition_device}") if ! mountpoint -q "${rootmnt}${storage_mount_point}"; then - if ! mount -t $(get_fstype ${ovl_partition_device}) \ + if [ "$partition_fstype" = "ext*" ]; then + if ! e2fsck -p -f "$ovl_partition_device"; then + if [ -f "$ovl_recovery_script" ] && [ -x "$ovl_recovery_script" ]; then + "$ovl_recovery_script" "$ovl_partition_device" "$partition_fstype" + fi + fi + fi + if ! mount -t ${partition_fstype} \ -o ${ovl_mount_option} \ ${ovl_partition_device} \ ${rootmnt}${storage_mount_point}; then diff --git a/recipes-initramfs/initramfs-overlay-hook/files/overlay_recovery_action.script b/recipes-initramfs/initramfs-overlay-hook/files/overlay_recovery_action.script new file mode 100644 index 0000000..4ef0148 --- /dev/null +++ b/recipes-initramfs/initramfs-overlay-hook/files/overlay_recovery_action.script @@ -0,0 +1,14 @@ +#!/bin/sh +# +# CIP Core, generic profile +# +# Copyright (c) Siemens AG, 2024 +# +# Authors: +# Clara Kowalsky +# + +ovl_partition_device="$1" +partition_fstype="$2" + +mke2fs -t "$partition_fstype" "$ovl_partition_device" diff --git a/recipes-initramfs/initramfs-overlay-hook/initramfs-overlay-hook_0.1.bb b/recipes-initramfs/initramfs-overlay-hook/initramfs-overlay-hook_0.1.bb index 955748f..7097130 100644 --- a/recipes-initramfs/initramfs-overlay-hook/initramfs-overlay-hook_0.1.bb +++ b/recipes-initramfs/initramfs-overlay-hook/initramfs-overlay-hook_0.1.bb @@ -12,9 +12,12 @@ inherit dpkg-raw +INITRAMFS_OVERLAY_RECOVERY_SCRIPT ??= "overlay_recovery_action.script" + SRC_URI += " \ file://overlay.hook \ file://overlay.script.tmpl \ + file://${INITRAMFS_OVERLAY_RECOVERY_SCRIPT} \ " # The variable INITRAMFS_OVERLAY_PATHS contains the directories which are @@ -35,7 +38,8 @@ TEMPLATE_FILES = "overlay.script.tmpl" TEMPLATE_VARS += " INITRAMFS_OVERLAY_STORAGE_PATH \ INITRAMFS_OVERLAY_PATHS \ INITRAMFS_OVERLAY_STORAGE_DEVICE \ - INITRAMFS_OVERLAY_MOUNT_OPTION" + INITRAMFS_OVERLAY_MOUNT_OPTION \ + INITRAMFS_OVERLAY_RECOVERY_SCRIPT" DEBIAN_DEPENDS = "initramfs-tools, awk, coreutils, util-linux" @@ -48,4 +52,6 @@ do_install() { "${D}/usr/share/initramfs-tools/hooks/overlay" install -m 0755 "${WORKDIR}/overlay.script" \ "${D}/usr/share/initramfs-tools/scripts/local-bottom/overlay" + install -m 0755 "${WORKDIR}/${INITRAMFS_OVERLAY_RECOVERY_SCRIPT}" \ + "${D}/usr/share/initramfs-tools/scripts" }