summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2021-02-16 21:02:06 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2021-02-18 09:23:42 +0100
commit4665e1688440d0f381d3484adc00b195db033c3c (patch)
tree44e750922db88f4ef4bd911fb85e10f9fb75d5a1 /fs
parent5504426f88f331f02c81a517a27b7618bbab2761 (diff)
downloadbarebox-4665e1688440d0f381d3484adc00b195db033c3c.tar.gz
barebox-4665e1688440d0f381d3484adc00b195db033c3c.tar.xz
fs: ext4: support files exceeding 4G
ext4 redefines directory ACL to hold the most-significant 32-bit of the inode size for regular files. For directories, it can either be ACL or, when using largedir, the most-significant 32-bit of the directory size. Adapt the code take these upper 32-bit into consideration for determining regular file size. For directories, behavior remains unchanged as we neither support ACLs nor >= 4G directories Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'fs')
-rw-r--r--fs/ext4/ext4fs.c2
-rw-r--r--fs/ext4/ext_barebox.c2
-rw-r--r--fs/ext4/ext_common.h9
3 files changed, 11 insertions, 2 deletions
diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c
index be643a4487..54349aad3f 100644
--- a/fs/ext4/ext4fs.c
+++ b/fs/ext4/ext4fs.c
@@ -55,7 +55,7 @@ loff_t ext4fs_read_file(struct ext2fs_node *node, loff_t pos,
int log2blocksize = LOG2_EXT2_BLOCK_SIZE(node->data);
const int blockshift = log2blocksize + DISK_SECTOR_BITS;
const int blocksize = 1 << blockshift;
- unsigned int filesize = le32_to_cpu(node->inode.size);
+ loff_t filesize = ext4_isize(node);
ssize_t ret;
struct ext_filesystem *fs = node->data->fs;
diff --git a/fs/ext4/ext_barebox.c b/fs/ext4/ext_barebox.c
index a68a783e1c..8f318a49c0 100644
--- a/fs/ext4/ext_barebox.c
+++ b/fs/ext4/ext_barebox.c
@@ -221,7 +221,7 @@ struct inode *ext_get_inode(struct super_block *sb, int ino)
inode->i_ino = ino;
inode->i_mode = le16_to_cpu(node->inode.mode);
- inode->i_size = le32_to_cpu(node->inode.size);
+ inode->i_size = ext4_isize(node);
switch (inode->i_mode & S_IFMT) {
default:
diff --git a/fs/ext4/ext_common.h b/fs/ext4/ext_common.h
index 350cc6efe5..37575d2a1a 100644
--- a/fs/ext4/ext_common.h
+++ b/fs/ext4/ext_common.h
@@ -232,4 +232,13 @@ struct ext2_data {
struct ext4fs_indir_block indir1, indir2, indir3;
};
+static inline loff_t ext4_isize(struct ext2fs_node *node)
+{
+ if (S_ISREG(le16_to_cpu(node->inode.mode)))
+ return ((loff_t)le32_to_cpu(node->inode.size_high) << 32) |
+ le32_to_cpu(node->inode.size);
+
+ return (loff_t) le32_to_cpu(node->inode.size);
+}
+
#endif