mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-20 22:48:22 +00:00
osdep/linux/hostdisk: 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 the 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> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
1 parent
53e0726285
commit
f7564844f8
2 files changed
+11
-3
No files matched your search
@@ -198,7 +198,8 @@ have_devfs (void)
|
||||
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
||||
|
||||
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;
|
||||
@@ -263,7 +264,7 @@ grub_hostdisk_linux_find_partition (char *dev, grub_disk_addr_t sector)
|
||||
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 = grub_disk_to_native_sector (disk, grub_util_find_partition_start_os (real_dev));
|
||||
/* We don't care about errors here. */
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
||||
@@ -344,7 +345,7 @@ grub_util_fd_open_device (const grub_disk_t disk, grub_disk_addr_t sector, int f
|
||||
&& 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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user