From: Avnish Chouhan <avnish@linux.ibm.com>
To: "Vladimir 'phcoder' Serbinenko" <phcoder@gmail.com>
Cc: The development of GRUB 2 <grub-devel@gnu.org>,
Daniel Kiper <daniel.kiper@oracle.com>,
Michael Chang <mchang@suse.com>,
msuchanek@suse.com,
John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Subject: Re: [PATCH v4] Mandatory install device check for PowerPC
Date: Thu, 29 Jan 2026 16:29:18 +0530 [thread overview]
Message-ID: <e62d25d77e84d5e579fd6266fa3bc071@linux.ibm.com> (raw)
In-Reply-To: <CAEaD8JNudbWx=vrma-cZHOe_UB-vP7ewPhYdBg+W5TZQKX5CNg@mail.gmail.com>
On 2026-01-29 15:22, Vladimir 'phcoder' Serbinenko wrote:
> How does it handle PPC macs? They don't use install device Regards
> Vladimir 'phcoder' Serbinenko Le mar. 27 janv. 2026, 16: 48, Avnish
> Chouhan <avnish@ linux. ibm. com> a écrit : This patch adds a
> check on install_device while
>
>
> How does it handle PPC macs? They don't use install device
>
> Regards
> Vladimir 'phcoder' Serbinenko
Hi Vladimir,
Thank you so much for your review!
I have added this check in else condition, which is newly added to the
if condition where we decide whether machine is PowerMac or Non
PowerMac. So this check is not applicable to PowerMac. Sharing the whole
code block below where I have introduced this new else condition for
better understanding! Please let me know your suggestions on it. I have
tested this on IBM Power and it is working as expected. No issues
observed.
Regards,
Avnish Chouhan
Code:
if (platform == GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275)
{
int is_guess = 0;
if (!macppcdir)
{
char *d;
is_guess = 1;
d = grub_util_path_concat (2, bootdir, "macppc");
if (!grub_util_is_directory (d))
{
free (d);
d = grub_util_path_concat (2, bootdir, "efi");
}
/* Find the Mac HFS(+) System Partition. */
if (!grub_util_is_directory (d))
{
free (d);
d = grub_util_path_concat (2, bootdir, "EFI");
}
if (!grub_util_is_directory (d))
{
free (d);
d = 0;
}
if (d)
macppcdir = d;
}
if (macppcdir) <<< added else against this if condition >>>>
{
char **macppcdir_device_names = NULL;
grub_device_t macppcdir_grub_dev = NULL;
char *macppcdir_grub_devname;
grub_fs_t fs;
macppcdir_device_names = grub_guess_root_devices (macppcdir);
if (!macppcdir_device_names || !macppcdir_device_names[0])
grub_util_error (_("cannot find a device for %s (is /dev
mounted?)"),
macppcdir);
for (curdev = macppcdir_device_names; *curdev; curdev++)
grub_util_pull_device (*curdev);
macppcdir_grub_devname = grub_util_get_grub_dev
(macppcdir_device_names[0]);
if (!macppcdir_grub_devname)
grub_util_error (_("cannot find a GRUB drive for %s. Check
your device.map"),
macppcdir_device_names[0]);
macppcdir_grub_dev = grub_device_open
(macppcdir_grub_devname);
if (! macppcdir_grub_dev)
grub_util_error ("%s", grub_errmsg);
fs = grub_fs_probe (macppcdir_grub_dev);
if (! fs)
grub_util_error ("%s", grub_errmsg);
if (grub_strcmp (fs->name, "hfs") != 0
&& grub_strcmp (fs->name, "hfsplus") != 0
&& !is_guess)
grub_util_error (_("filesystem on %s is neither HFS nor
HFS+"),
macppcdir);
if (grub_strcmp (fs->name, "hfs") == 0
|| grub_strcmp (fs->name, "hfsplus") == 0)
{
install_device = macppcdir_device_names[0];
is_prep = 0;
}
}
+#if defined(__powerpc__)
+ else
+ {
+ /*
+ * As the machine has been detected as PowerPC and not a PowerMac.
We need to check
+ * whether the install_device has been mentioned while installing.
If no device has been
+ * mentioned, we need to exit and mark it as an error as the
install_device is required for
+ * PowerPC installation. An installation with no device mentioned
may lead to corruptions.
+ */
+ if (!install_device)
+ grub_util_error ("%s", _("install device isn't specified,
required for PowerPC"));
+ }
+#endif /* __powerpc__ */
}
*****************
>
> Le mar. 27 janv. 2026, 16:48, Avnish Chouhan <avnish@linux.ibm.com> a
> écrit :
>
>> This patch adds a check on install_device while installing grub for
>> PowerPC.
>> If install_device is not mentioned in grub2-install and machine is
>> detected
>> as PowerPC, the error will be thrown and it will terminates the
>> grub2-install
>> operation. Running grub2-install on PowerPC without the
>> install_device may
>> result in bootlist corruption. When no install device is specified,
>> it attempts
>> to load images from the filesystem, which leads to nvram bootlist
>> corruption.
>> The idea is to fail the operation and avoid creating the invalid
>> boot entry.
>>
>> Signed-off-by: Avnish Chouhan <avnish@linux.ibm.com>
>> ---
>> util/grub-install.c | 13 +++++++++++++
>> 1 file changed, 13 insertions(+)
>>
>> diff --git a/util/grub-install.c b/util/grub-install.c
>> index 0602465..f7389b3 100644
>> --- a/util/grub-install.c
>> +++ b/util/grub-install.c
>> @@ -1289,6 +1289,19 @@ main (int argc, char *argv[])
>> is_prep = 0;
>> }
>> }
>> +#if defined(__powerpc__)
>> + else
>> + {
>> + /*
>> + * As the machine has been detected as PowerPC and not a
>> PowerMac. We need to check
>> + * whether the install_device has been mentioned while
>> installing. If no device has been
>> + * mentioned, we need to exit and mark it as an error as
>> the install_device is required for
>> + * PowerPC installation. An installation with no device
>> mentioned may lead to corruptions.
>> + */
>> + if (!install_device)
>> + grub_util_error ("%s", _("install device isn't
>> specified, required for PowerPC"));
>> + }
>> +#endif /* __powerpc__ */
>> }
>>
>> size_t ndev = 0;
>> --
>> 2.50.1 (Apple Git-155)
>
>
> Links:
> ------
> [1]
> https://us-phishalarm-ewt.proofpoint.com/EWT/v1/AdhS1Rd-!-XFVHHiYfI50uj3TBKhpkK0tRmgEA2v9hULtpqArjJRiacl4ZySbwwz0clt_u8GN0uhe8Tu7SuPZ4j2yFq_HRk40s3NhJKsDTK2fk_F-8JHP7eq9rmV2QzpyfqQg$
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
next prev parent reply other threads:[~2026-01-29 10:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-27 13:48 [PATCH v4] Mandatory install device check for PowerPC Avnish Chouhan
2026-01-27 16:13 ` Michal Suchánek
2026-01-29 9:48 ` Avnish Chouhan
2026-01-29 9:52 ` Vladimir 'phcoder' Serbinenko
2026-01-29 10:59 ` Avnish Chouhan [this message]
2026-01-29 11:14 ` Michal Suchánek
2026-01-30 10:38 ` Avnish Chouhan
2026-01-30 12:00 ` Michal Suchánek
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=e62d25d77e84d5e579fd6266fa3bc071@linux.ibm.com \
--to=avnish@linux.ibm.com \
--cc=daniel.kiper@oracle.com \
--cc=glaubitz@physik.fu-berlin.de \
--cc=grub-devel@gnu.org \
--cc=mchang@suse.com \
--cc=msuchanek@suse.com \
--cc=phcoder@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.