public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: "Roberto A. Foglietta" <roberto.foglietta@gmail.com>
To: henning.schild@siemens.com
Cc: isar-users@googlegroups.com, Joe MacDonald <joe_macdonald@mentor.com>
Subject: Re: [PATCH v5 2/6] expand-on-first-boot: support resizing a btrfs
Date: Thu, 15 Dec 2022 18:48:12 +0100	[thread overview]
Message-ID: <CAJGKYO6+NR8w+0xM0decOjtrm8gWxo52sZ6jYRoPsBECjWsvcw@mail.gmail.com> (raw)
In-Reply-To: <20221215142759.26327-3-henning.schild@siemens.com>

On Thu, 15 Dec 2022 at 15:28, <henning.schild@siemens.com> wrote:

> +MOUNT_POINT=$(mktemp -d --tmpdir "$(basename "$0").XXXXXXXXXX")

Good choice to use the long option --tmpdir but it is still less
readable than -p "$TMPDIR"

> +if [ ! -d "${MOUNT_POINT}" ]; then
> +       echo "Cannot create temporary mount point ${MOUNT_POINT}." >&2
> +       exit 1
> +fi

This is useless because set -e detected the failure also in child shells.

Just try these two commands:

roberto$ set -e
roberto$ test=$(false)

The terminal / shell will be closed immediately after pressing ENTER

> +mount "${LAST_PART}" "${MOUNT_POINT}"

If mktemp fails then also the mount will fail so whatever the shell
takes in account or not the subshell errors it is useless explicitly
check the mount point existence

> +
> +ret=0
> +# Determine the filesystem type and perform the appropriate resize function
> +FS_TYPE=$(findmnt -fno FSTYPE "${MOUNT_POINT}" )
> +case ${FS_TYPE} in
> +ext*)

Using ext*) seems legit but what about the introduction of extmyfs? A
completely different filesystem from ext[234]? I suggest ext[234]),
instead.

> +       # Do not fail resize2fs if no mtab entry is found, e.g.,
> +       # when using systemd mount units.
> +       export EXT2FS_NO_MTAB_OK=1
> +       resize2fs "${LAST_PART}"
> +       ;;
> +btrfs)
> +       btrfs filesystem resize max "${MOUNT_POINT}"Using ext*) seems legit but what about the introduction of extmyfs? A completely different filesystem from ext[234]? I suggest ext[234]), instead.
> +       ;;
> +*)
> +       echo "Unrecognized filesystem type ${FS_TYPE} - no resize performed"
> +       ret=1

Looking at your other patches this script has been added by default in
many templates. So, why consider a failure the execution of something
that the user might not even choose to use but just accepted by
default? Would it not be better to have a simple warning and nothing
else? Moreover, if the failure of this script does not deactivate its
service [as I hope] this script will run at every boot without any
reason. Adding an exit 0 here will also remove the use of ret variable
simplifying the code.

> +       ;;
> +esac
>
> -resize2fs "${LAST_PART}"
> +umount "${MOUNT_POINT}"
> +rmdir "${MOUNT_POINT}"
> +exit $ret
> --
> 2.37.4
>

Best regards, R-

  reply	other threads:[~2022-12-15 17:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-15 14:27 [PATCH v5 0/6] expand-on-first-boot btrfs and CI testing henning.schild
2022-12-15 14:27 ` [PATCH v5 1/6] expand-on-first-boot: really only do that once, especially on failure henning.schild
2022-12-15 15:32   ` Roberto A. Foglietta
2022-12-15 14:27 ` [PATCH v5 2/6] expand-on-first-boot: support resizing a btrfs henning.schild
2022-12-15 17:48   ` Roberto A. Foglietta [this message]
2022-12-15 14:27 ` [PATCH v5 3/6] meta-isar: introduce an example to use btrfs henning.schild
2022-12-15 14:27 ` [PATCH v5 4/6] CI: improve cibuilder readability henning.schild
2022-12-15 14:27 ` [PATCH v5 5/6] meta-isar: install expand-on-first-boot in most images and add space henning.schild
2022-12-15 14:27 ` [PATCH v5 6/6] CI: expect a message about filesystem resize vom expand script henning.schild

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=CAJGKYO6+NR8w+0xM0decOjtrm8gWxo52sZ6jYRoPsBECjWsvcw@mail.gmail.com \
    --to=roberto.foglietta@gmail.com \
    --cc=henning.schild@siemens.com \
    --cc=isar-users@googlegroups.com \
    --cc=joe_macdonald@mentor.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