public inbox for cip-dev@lists.cip-project.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@web.de>
To: Clara Kowalsky <clara.kowalsky@siemens.com>,
	cip-dev@lists.cip-project.org
Cc: quirin.gylstorff@siemens.com
Subject: Re: [cip-dev] [isar-cip-core][PATCH v5] initramfs-overlay-hook: Check file system of INITRAMFS_OVERLAY_STORAGE_DEVICE
Date: Fri, 2 Aug 2024 13:00:27 +0200	[thread overview]
Message-ID: <307bf040-06cb-49f7-84eb-e1a06447fc53@web.de> (raw)
In-Reply-To: <f640d73c-8882-4267-ac13-715947002c5c@siemens.com>

On 01.08.24 09:26, Clara Kowalsky wrote:
>
>
> On 31.07.24 19:01, Jan Kiszka wrote:
>> On 23.07.24 14:59, Clara Kowalsky wrote:
>>> 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 <clara.kowalsky@siemens.com>
>>> ---
>>>   .../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"
>>
>> Is there no "copy_exec_and_complain+fail_if_missing"? This pattern looks
>> like it does not scale very well across all our scripts (including isar
>> upstream).
>>
> I have not found anything like this that covers both in one command.
>
>>> diff --git
>>> a/recipes-initramfs/initramfs-overlay-hook/files/overlay.script.tmpl
>>> b/recipes-initramfs/initramfs-overlay-hook/files/overlay.script.tmpl
>>> index 42eb59c..c6f69b9 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}) \
>>> +    case $partition_fstype in
>>> +    ext*)
>>> +        if ! e2fsck -p -f "$ovl_partition_device" && [ -f
>>> "$ovl_recovery_script" ] && [ -x "$ovl_recovery_script" ]; then
>>
>> Why testing both -f and -x?
>
> I was thinking, what if someone sets INITRAMFS_OVERLAY_RECOVERY_SCRIPT
> to an empty string? Then ovl_recovery_script would be a directory and
> the next line would give a permission denied.
>

OK - but in that case, "file://${INITRAMFS_OVERLAY_RECOVERY_SCRIPT}"
will make things fail much earlier.

Jan



      reply	other threads:[~2024-08-02 11:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-23 12:59 [cip-dev] [isar-cip-core][PATCH v5] initramfs-overlay-hook: Check file system of INITRAMFS_OVERLAY_STORAGE_DEVICE Clara Kowalsky
2024-07-31 17:01 ` Jan Kiszka
2024-08-01  7:26   ` Clara Kowalsky
2024-08-02 11:00     ` Jan Kiszka [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=307bf040-06cb-49f7-84eb-e1a06447fc53@web.de \
    --to=jan.kiszka@web.de \
    --cc=cip-dev@lists.cip-project.org \
    --cc=clara.kowalsky@siemens.com \
    --cc=quirin.gylstorff@siemens.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox