disk: Rename grub_disk_get_size() to grub_disk_native_sectors()

The function grub_disk_get_size() is confusingly named because it actually
returns a sector count where the sectors are sized in the GRUB native sector
size. Rename to something more appropriate.

Suggested-by: Daniel Kiper <daniel.kiper@oracle.com>
Signed-off-by: Glenn Washburn <development@efficientek.com>
Reviewed-by: Patrick Steinhardt <ps@pks.im>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
Glenn Washburn authored and Daniel Kiper committed 2020-12-12 01:19:03 +01:00
1 parent 85307c34e8
commit 880dfd8f40
19 files changed
+38 -38

No files matched your search

+8 -8
View File
@@ -148,16 +148,16 @@ grub_cbfs_mount (grub_disk_t disk)
grub_off_t header_off;
struct cbfs_header head;
if (grub_disk_get_size (disk) == GRUB_DISK_SIZE_UNKNOWN)
if (grub_disk_native_sectors (disk) == GRUB_DISK_SIZE_UNKNOWN)
goto fail;
if (grub_disk_read (disk, grub_disk_get_size (disk) - 1,
if (grub_disk_read (disk, grub_disk_native_sectors (disk) - 1,
GRUB_DISK_SECTOR_SIZE - sizeof (ptr),
sizeof (ptr), &ptr))
goto fail;
ptr = grub_cpu_to_le32 (ptr);
header_off = (grub_disk_get_size (disk) << GRUB_DISK_SECTOR_BITS)
header_off = (grub_disk_native_sectors (disk) << GRUB_DISK_SECTOR_BITS)
+ (grub_int32_t) ptr;
if (grub_disk_read (disk, 0, header_off,
@@ -171,16 +171,16 @@ grub_cbfs_mount (grub_disk_t disk)
if (!data)
goto fail;
data->cbfs_start = (grub_disk_get_size (disk) << GRUB_DISK_SECTOR_BITS)
data->cbfs_start = (grub_disk_native_sectors (disk) << GRUB_DISK_SECTOR_BITS)
- (grub_be_to_cpu32 (head.romsize) - grub_be_to_cpu32 (head.offset));
data->cbfs_end = (grub_disk_get_size (disk) << GRUB_DISK_SECTOR_BITS)
data->cbfs_end = (grub_disk_native_sectors (disk) << GRUB_DISK_SECTOR_BITS)
- grub_be_to_cpu32 (head.bootblocksize);
data->cbfs_align = grub_be_to_cpu32 (head.align);
if (data->cbfs_start >= (grub_disk_get_size (disk) << GRUB_DISK_SECTOR_BITS))
if (data->cbfs_start >= (grub_disk_native_sectors (disk) << GRUB_DISK_SECTOR_BITS))
goto fail;
if (data->cbfs_end > (grub_disk_get_size (disk) << GRUB_DISK_SECTOR_BITS))
data->cbfs_end = (grub_disk_get_size (disk) << GRUB_DISK_SECTOR_BITS);
if (data->cbfs_end > (grub_disk_native_sectors (disk) << GRUB_DISK_SECTOR_BITS))
data->cbfs_end = (grub_disk_native_sectors (disk) << GRUB_DISK_SECTOR_BITS);
data->next_hofs = data->cbfs_start;
+1 -1
View File
@@ -753,7 +753,7 @@ grub_nilfs2_load_sb (struct grub_nilfs2_data *data)
partition_size = (grub_le_to_cpu64 (data->sblock.s_dev_size)
>> GRUB_DISK_SECTOR_BITS);
else
partition_size = grub_disk_get_size (disk);
partition_size = grub_disk_native_sectors (disk);
if (partition_size != GRUB_DISK_SIZE_UNKNOWN)
{
/* Read second super block. */
+2 -2
View File
@@ -1175,7 +1175,7 @@ scan_disk (grub_device_t dev, struct grub_zfs_data *data,
desc.original = original;
/* Don't check back labels on CDROM. */
if (grub_disk_get_size (dev->disk) == GRUB_DISK_SIZE_UNKNOWN)
if (grub_disk_native_sectors (dev->disk) == GRUB_DISK_SIZE_UNKNOWN)
vdevnum = VDEV_LABELS / 2;
for (label = 0; ubbest == NULL && label < vdevnum; label++)
@@ -1184,7 +1184,7 @@ scan_disk (grub_device_t dev, struct grub_zfs_data *data,
= label * (sizeof (vdev_label_t) >> SPA_MINBLOCKSHIFT)
+ ((VDEV_SKIP_SIZE + VDEV_BOOT_HEADER_SIZE) >> SPA_MINBLOCKSHIFT)
+ (label < VDEV_LABELS / 2 ? 0 :
ALIGN_DOWN (grub_disk_get_size (dev->disk), sizeof (vdev_label_t))
ALIGN_DOWN (grub_disk_native_sectors (dev->disk), sizeof (vdev_label_t))
- VDEV_LABELS * (sizeof (vdev_label_t) >> SPA_MINBLOCKSHIFT));
/* Read in the uberblock ring (128K). */