Commit 3e34cf7bffb87f3a96a87a4d1e0a76df7322b3c1
Committed by
Tom Rini
1 parent
c8876f1c72
Exists in
master
and in
53 other branches
gpt: fix partion size limit
Currently, in gpt command, partion size is converted from string to unsigned long type using 'ustrtol' function. That type limits the partition size to 4GB. This patch changes the conversion function to 'ustrtoll' to return unsigned long long type. Signed-off-by: Piotr Wilczek <p.wilczek@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Showing 1 changed file with 6 additions and 4 deletions Side-by-side Diff
common/cmd_gpt.c
... | ... | @@ -27,6 +27,7 @@ |
27 | 27 | #include <part_efi.h> |
28 | 28 | #include <exports.h> |
29 | 29 | #include <linux/ctype.h> |
30 | +#include <div64.h> | |
30 | 31 | |
31 | 32 | #ifndef CONFIG_PARTITION_UUIDS |
32 | 33 | #error CONFIG_PARTITION_UUIDS must be enabled for CONFIG_CMD_GPT to be enabled |
... | ... | @@ -131,6 +132,7 @@ |
131 | 132 | int p_count; |
132 | 133 | disk_partition_t *parts; |
133 | 134 | int errno = 0; |
135 | + uint64_t size_ll, start_ll; | |
134 | 136 | |
135 | 137 | debug("%s: MMC lba num: 0x%x %d\n", __func__, |
136 | 138 | (unsigned int)dev_desc->lba, (unsigned int)dev_desc->lba); |
... | ... | @@ -217,8 +219,8 @@ |
217 | 219 | } |
218 | 220 | if (extract_env(val, &p)) |
219 | 221 | p = val; |
220 | - parts[i].size = ustrtoul(p, &p, 0); | |
221 | - parts[i].size /= dev_desc->blksz; | |
222 | + size_ll = ustrtoull(p, &p, 0); | |
223 | + parts[i].size = lldiv(size_ll, dev_desc->blksz); | |
222 | 224 | free(val); |
223 | 225 | |
224 | 226 | /* start address */ |
... | ... | @@ -226,8 +228,8 @@ |
226 | 228 | if (val) { /* start address is optional */ |
227 | 229 | if (extract_env(val, &p)) |
228 | 230 | p = val; |
229 | - parts[i].start = ustrtoul(p, &p, 0); | |
230 | - parts[i].start /= dev_desc->blksz; | |
231 | + start_ll = ustrtoull(p, &p, 0); | |
232 | + parts[i].start = lldiv(start_ll, dev_desc->blksz); | |
231 | 233 | free(val); |
232 | 234 | } |
233 | 235 | } |