Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
devel:gcc:next:testing
grub2
0001-grub-core-modify-sector-by-sysfs-as-disk-s...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-grub-core-modify-sector-by-sysfs-as-disk-sector.patch of Package grub2
From 1eee02bbf2c11167e94f424846ce1de0b6e7fa8e Mon Sep 17 00:00:00 2001 From: Mukesh Kumar Chaurasiya <mchauras@linux.vnet.ibm.com> Date: Fri, 3 Feb 2023 10:10:43 +0530 Subject: [PATCH] grub-core: modify sector by sysfs as disk sector The disk sector size provided by sysfs file system considers the sector size of 512 irrespective of disk sector size, Thus causing the read by grub to an incorrect offset from what was originally intended. Considering the 512 sector size of sysfs data the actual sector needs to be modified corresponding to disk sector size. Signed-off-by: Mukesh Kumar Chaurasiya <mchauras@linux.vnet.ibm.com> --- grub-core/osdep/linux/hostdisk.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) --- a/grub-core/osdep/linux/hostdisk.c +++ b/grub-core/osdep/linux/hostdisk.c @@ -199,8 +199,15 @@ #pragma GCC diagnostic ignored "-Wformat-nonliteral" +static inline grub_disk_addr_t +transform_sector (grub_disk_t disk, grub_disk_addr_t sector) +{ + return sector >> (disk->log_sector_size - GRUB_DISK_SECTOR_BITS); +} + static int -grub_hostdisk_linux_find_partition (char *dev, grub_disk_addr_t sector) +grub_hostdisk_linux_find_partition (const grub_disk_t disk, char *dev, + grub_disk_addr_t sector) { size_t len = strlen (dev); const char *format; @@ -265,7 +272,8 @@ if (fstat (fd, &st) < 0 || !grub_util_device_is_mapped_stat (&st) || !grub_util_get_dm_node_linear_info (st.st_rdev, 0, 0, &start)) - start = grub_util_find_partition_start_os (real_dev); + start = transform_sector (disk, + grub_util_find_partition_start_os (real_dev)); /* We don't care about errors here. */ grub_errno = GRUB_ERR_NONE; @@ -346,7 +354,8 @@ && strncmp (dev, "/dev/", 5) == 0) { if (sector >= part_start) - is_partition = grub_hostdisk_linux_find_partition (dev, part_start); + is_partition = grub_hostdisk_linux_find_partition (disk, dev, + part_start); else *max = part_start - sector; }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor