summaryrefslogtreecommitdiff
path: root/fs/ext4/ext4fs.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext4/ext4fs.c')
-rw-r--r--fs/ext4/ext4fs.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c
index 1727da2dc6d..3c79a889bc2 100644
--- a/fs/ext4/ext4fs.c
+++ b/fs/ext4/ext4fs.c
@@ -27,6 +27,7 @@
#include <ext4fs.h>
#include <malloc.h>
#include <part.h>
+#include <rtc.h>
#include <u-boot/uuid.h>
#include "ext4_common.h"
@@ -101,17 +102,21 @@ int ext4fs_read_file(struct ext2fs_node *node, loff_t pos,
blockcnt = lldiv(((len + pos) + blocksize - 1), blocksize);
for (i = lldiv(pos, blocksize); i < blockcnt; i++) {
- long int blknr;
+ lbaint_t blknr;
+ long blknr_and_status;
int blockoff = pos - (blocksize * i);
int blockend = blocksize;
int skipfirst = 0;
- blknr = read_allocated_block(&node->inode, i, &cache);
- if (blknr < 0) {
+ blknr_and_status = read_allocated_block(&node->inode, i, &cache);
+ if (blknr_and_status < 0) {
ext_cache_fini(&cache);
return -1;
}
- blknr = blknr << log2_fs_blocksize;
+ /* Block number could becomes very large when CONFIG_SYS_64BIT_LBA is enabled
+ * and wrap around at max long int
+ */
+ blknr = (lbaint_t)blknr_and_status << log2_fs_blocksize;
/* Last block. */
if (i == blockcnt - 1) {
@@ -272,7 +277,7 @@ int ext4fs_readdir(struct fs_dir_stream *fs_dirs, struct fs_dirent **dentp)
sizeof(struct ext2_dirent),
(char *)&dirent, &actread);
if (ret < 0)
- return -ret;
+ return ret;
if (!dirent.direntlen)
return -EIO;