When copying large files into a ext filesystem at mkfs time the copy
fails at 2^31 bytes in. There are two problems:
copy_file_chunk() passes an offset (off_t, 64-bit typically) to
ext2fs_file_lseek() which expects a ext2_off_t (typedef to __u32) so
the value is truncated. Solve by calling ext2fs_file_llseek() which
takes a u64 offset instead.
try_lseek_copy() rounds the data and hole offsets as found by lseek()
to block boundaries, but the calculation gets truncated to 32-bits.
Solve by casting the 32-bit blocksize to off_t to ensure this doesn't
happen.
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
ptr += blen;
continue;
}
- err = ext2fs_file_lseek(e2_file, off + bpos,
+ err = ext2fs_file_llseek(e2_file, off + bpos,
EXT2_SEEK_SET, NULL);
if (err)
goto fail;
if (hole < 0)
return EXT2_ET_UNIMPLEMENTED;
- data_blk = data & ~(fs->blocksize - 1);
- hole_blk = (hole + (fs->blocksize - 1)) & ~(fs->blocksize - 1);
+ data_blk = data & ~(off_t)(fs->blocksize - 1);
+ hole_blk = (hole + (off_t)(fs->blocksize - 1)) & ~(off_t)(fs->blocksize - 1);
err = copy_file_chunk(fs, fd, e2_file, data_blk, hole_blk, buf,
zerobuf);
if (err)