Commit 04735e9c5578dd4f3584be5454b9779e8e5c2af9

Authored by Frederic Leroy
Committed by Tom Rini
1 parent 0eb33ad253

Fix ext2/ext4 filesystem accesses beyond 2TiB

With CONFIG_SYS_64BIT_LBA, lbaint_t gets defined as a 64-bit type,
which is required to represent block numbers for storage devices that
exceed 2TiB (the block size usually is 512B), e.g. recent hard drives

We now use lbaint_t for partition offset to reflect the lbaint_t change,
and access partitions beyond or crossing the 2.1TiB limit.
This required changes to signature of ext4fs_devread(), and type of all
variables relatives to block sector.

ext2/ext4 fs uses logical block represented by a 32 bit value. Logical
block is a multiple of device block sector. To avoid overflow problem
when calling ext4fs_devread(), we need to cast the sector parameter.

Signed-off-by: Frédéric Leroy <fredo@starox.org>

Showing 12 changed files with 93 additions and 70 deletions Side-by-side Diff

... ... @@ -67,7 +67,8 @@
67 67 "Name: %.32s Type: %.32s\n", intf, dev, part, info.name,
68 68 info.type);
69 69  
70   - debug("First Block: %ld, # of blocks: %ld, Block Size: %ld\n",
  70 + debug("First Block: " LBAFU ", # of blocks: " LBAFU
  71 + ", Block Size: %ld\n",
71 72 info.start, info.size, info.blksz);
72 73  
73 74 if (dev_desc->block_read(dev, info.start, 1, (ulong *) addr) != 1) {
... ... @@ -200,8 +200,8 @@
200 200 uuid_string(gpt_pte[part - 1].unique_partition_guid.b, info->uuid);
201 201 #endif
202 202  
203   - debug("%s: start 0x%lX, size 0x%lX, name %s", __func__,
204   - info->start, info->size, info->name);
  203 + debug("%s: start 0x" LBAF ", size 0x" LBAF ", name %s", __func__,
  204 + info->start, info->size, info->name);
205 205  
206 206 /* Remember to free pte */
207 207 free(gpt_pte);
... ... @@ -431,7 +431,7 @@
431 431 gpt_e[i].partition_name[k] =
432 432 (efi_char16_t)(partitions[i].name[k]);
433 433  
434   - debug("%s: name: %s offset[%d]: 0x%x size[%d]: 0x%lx\n",
  434 + debug("%s: name: %s offset[%d]: 0x%x size[%d]: 0x" LBAF "\n",
435 435 __func__, partitions[i].name, i,
436 436 offset, i, partitions[i].size);
437 437 }
... ... @@ -249,8 +249,8 @@
249 249 printf("Part Start Sect x Size Type\n");
250 250 i=0;
251 251 do {
252   - printf (" %2d %8ld %8ld %6ld %.32s\n",
253   - i, info.start, info.size, info.blksz, info.type);
  252 + printf(" %2d " LBAFU " " LBAFU " %6ld %.32s\n",
  253 + i, info.start, info.size, info.blksz, info.type);
254 254 i++;
255 255 } while (get_partition_info_iso_verb(dev_desc,i,&info,0)!=-1);
256 256 }
... ... @@ -42,7 +42,7 @@
42 42 #include <ext_common.h>
43 43 #include "ext4_common.h"
44 44  
45   -unsigned long part_offset;
  45 +lbaint_t part_offset;
46 46  
47 47 static block_dev_desc_t *ext4fs_block_dev_desc;
48 48 static disk_partition_t *part_info;
... ... @@ -58,7 +58,7 @@
58 58 get_fs()->dev_desc->log2blksz;
59 59 }
60 60  
61   -int ext4fs_devread(int sector, int byte_offset, int byte_len, char *buf)
  61 +int ext4fs_devread(lbaint_t sector, int byte_offset, int byte_len, char *buf)
62 62 {
63 63 unsigned block_len;
64 64 int log2blksz = ext4fs_block_dev_desc->log2blksz;
... ... @@ -74,7 +74,8 @@
74 74 if ((sector < 0) ||
75 75 ((sector + ((byte_offset + byte_len - 1) >> log2blksz))
76 76 >= part_info->size)) {
77   - printf("%s read outside partition %d\n", __func__, sector);
  77 + printf("%s read outside partition " LBAFU "\n", __func__,
  78 + sector);
78 79 return 0;
79 80 }
80 81  
... ... @@ -82,7 +83,7 @@
82 83 sector += byte_offset >> log2blksz;
83 84 byte_offset &= ext4fs_block_dev_desc->blksz - 1;
84 85  
85   - debug(" <%d, %d, %d>\n", sector, byte_offset, byte_len);
  86 + debug(" <" LBAFU ", %d, %d>\n", sector, byte_offset, byte_len);
86 87  
87 88 if (byte_offset != 0) {
88 89 /* read first part which isn't aligned with start of sector */
fs/ext4/ext4_common.c
... ... @@ -84,7 +84,7 @@
84 84  
85 85 if ((startblock + (size >> log2blksz)) >
86 86 (part_offset + fs->total_sect)) {
87   - printf("part_offset is %lu\n", part_offset);
  87 + printf("part_offset is " LBAFU "\n", part_offset);
88 88 printf("total_sector is %llu\n", fs->total_sect);
89 89 printf("error: overflow occurs\n");
90 90 return;
... ... @@ -405,7 +405,7 @@
405 405 previous_blknr = root_blknr;
406 406 }
407 407  
408   - status = ext4fs_devread(first_block_no_of_root
  408 + status = ext4fs_devread((lbaint_t)first_block_no_of_root
409 409 * fs->sect_perblk,
410 410 0, fs->blksz, root_first_block_buffer);
411 411 if (status == 0)
... ... @@ -545,7 +545,7 @@
545 545 if (!block_buffer)
546 546 goto fail;
547 547  
548   - status = ext4fs_devread(blknr * fs->sect_perblk,
  548 + status = ext4fs_devread((lbaint_t)blknr * fs->sect_perblk,
549 549 0, fs->blksz, (char *)block_buffer);
550 550 if (status == 0)
551 551 goto fail;
... ... @@ -783,7 +783,7 @@
783 783 if (!root_first_block_buffer)
784 784 return -ENOMEM;
785 785 root_first_block_addr = root_first_block_buffer;
786   - status = ext4fs_devread(first_block_no_of_root *
  786 + status = ext4fs_devread((lbaint_t)first_block_no_of_root *
787 787 fs->sect_perblk, 0,
788 788 fs->blksz, root_first_block_buffer);
789 789 if (status == 0)
... ... @@ -895,7 +895,8 @@
895 895 fs->first_pass_bbmap++;
896 896 bgd[i].free_blocks--;
897 897 fs->sb->free_blocks--;
898   - status = ext4fs_devread(bgd[i].block_id *
  898 + status = ext4fs_devread((lbaint_t)
  899 + bgd[i].block_id *
899 900 fs->sect_perblk, 0,
900 901 fs->blksz,
901 902 journal_buffer);
... ... @@ -957,7 +958,7 @@
957 958 /* journal backup */
958 959 if (prev_bg_bitmap_index != bg_idx) {
959 960 memset(journal_buffer, '\0', fs->blksz);
960   - status = ext4fs_devread(bgd[bg_idx].block_id
  961 + status = ext4fs_devread((lbaint_t)bgd[bg_idx].block_id
961 962 * fs->sect_perblk,
962 963 0, fs->blksz, journal_buffer);
963 964 if (status == 0)
... ... @@ -1026,7 +1027,8 @@
1026 1027 bgd[i].free_inodes--;
1027 1028 bgd[i].bg_itable_unused--;
1028 1029 fs->sb->free_inodes--;
1029   - status = ext4fs_devread(bgd[i].inode_id *
  1030 + status = ext4fs_devread((lbaint_t)
  1031 + bgd[i].inode_id *
1030 1032 fs->sect_perblk, 0,
1031 1033 fs->blksz,
1032 1034 journal_buffer);
... ... @@ -1067,7 +1069,8 @@
1067 1069 /* journal backup */
1068 1070 if (prev_inode_bitmap_index != ibmap_idx) {
1069 1071 memset(journal_buffer, '\0', fs->blksz);
1070   - status = ext4fs_devread(bgd[ibmap_idx].inode_id
  1072 + status = ext4fs_devread((lbaint_t)
  1073 + bgd[ibmap_idx].inode_id
1071 1074 * fs->sect_perblk,
1072 1075 0, fs->blksz, journal_buffer);
1073 1076 if (status == 0)
... ... @@ -1129,7 +1132,7 @@
1129 1132 (*no_blks_reqd)++;
1130 1133 debug("SIPB %ld: %u\n", si_blockno, *total_remaining_blocks);
1131 1134  
1132   - status = ext4fs_devread(si_blockno * fs->sect_perblk,
  1135 + status = ext4fs_devread((lbaint_t)si_blockno * fs->sect_perblk,
1133 1136 0, fs->blksz, (char *)si_buffer);
1134 1137 memset(si_buffer, '\0', fs->blksz);
1135 1138 if (status == 0)
... ... @@ -1193,7 +1196,7 @@
1193 1196 debug("DIPB %ld: %u\n", di_blockno_parent,
1194 1197 *total_remaining_blocks);
1195 1198  
1196   - status = ext4fs_devread(di_blockno_parent *
  1199 + status = ext4fs_devread((lbaint_t)di_blockno_parent *
1197 1200 fs->sect_perblk, 0,
1198 1201 fs->blksz, (char *)di_parent_buffer);
1199 1202  
... ... @@ -1224,7 +1227,7 @@
1224 1227 debug("DICB %ld: %u\n", di_blockno_child,
1225 1228 *total_remaining_blocks);
1226 1229  
1227   - status = ext4fs_devread(di_blockno_child *
  1230 + status = ext4fs_devread((lbaint_t)di_blockno_child *
1228 1231 fs->sect_perblk, 0,
1229 1232 fs->blksz,
1230 1233 (char *)di_child_buff);
... ... @@ -1447,7 +1450,8 @@
1447 1450 block = le32_to_cpu(index[i].ei_leaf_hi);
1448 1451 block = (block << 32) + le32_to_cpu(index[i].ei_leaf_lo);
1449 1452  
1450   - if (ext4fs_devread(block << log2_blksz, 0, fs->blksz, buf))
  1453 + if (ext4fs_devread((lbaint_t)block << log2_blksz, 0, fs->blksz,
  1454 + buf))
1451 1455 ext_block = (struct ext4_extent_header *)buf;
1452 1456 else
1453 1457 return 0;
... ... @@ -1470,7 +1474,8 @@
1470 1474 debug("ext4fs read %d group descriptor (blkno %ld blkoff %u)\n",
1471 1475 group, blkno, blkoff);
1472 1476  
1473   - return ext4fs_devread(blkno << (LOG2_BLOCK_SIZE(data) - log2blksz),
  1477 + return ext4fs_devread((lbaint_t)blkno <<
  1478 + (LOG2_BLOCK_SIZE(data) - log2blksz),
1474 1479 blkoff, sizeof(struct ext2_block_group),
1475 1480 (char *)blkgrp);
1476 1481 }
... ... @@ -1497,8 +1502,8 @@
1497 1502 (ino % __le32_to_cpu(sblock->inodes_per_group)) / inodes_per_block;
1498 1503 blkoff = (ino % inodes_per_block) * fs->inodesz;
1499 1504 /* Read the inode. */
1500   - status = ext4fs_devread(blkno << (LOG2_BLOCK_SIZE(data) - log2blksz),
1501   - blkoff,
  1505 + status = ext4fs_devread((lbaint_t)blkno << (LOG2_BLOCK_SIZE(data) -
  1506 + log2blksz), blkoff,
1502 1507 sizeof(struct ext2_inode), (char *)inode);
1503 1508 if (status == 0)
1504 1509 return 0;
... ... @@ -1597,7 +1602,7 @@
1597 1602 if ((__le32_to_cpu(inode->b.blocks.indir_block) <<
1598 1603 log2_blksz) != ext4fs_indir1_blkno) {
1599 1604 status =
1600   - ext4fs_devread(__le32_to_cpu
  1605 + ext4fs_devread((lbaint_t)__le32_to_cpu
1601 1606 (inode->b.blocks.
1602 1607 indir_block) << log2_blksz, 0,
1603 1608 blksz, (char *)ext4fs_indir1_block);
... ... @@ -1646,7 +1651,7 @@
1646 1651 if ((__le32_to_cpu(inode->b.blocks.double_indir_block) <<
1647 1652 log2_blksz) != ext4fs_indir1_blkno) {
1648 1653 status =
1649   - ext4fs_devread(__le32_to_cpu
  1654 + ext4fs_devread((lbaint_t)__le32_to_cpu
1650 1655 (inode->b.blocks.
1651 1656 double_indir_block) << log2_blksz,
1652 1657 0, blksz,
... ... @@ -1686,7 +1691,7 @@
1686 1691 }
1687 1692 if ((__le32_to_cpu(ext4fs_indir1_block[rblock / perblock]) <<
1688 1693 log2_blksz) != ext4fs_indir2_blkno) {
1689   - status = ext4fs_devread(__le32_to_cpu
  1694 + status = ext4fs_devread((lbaint_t)__le32_to_cpu
1690 1695 (ext4fs_indir1_block
1691 1696 [rblock /
1692 1697 perblock]) << log2_blksz, 0,
... ... @@ -1738,7 +1743,8 @@
1738 1743 if ((__le32_to_cpu(inode->b.blocks.triple_indir_block) <<
1739 1744 log2_blksz) != ext4fs_indir1_blkno) {
1740 1745 status = ext4fs_devread
1741   - (__le32_to_cpu(inode->b.blocks.triple_indir_block)
  1746 + ((lbaint_t)
  1747 + __le32_to_cpu(inode->b.blocks.triple_indir_block)
1742 1748 << log2_blksz, 0, blksz,
1743 1749 (char *)ext4fs_indir1_block);
1744 1750 if (status == 0) {
... ... @@ -1778,7 +1784,7 @@
1778 1784 perblock_parent]) <<
1779 1785 log2_blksz)
1780 1786 != ext4fs_indir2_blkno) {
1781   - status = ext4fs_devread(__le32_to_cpu
  1787 + status = ext4fs_devread((lbaint_t)__le32_to_cpu
1782 1788 (ext4fs_indir1_block
1783 1789 [rblock /
1784 1790 perblock_parent]) <<
... ... @@ -1823,7 +1829,7 @@
1823 1829 perblock_child]) <<
1824 1830 log2_blksz) != ext4fs_indir3_blkno) {
1825 1831 status =
1826   - ext4fs_devread(__le32_to_cpu
  1832 + ext4fs_devread((lbaint_t)__le32_to_cpu
1827 1833 (ext4fs_indir2_block
1828 1834 [(rblock / perblock_child)
1829 1835 % (blksz / 4)]) << log2_blksz, 0,
fs/ext4/ext4_journal.c
... ... @@ -360,7 +360,8 @@
360 360 (struct ext2_inode *)&inode_journal);
361 361 blknr = read_allocated_block((struct ext2_inode *)
362 362 &inode_journal, i);
363   - ext4fs_devread(blknr * fs->sect_perblk, 0, fs->blksz, temp_buff);
  363 + ext4fs_devread((lbaint_t)blknr * fs->sect_perblk, 0, fs->blksz,
  364 + temp_buff);
364 365 p_jdb = (char *)temp_buff;
365 366 jdb = (struct journal_header_t *) temp_buff;
366 367 ofs = sizeof(struct journal_header_t);
... ... @@ -384,7 +385,7 @@
384 385 continue;
385 386 }
386 387 blknr = read_allocated_block(&inode_journal, i);
387   - ext4fs_devread(blknr * fs->sect_perblk, 0,
  388 + ext4fs_devread((lbaint_t)blknr * fs->sect_perblk, 0,
388 389 fs->blksz, metadata_buff);
389 390 put_ext4((uint64_t)(be32_to_cpu(tag->block) * fs->blksz),
390 391 metadata_buff, (uint32_t) fs->blksz);
... ... @@ -431,7 +432,8 @@
431 432  
432 433 ext4fs_read_inode(ext4fs_root, EXT2_JOURNAL_INO, &inode_journal);
433 434 blknr = read_allocated_block(&inode_journal, EXT2_JOURNAL_SUPERBLOCK);
434   - ext4fs_devread(blknr * fs->sect_perblk, 0, fs->blksz, temp_buff);
  435 + ext4fs_devread((lbaint_t)blknr * fs->sect_perblk, 0, fs->blksz,
  436 + temp_buff);
435 437 jsb = (struct journal_superblock_t *) temp_buff;
436 438  
437 439 if (fs->sb->feature_incompat & EXT3_FEATURE_INCOMPAT_RECOVER) {
... ... @@ -455,7 +457,7 @@
455 457 while (1) {
456 458 blknr = read_allocated_block(&inode_journal, i);
457 459 memset(temp_buff1, '\0', fs->blksz);
458   - ext4fs_devread(blknr * fs->sect_perblk,
  460 + ext4fs_devread((lbaint_t)blknr * fs->sect_perblk,
459 461 0, fs->blksz, temp_buff1);
460 462 jdb = (struct journal_header_t *) temp_buff1;
461 463  
... ... @@ -574,7 +576,8 @@
574 576 ext4fs_read_inode(ext4fs_root, EXT2_JOURNAL_INO, &inode_journal);
575 577 jsb_blknr = read_allocated_block(&inode_journal,
576 578 EXT2_JOURNAL_SUPERBLOCK);
577   - ext4fs_devread(jsb_blknr * fs->sect_perblk, 0, fs->blksz, temp_buff);
  579 + ext4fs_devread((lbaint_t)jsb_blknr * fs->sect_perblk, 0, fs->blksz,
  580 + temp_buff);
578 581 jsb = (struct journal_superblock_t *) temp_buff;
579 582  
580 583 jdb.h_blocktype = cpu_to_be32(EXT3_JOURNAL_DESCRIPTOR_BLOCK);
581 584  
... ... @@ -621,10 +624,12 @@
621 624 if (!temp_buff)
622 625 return;
623 626  
624   - ext4fs_read_inode(ext4fs_root, EXT2_JOURNAL_INO, &inode_journal);
  627 + ext4fs_read_inode(ext4fs_root, EXT2_JOURNAL_INO,
  628 + &inode_journal);
625 629 jsb_blknr = read_allocated_block(&inode_journal,
626 630 EXT2_JOURNAL_SUPERBLOCK);
627   - ext4fs_devread(jsb_blknr * fs->sect_perblk, 0, fs->blksz, temp_buff);
  631 + ext4fs_devread((lbaint_t)jsb_blknr * fs->sect_perblk, 0, fs->blksz,
  632 + temp_buff);
628 633 jsb = (struct journal_superblock_t *) temp_buff;
629 634  
630 635 jdb.h_blocktype = cpu_to_be32(EXT3_JOURNAL_COMMIT_BLOCK);
fs/ext4/ext4_write.c
... ... @@ -88,8 +88,8 @@
88 88 if (!fs->gdtable)
89 89 return -ENOMEM;
90 90 /* read the group descriptor table */
91   - status = ext4fs_devread(fs->gdtable_blkno * fs->sect_perblk, 0,
92   - fs->blksz * fs->no_blk_pergdt, fs->gdtable);
  91 + status = ext4fs_devread((lbaint_t)fs->gdtable_blkno * fs->sect_perblk,
  92 + 0, fs->blksz * fs->no_blk_pergdt, fs->gdtable);
93 93 if (status == 0)
94 94 goto fail;
95 95  
... ... @@ -142,7 +142,7 @@
142 142 /* journal backup */
143 143 if (prev_bg_bmap_idx != bg_idx) {
144 144 status =
145   - ext4fs_devread(bgd[bg_idx].block_id *
  145 + ext4fs_devread((lbaint_t)bgd[bg_idx].block_id *
146 146 fs->sect_perblk, 0, fs->blksz,
147 147 journal_buffer);
148 148 if (status == 0)
... ... @@ -186,8 +186,8 @@
186 186 }
187 187 DIB_start_addr = (unsigned int *)di_buffer;
188 188 blknr = inode->b.blocks.double_indir_block;
189   - status = ext4fs_devread(blknr * fs->sect_perblk, 0, fs->blksz,
190   - (char *)di_buffer);
  189 + status = ext4fs_devread((lbaint_t)blknr * fs->sect_perblk, 0,
  190 + fs->blksz, (char *)di_buffer);
191 191 for (i = 0; i < fs->blksz / sizeof(int); i++) {
192 192 if (*di_buffer == 0)
193 193 break;
... ... @@ -208,7 +208,8 @@
208 208 fs->sb->free_blocks++;
209 209 /* journal backup */
210 210 if (prev_bg_bmap_idx != bg_idx) {
211   - status = ext4fs_devread(bgd[bg_idx].block_id
  211 + status = ext4fs_devread((lbaint_t)
  212 + bgd[bg_idx].block_id
212 213 * fs->sect_perblk, 0,
213 214 fs->blksz,
214 215 journal_buffer);
... ... @@ -238,7 +239,7 @@
238 239 /* journal backup */
239 240 if (prev_bg_bmap_idx != bg_idx) {
240 241 memset(journal_buffer, '\0', fs->blksz);
241   - status = ext4fs_devread(bgd[bg_idx].block_id *
  242 + status = ext4fs_devread((lbaint_t)bgd[bg_idx].block_id *
242 243 fs->sect_perblk, 0, fs->blksz,
243 244 journal_buffer);
244 245 if (status == 0)
... ... @@ -287,8 +288,8 @@
287 288 }
288 289 tib_start_addr = (unsigned int *)tigp_buffer;
289 290 blknr = inode->b.blocks.triple_indir_block;
290   - status = ext4fs_devread(blknr * fs->sect_perblk, 0, fs->blksz,
291   - (char *)tigp_buffer);
  291 + status = ext4fs_devread((lbaint_t)blknr * fs->sect_perblk, 0,
  292 + fs->blksz, (char *)tigp_buffer);
292 293 for (i = 0; i < fs->blksz / sizeof(int); i++) {
293 294 if (*tigp_buffer == 0)
294 295 break;
... ... @@ -298,7 +299,7 @@
298 299 if (!tip_buffer)
299 300 goto fail;
300 301 tipb_start_addr = (unsigned int *)tip_buffer;
301   - status = ext4fs_devread((*tigp_buffer) *
  302 + status = ext4fs_devread((lbaint_t)(*tigp_buffer) *
302 303 fs->sect_perblk, 0, fs->blksz,
303 304 (char *)tip_buffer);
304 305 for (j = 0; j < fs->blksz / sizeof(int); j++) {
... ... @@ -325,6 +326,7 @@
325 326 if (prev_bg_bmap_idx != bg_idx) {
326 327 status =
327 328 ext4fs_devread(
  329 + (lbaint_t)
328 330 bgd[bg_idx].block_id *
329 331 fs->sect_perblk, 0,
330 332 fs->blksz,
... ... @@ -365,7 +367,8 @@
365 367 if (prev_bg_bmap_idx != bg_idx) {
366 368 memset(journal_buffer, '\0', fs->blksz);
367 369 status =
368   - ext4fs_devread(bgd[bg_idx].block_id *
  370 + ext4fs_devread((lbaint_t)
  371 + bgd[bg_idx].block_id *
369 372 fs->sect_perblk, 0,
370 373 fs->blksz, journal_buffer);
371 374 if (status == 0)
... ... @@ -394,7 +397,7 @@
394 397 /* journal backup */
395 398 if (prev_bg_bmap_idx != bg_idx) {
396 399 memset(journal_buffer, '\0', fs->blksz);
397   - status = ext4fs_devread(bgd[bg_idx].block_id *
  400 + status = ext4fs_devread((lbaint_t)bgd[bg_idx].block_id *
398 401 fs->sect_perblk, 0, fs->blksz,
399 402 journal_buffer);
400 403 if (status == 0)
... ... @@ -480,7 +483,8 @@
480 483 /* journal backup */
481 484 if (prev_bg_bmap_idx != bg_idx) {
482 485 status =
483   - ext4fs_devread(bgd[bg_idx].block_id *
  486 + ext4fs_devread((lbaint_t)
  487 + bgd[bg_idx].block_id *
484 488 fs->sect_perblk, 0,
485 489 fs->blksz, journal_buffer);
486 490 if (status == 0)
... ... @@ -524,7 +528,8 @@
524 528 /* journal backup */
525 529 if (prev_bg_bmap_idx != bg_idx) {
526 530 memset(journal_buffer, '\0', fs->blksz);
527   - status = ext4fs_devread(bgd[bg_idx].block_id
  531 + status = ext4fs_devread((lbaint_t)
  532 + bgd[bg_idx].block_id
528 533 * fs->sect_perblk,
529 534 0, fs->blksz,
530 535 journal_buffer);
... ... @@ -555,7 +560,7 @@
555 560 if (!read_buffer)
556 561 goto fail;
557 562 start_block_address = read_buffer;
558   - status = ext4fs_devread(blkno * fs->sect_perblk,
  563 + status = ext4fs_devread((lbaint_t)blkno * fs->sect_perblk,
559 564 0, fs->blksz, read_buffer);
560 565 if (status == 0)
561 566 goto fail;
... ... @@ -578,7 +583,7 @@
578 583 fs->sb->free_inodes++;
579 584 /* journal backup */
580 585 memset(journal_buffer, '\0', fs->blksz);
581   - status = ext4fs_devread(bgd[ibmap_idx].inode_id *
  586 + status = ext4fs_devread((lbaint_t)bgd[ibmap_idx].inode_id *
582 587 fs->sect_perblk, 0, fs->blksz, journal_buffer);
583 588 if (status == 0)
584 589 goto fail;
... ... @@ -653,7 +658,8 @@
653 658  
654 659 for (i = 0; i < fs->no_blkgrp; i++) {
655 660 status =
656   - ext4fs_devread(fs->bgd[i].block_id * fs->sect_perblk, 0,
  661 + ext4fs_devread((lbaint_t)fs->bgd[i].block_id *
  662 + fs->sect_perblk, 0,
657 663 fs->blksz, (char *)fs->blk_bmaps[i]);
658 664 if (status == 0)
659 665 goto fail;
... ... @@ -670,7 +676,8 @@
670 676 }
671 677  
672 678 for (i = 0; i < fs->no_blkgrp; i++) {
673   - status = ext4fs_devread(fs->bgd[i].inode_id * fs->sect_perblk,
  679 + status = ext4fs_devread((lbaint_t)fs->bgd[i].inode_id *
  680 + fs->sect_perblk,
674 681 0, fs->blksz,
675 682 (char *)fs->inode_bmaps[i]);
676 683 if (status == 0)
... ... @@ -710,7 +717,7 @@
710 717 &inode_journal);
711 718 blknr = read_allocated_block(&inode_journal,
712 719 EXT2_JOURNAL_SUPERBLOCK);
713   - ext4fs_devread(blknr * fs->sect_perblk, 0, fs->blksz,
  720 + ext4fs_devread((lbaint_t)blknr * fs->sect_perblk, 0, fs->blksz,
714 721 temp_buff);
715 722 jsb = (struct journal_superblock_t *)temp_buff;
716 723 jsb->s_start = cpu_to_be32(0);
... ... @@ -934,7 +941,8 @@
934 941 (inodeno % __le32_to_cpu(sblock->inodes_per_group)) /
935 942 inodes_per_block;
936 943 blkoff = (inodeno % inodes_per_block) * fs->inodesz;
937   - ext4fs_devread(itable_blkno * fs->sect_perblk, 0, fs->blksz, temp_ptr);
  944 + ext4fs_devread((lbaint_t)itable_blkno * fs->sect_perblk, 0, fs->blksz,
  945 + temp_ptr);
938 946 if (ext4fs_log_journal(temp_ptr, itable_blkno))
939 947 goto fail;
940 948  
... ... @@ -954,7 +962,7 @@
954 962 blkoff = (parent_inodeno % inodes_per_block) * fs->inodesz;
955 963 if (parent_itable_blkno != itable_blkno) {
956 964 memset(temp_ptr, '\0', fs->blksz);
957   - ext4fs_devread(parent_itable_blkno * fs->sect_perblk,
  965 + ext4fs_devread((lbaint_t)parent_itable_blkno * fs->sect_perblk,
958 966 0, fs->blksz, temp_ptr);
959 967 if (ext4fs_log_journal(temp_ptr, parent_itable_blkno))
960 968 goto fail;
... ... @@ -62,16 +62,16 @@
62 62 {
63 63 struct ext_filesystem *fs = get_fs();
64 64 int i;
65   - int blockcnt;
  65 + lbaint_t blockcnt;
66 66 int log2blksz = fs->dev_desc->log2blksz;
67 67 int log2_fs_blocksize = LOG2_BLOCK_SIZE(node->data) - log2blksz;
68 68 int blocksize = (1 << (log2_fs_blocksize + log2blksz));
69 69 unsigned int filesize = __le32_to_cpu(node->inode.size);
70   - int previous_block_number = -1;
71   - int delayed_start = 0;
72   - int delayed_extent = 0;
73   - int delayed_skipfirst = 0;
74   - int delayed_next = 0;
  70 + lbaint_t previous_block_number = -1;
  71 + lbaint_t delayed_start = 0;
  72 + lbaint_t delayed_extent = 0;
  73 + lbaint_t delayed_skipfirst = 0;
  74 + lbaint_t delayed_next = 0;
75 75 char *delayed_buf = NULL;
76 76 short status;
77 77  
... ... @@ -82,7 +82,7 @@
82 82 blockcnt = ((len + pos) + blocksize - 1) / blocksize;
83 83  
84 84 for (i = pos / blocksize; i < blockcnt; i++) {
85   - int blknr;
  85 + lbaint_t blknr;
86 86 int blockoff = pos % blocksize;
87 87 int blockend = blocksize;
88 88 int skipfirst = 0;
... ... @@ -135,7 +135,7 @@
135 135 void ext4fs_close(void);
136 136 int ext4fs_ls(const char *dirname);
137 137 void ext4fs_free_node(struct ext2fs_node *node, struct ext2fs_node *currroot);
138   -int ext4fs_devread(int sector, int byte_offset, int byte_len, char *buf);
  138 +int ext4fs_devread(lbaint_t sector, int byte_offset, int byte_len, char *buf);
139 139 void ext4fs_set_blk_dev(block_dev_desc_t *rbdd, disk_partition_t *info);
140 140 long int read_allocated_block(struct ext2_inode *inode, int fileblock);
141 141 int ext4fs_probe(block_dev_desc_t *fs_dev_desc,
include/ext_common.h
... ... @@ -180,7 +180,7 @@
180 180 struct ext2fs_node diropen;
181 181 };
182 182  
183   -extern unsigned long part_offset;
  183 +extern lbaint_t part_offset;
184 184  
185 185 int do_ext2ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
186 186 int do_ext2load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
... ... @@ -44,9 +44,11 @@
44 44 #ifdef CONFIG_SYS_64BIT_LBA
45 45 typedef uint64_t lbaint_t;
46 46 #define LBAF "%llx"
  47 +#define LBAFU "%llu"
47 48 #else
48 49 typedef ulong lbaint_t;
49 50 #define LBAF "%lx"
  51 +#define LBAFU "%lu"
50 52 #endif
51 53  
52 54 /*
... ... @@ -97,8 +97,8 @@
97 97 #define DEV_TYPE_OPDISK 0x07 /* optical disk */
98 98  
99 99 typedef struct disk_partition {
100   - ulong start; /* # of first block in partition */
101   - ulong size; /* number of blocks in partition */
  100 + lbaint_t start; /* # of first block in partition */
  101 + lbaint_t size; /* number of blocks in partition */
102 102 ulong blksz; /* block size in bytes */
103 103 uchar name[32]; /* partition name */
104 104 uchar type[32]; /* string type description */