From mboxrd@z Thu Jan 1 00:00:00 1970 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:58 +0200 X-Sieve: CMU Sieve 2.4 Received: from mail-lf1-f57.google.com (mail-lf1-f57.google.com [209.85.167.57]) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8+deb9u1) with ESMTPS id 46FDkuSJ007048 (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-f57.google.com with SMTP id 2adb3069b0e04-52ea64b7903sf4826328e87.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=YCcMugVCuLMXeAjz5pMWvmJ1/K7y1EAjT8035R91d2uvmZZa+UYUXeMiuktK5EZ3dm 6lQu/gXRstdPJrd9A+6n2kD/wOOIWrMPsE4DWJGtIbOTISb3f4Ma61Gnq4GI35h6elAJ A7Vt+4zUR9mTOkGHM4nxrE/N8I+ZyPgWIF8D4EwnWArQKPG83OvH81utnxx69tp0jTm1 RENzkwOR2JZksGk8qPB/c4C005usCCbBv2Y9Qmvhzl+wbqN+vTt0Z+5W8EsBjFQK/s1g ZK52EcSCI6Jli1KEbLsdyB1CDfMU9r4g40l4NmRvANHfHxQTP3xoW7XvTh9yYuEZeEAh xOgA== 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=t7cL+hlLrhsbjEKQhJiincLeLzHpLcqdEe559K0P0JI=; b=FW+mdeFSy9ilqkmM1D+rg7dneoL6OzRqhkOWrCLGJqYp4MFRQYrKOhJxpt/KfDUWI4 CeBRQ7prMiZjZrZTAIrAVj9133TmYPVELUzUTR+EsVxqCQwcq0+vRUlaw9Hpb5y6TJR0 W5yhyMAybMLL+c9A2sCVBSoGHgh1WwafmYapSU8Znnvamg+EKCA5EHUzSY6MNHO77C7k GBfqJYRDQey7uOj7Xog/mneH+bIMKf9qFFcxxsvfYuWEoa77nrjdMwNb83uJBrnze/Ly kLMKNrqA65bsgXYZX1bDOfNiPQtx7JbPbFYH/aOH7KjhQwZ+kPAy6CuFn/aF2cKZR6x6 dY8Q==; 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=hoRfSEbc1MNLaGtjyWY5oyBhGFqj0EZryQ+d+9jLh5YRFOBE2SORHrthgfMsBU0uL9 UykRCGfp5P+tDvoz6eEiGs2PhjRkntoOlm7Yalt0Umy4Y9iQCMqOlvNwy39DBSM9azUu vW1USCTuXLdtioDdeX6CmcJI3MoWuYvN5/RFVWhahfEutMqn0os7Dg9F6spTOCpy46iP wyHjC8/5pJPNKLpA17+kGv/5raxIAidqdbEkCK2i89Gnb+AxnZ/XYukvnrfriIIdSK3Q 3I9hDZ/GZNZVOaMbASw2OSTC8JIRGOnvslr0cHlOfCYhQKJyWeiCIsFwpsg41Cj4RJ4a GQ7w== X-Forwarded-Encrypted: i=2; AJvYcCWxNQgKash8ph0wU667C1Y4Bjj9ntArRbqpfzu+s1Fjps/FsZIdKqFxk2C/YyLvgyp5MjVN8MTONx++Cf6bYulj2/4= X-Gm-Message-State: AOJu0YwsCjj+6vQW+zcq723v+xSBtw2tCwB0hDq7IlzMdWEgnmK2aG/2 mxWHfBHAc4yAHhz/3Z2ubnbHI1ntTp9zEOr2OkxYFsoe93HJ6LuD 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 From: "'Clara Kowalsky' via isar-users" 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 Content-Type: text/plain; charset="UTF-8" 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-TUID: 5EI027b87yVL 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" } -- 2.45.2 -- You received this message because you are subscribed to the Google Groups "isar-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/isar-users/20240715134643.901757-1-clara.kowalsky%40siemens.com.