1 Star 0 Fork 16

jackzhao166/grub2

forked from OpenCloudOS Stream/grub2 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0052-grub-install-remove-useless-check-PReP-partition-is-.patch 2.60 KB
一键复制 编辑 原始数据 按行查看 历史
nilusyi 提交于 2024-04-07 16:45 . update patches
From 1657812278bb086ca31dc4af24dd0e1627504869 Mon Sep 17 00:00:00 2001
From: Michal Suchanek <msuchanek@suse.de>
Date: Tue, 31 Oct 2017 14:28:54 +0100
Subject: [PATCH 052/272] grub-install: remove useless check PReP partition is
empty.
References: bsc#1065738
The grub-install rewrite in commit cd46aa6cefab checks that the PPeP
partition does not install an ELF binary before writing grub to it. This
causes regression in installer scripts that expect to be able to
reinstall bootloaders without first witping the partition by hand.
Fixes: cd46aa6cefab ("Rewrite grub-install, grub-mkrescue,
grub-mkstandalone and grub-mknetdir ")
---
util/grub-install.c | 43 +++----------------------------------------
1 file changed, 3 insertions(+), 40 deletions(-)
diff --git a/util/grub-install.c b/util/grub-install.c
index 1d2bf4dd3..036a66dc6 100644
--- a/util/grub-install.c
+++ b/util/grub-install.c
@@ -746,34 +746,6 @@ is_prep_partition (grub_device_t dev)
return 0;
}
-static int
-is_prep_empty (grub_device_t dev)
-{
- grub_disk_addr_t dsize, addr;
- grub_uint32_t buffer[32768];
-
- dsize = grub_disk_native_sectors (dev->disk);
- for (addr = 0; addr < dsize;
- addr += sizeof (buffer) / GRUB_DISK_SECTOR_SIZE)
- {
- grub_size_t sz = sizeof (buffer);
- grub_uint32_t *ptr;
-
- if (sizeof (buffer) / GRUB_DISK_SECTOR_SIZE > dsize - addr)
- sz = (dsize - addr) * GRUB_DISK_SECTOR_SIZE;
- grub_disk_read (dev->disk, addr, 0, sz, buffer);
-
- if (addr == 0 && grub_memcmp (buffer, ELFMAG, SELFMAG) == 0)
- return 1;
-
- for (ptr = buffer; ptr < buffer + sz / sizeof (*buffer); ptr++)
- if (*ptr)
- return 0;
- }
-
- return 1;
-}
-
static void
bless (grub_device_t dev, const char *path, int x86)
{
@@ -1942,18 +1914,9 @@ main (int argc, char *argv[])
{
grub_util_error ("%s", _("the chosen partition is not a PReP partition"));
}
- if (is_prep_empty (ins_dev))
- {
- if (write_to_disk (ins_dev, imgfile))
- grub_util_error ("%s", _("failed to copy Grub to the PReP partition"));
- grub_set_install_backup_ponr ();
- }
- else
- {
- char *s = xasprintf ("dd if=/dev/zero of=%s", install_device);
- grub_util_error (_("the PReP partition is not empty. If you are sure you want to use it, run dd to clear it: `%s'"),
- s);
- }
+ if (write_to_disk (ins_dev, imgfile))
+ grub_util_error ("%s", _("failed to copy Grub to the PReP partition"));
+ grub_set_install_backup_ponr ();
grub_device_close (ins_dev);
if (update_nvram)
grub_install_register_ieee1275 (1, grub_util_get_os_disk (install_device),
--
2.41.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jackzhao166/grub2.git
git@gitee.com:jackzhao166/grub2.git
jackzhao166
grub2
grub2
master

搜索帮助