diff options
author | Richard Retanubun <RichardRetanubun@RuggedCom.com> | 2009-01-26 16:45:14 +0300 |
---|---|---|
committer | Wolfgang Denk <wd@denx.de> | 2009-01-28 01:03:57 +0300 |
commit | 50970839712dda35399e2fa83fe818df9354d618 (patch) | |
tree | fb9b8410b277709ba769d743467596704e5f675a /disk/part_efi.c | |
parent | b5b004ad8a0ac6f98bd5708ec8b22fbddd1c1042 (diff) | |
download | u-boot-50970839712dda35399e2fa83fe818df9354d618.tar.xz |
part_efi: Fix partition size calculation due to inclusive ending LBA.
The ending LBA is inclusive. Hence, the partition size should be
((ending-LBA + 1) - starting-LBA) to get the proper partition size.
This is confirmed against the results from the parted tool.
(e.g. use parted /dev/sda -s unit S print) and observe the size.
Signed-off-by: Richard Retanubun <RichardRetanubun@RuggedCom.com>
Diffstat (limited to 'disk/part_efi.c')
-rw-r--r-- | disk/part_efi.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/disk/part_efi.c b/disk/part_efi.c index cc188ee899..d8a81115c5 100644 --- a/disk/part_efi.c +++ b/disk/part_efi.c @@ -163,7 +163,9 @@ int get_partition_info_efi(block_dev_desc_t * dev_desc, int part, /* The ulong casting limits the maximum disk size to 2 TB */ info->start = (ulong) le64_to_int((*pgpt_pte)[part - 1].starting_lba); - info->size = (ulong) le64_to_int((*pgpt_pte)[part - 1].ending_lba) - info->start; + /* The ending LBA is inclusive, to calculate size, add 1 to it */ + info->size = ((ulong)le64_to_int((*pgpt_pte)[part - 1].ending_lba) + 1) + - info->start; info->blksz = GPT_BLOCK_SIZE; sprintf((char *)info->name, "%s%d\n", GPT_ENTRY_NAME, part); |