Skip to content

Commit e83874d

Browse files
Fix fs.stat for large file sizes
The the size of an image was > ~4GB (max value that could be stored in a 32-bit integer the stat function threw an error - there was a type mismatch between node and the c function that combined the upper and lower 32 bits of the image size that is stored in the inode. Change-type: patch Signed-off-by: Ryan Cooke<ryan@balena.io>
1 parent 7028be1 commit e83874d

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/glue.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,8 @@ errcode_t update_xtime(ext2_file_t file, bool a, bool c, bool m) {
283283
return err;
284284
}
285285

286-
unsigned long getUInt64Number(unsigned long long hi, unsigned long long lo) {
287-
return lo | (hi << 32);
286+
double getUInt64Number(unsigned long long hi, unsigned long long lo) {
287+
return (double) ((hi << 32) | lo);
288288
}
289289
// ------------------------
290290

@@ -1377,7 +1377,7 @@ int node_ext2fs_stat_blocksize(ext2_file_t file) {
13771377
return file->fs->blocksize;
13781378
}
13791379

1380-
unsigned long node_ext2fs_stat_i_size(ext2_file_t file) {
1380+
double node_ext2fs_stat_i_size(ext2_file_t file) {
13811381
return getUInt64Number(file->inode.i_size_high, file->inode.i_size);
13821382
}
13831383

0 commit comments

Comments
 (0)