mirror of https://github.com/vitalif/e2fsprogs
libext2fs: set the large_file feature flag when setting i_size > 2GB
If someone tries to write a file that is larger than 2GB, we need to set the large_file feature flag to affirm that i_size_hi can hold meaningful contents. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>debian-1.42.9
parent
7320cb7106
commit
92a7b0d2e3
|
@ -389,6 +389,18 @@ errcode_t ext2fs_file_set_size2(ext2_file_t file, ext2_off64_t size)
|
|||
old_truncate = ((old_size + file->fs->blocksize - 1) >>
|
||||
EXT2_BLOCK_SIZE_BITS(file->fs->super)) + 1;
|
||||
|
||||
/* If we're writing a large file, set the large_file flag */
|
||||
if (LINUX_S_ISREG(file->inode.i_mode) &&
|
||||
EXT2_I_SIZE(&file->inode) > 0x7FFFFFFULL &&
|
||||
(!EXT2_HAS_RO_COMPAT_FEATURE(file->fs->super,
|
||||
EXT2_FEATURE_RO_COMPAT_LARGE_FILE) ||
|
||||
file->fs->super->s_rev_level == EXT2_GOOD_OLD_REV)) {
|
||||
file->fs->super->s_feature_ro_compat |=
|
||||
EXT2_FEATURE_RO_COMPAT_LARGE_FILE;
|
||||
ext2fs_update_dynamic_rev(file->fs);
|
||||
ext2fs_mark_super_dirty(file->fs);
|
||||
}
|
||||
|
||||
file->inode.i_size = size & 0xffffffff;
|
||||
file->inode.i_size_high = (size >> 32);
|
||||
if (file->ino) {
|
||||
|
|
Loading…
Reference in New Issue